Asteroid Fields revisited

Community Forums/Showcase/Asteroid Fields revisited

Krischan(Posted 2012) [#1]


This is another miniB3D tech demo I'm working - and I would love to hear your comments. It is using miniB3D's latest small fixes version, my source and a compiled EXE are included. Oh, this is just plain OpenGL, no shaders used here. There is still a lot of work, small fixes and ideas to include but I want to share this snapshot with the community right now because it's really, really eye candy :-D No comparison to my old procedural saturn and it's even faster.

Fly around with the mouse and the arrow keys, LMB shoots some lasers (only if boosters are off) and RMB activates the boosters for faster system travel, other keys are displayed in the info text. The quad "engine" controls 25000 asteroid quads right now but it could handle even more with the proper CPU/GPU at a decent FPS rate.

Have fun and any improvements/suggestions with source are welcome.

Download: QuadAsteroidFieldDemo.zip [5.0MB]

Last edited 2012


Yasha(Posted 2012) [#2]
Well that download set my antivirus a-wailing. It seems very concerned, lots of red text and deleted the main executable.

It's probably a false positive - it's AVG, they always are - but I feel it's worth mentioning.


Krischan(Posted 2012) [#3]
Hmm the main executable inside the 7zip SFX archive is packed with UPX LZMA compression. I recompiled it again, this time uncompressed and packed everything in a standard ZIP File. My local virus scanner couldn't find anything (Antivir). Please try it again, I changed the download link.

Edit: I double-checked it with an online virusscan service with 37 different scanners, found nothing. So it must have been a false positive.

Last edited 2012


Yasha(Posted 2012) [#4]
Yep second one works without any complaint.

As for the thing itself... wow. Amazing. Stunningly beautiful, very smooth, good FPS. That's a really clever technique with the asteroid lighting. I expect if you had a "full" game engine involving collision, the trickery wouldn't be visible at all, since you wouldn't be able to fly close enough to see it (currently you can sort of see how things are done if you fly within what ought to be an asteroid's radius, but you have to be looking for it).

Have you given any thought to how you would handle multiple light sources? The only thing that stands out at all at the moment is simply that weapons fire doesn't light up the back of a rock. Can the lighting effect be applied to only a part of an object? Although for most purposes you wouldn't have to do this: with a "big" light source like an explosion I guess you could light the whole object from the new angle briefly, which would be cheaper?

At any rate: sir, you have done it again. A fantastic piece of eye candy.


Ploppy(Posted 2012) [#5]
Very impressive, a real bute. Works fine on my system, getting about 60fps, just shows what blitz is capable of. Pretty much everything with talent and good thinking behind it.


Ploppy(Posted 2012) [#6]
In fact, reminds me a bit of the opening creds to star trek voyager when the ship flies through a planet's rings. Real well done...


Krischan(Posted 2012) [#7]
Have you given any thought to how you would handle multiple light sources? The only thing that stands out at all at the moment is simply that weapons fire doesn't light up the back of a rock. Can the lighting effect be applied to only a part of an object? Although for most purposes you wouldn't have to do this: with a "big" light source like an explosion I guess you could light the whole object from the new angle briefly, which would be cheaper?

Basically - as you can read from the full included source (see inc/TAsteroid.bmx and the main loop) - the quads are lit according to their vertex positions by their normals, so they are only lit by the main light source, the star. I think a second light should work somehow. But the light source must be a point light for proper lighting. I never tried a second light but you can play around with it.

I keep updating the quads in a very simple distance/time system: if the quad position is far away from the cam the update will be less frequently than a very close one, which gives a relative constant FPS inside the asteroid belt. I already thought about using real meshes for the very close asteroids. But even close the quads look stunning until you are *really* close to them. The asteroid texture is made of screenshots from some asteroid mesh models, so I could fade the real ones in. But the transition must be smooth.

Collisions will be a problem if I use the whole quad mesh but with separate close asteroid meshes it could work as I only have to check these for collision. And they can be lit independent from the far away asteroids.

I really don't know how big this "engine" will become, I'm just happy about the achieved result and the stunning optical FX right now :-D And it's a good proof what miniB3D is capable of, even in its current state. I'm only a little bit unhappy with my planet atmosphere, I think I could only improve it with a shader, but that's not possible with this version of miniB3D.


RemiD(Posted 2012) [#8]
Beautiful environment indeed. :)

The demo runs ok on my machine.
Lenovo Thinkpad E325, DualCore AMD E-450 APU 1.65Ghz, 6 Go DDR3-1333, Radeon HD 6320 Graphics 384 mo, Windows 7 Home Premium

Can you explain what is "dot3" ? i prefer the appearance of the ship without it.


Krischan(Posted 2012) [#9]
Can you explain what is "dot3" ? i prefer the appearance of the ship without it.

It can happen that some video cards don't display the Textureblend 4 mode correctly (Intel onboard in general). Dot3 is the use of a normalmap to let the model appear with more triangles that it really has, so the model looks more detailed and the most important thing is that the normalmap is being used for the lighting, too. I made a small animation to show the effect:



Look at the left wing's end, there is a noticable "depth" in the wing area which is missing in vertex only light - beside many other small details visible. It is the same mesh, the effect comes only from the normalmap, in this case it is this texture:



How I applied it in miniB3D I already explained in this thread.


RemiD(Posted 2012) [#10]
Ok i see, it gives the illusion of more details. Thanks.

But if this effect is only to add the illusion of more details, why the light on the ship is of a different color. When i wrote that i prefered the appearance without the dot3 texture i meant the light color.


Krischan(Posted 2012) [#11]
That's because the effect only works with a fullbright model - the normalmap gets lighted from the base fullbright color of the model - and there is no place for other vertexcolors as the lighting would be messed up then. In other words - the star color doesn't matter here.

You describe the vertexcolors with the light color from the star. I already tried to simulate a colorful illumination with an additional texture on the fullbright model but weren't successful here at last.


Taron(Posted 2012) [#12]
Awwww...can't run it, I get an access violation. Don't have minib3d hooked up to debug it right now, but just so you know...
I'm running it on windows 7 pro 64bit on 12core HP Z600 with Nivia Quadro 5000.


Steve Elliott(Posted 2012) [#13]
I can run it...but no textures on craft.


Why0Why(Posted 2012) [#14]
Looks really great. Anytime I see your name starting a thread I always click on it :)


Krischan(Posted 2012) [#15]
Adding the lost post again:

Thanks! The problem with the missing textures on the craft could be the use of the "GL_DOT3_RGB_EXT" command in the miniB3D TMesh.bmx. I changed the lines under the tex_blend Selection from "EXT" to "ARB" like this:

Case 4
	glTexEnvf GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB
	glTexEnvf GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_DOT3_RGB_ARB

and then it worked with Intel cards, too (miniB3D must be recompiled then). But I'm not sure if this is a proper solution for all GPUs and the effect looks too "sharp" to me.

Here is a compiled EXE with the change applied to it, perhaps it works: demo2.exe [1.3MB]


Krischan(Posted 2012) [#16]


For the asteroid improvements I just created a small tool to create random shaped asteroids using 3D Perlin Noise out of a standard sphere, with export to B3D files! Use mouse/arrows to rotate, LMB creates a new asteroid and RMB switches between DOT3 and Vertex Lighting. With Q/A you can move away and RETURN saves the asteroid to "asteroid.b3d". In the screenshot you can see the difference between simple vertex lighting and the cool DOT3 normalmap lighting.

The only thing I couldn't handle is to weld the unused sphere vertices before the B3D export, so the B3D mesh file has too many vertices now (1960 vs. 482 vertices after weld in Ultimate Unwrap 3D) and looks flat shaded without "Weld Model" or "Autosmooth model" applied to it. If anybody can provide some source to pre-weld the unused vertices before export please post your source here!

Anyway, have fun with it:

Download Asteroid Creator Demo (4.0MB)

EDIT: updated the normalmap and changed some variables that a unique asteroid can be created with the same start parameters (if you note them first).

Last edited 2012


JonnyEnglish(Posted 2012) [#17]
This is insanely great. Keep up the Amazing work!


Hotshot2005(Posted 2012) [#18]
Impressive - Elite Dangerous Watch out and Incoming tranmissions....You got Competions coming from Krischan! :-P

Last edited 2012

Last edited 2012


Krischan(Posted 2012) [#19]
Take it easy, this is only tech demo - compared to a complete game like Elite I finished only 1%. But thanks for the commendations.


JonnyEnglish(Posted 2012) [#20]
I just love things like this, along with Orbiter etc. It's just look really nice!


Taron(Posted 2012) [#21]
Funny, earlier this year I wrote also such an asteroid creator for a game I had started. It, too, deforms a sphere based on my own perlin based turbulence, but I had variable polygon density that can create quite amazingly jagged asteroids as well as smoother ones. I wrote a fun normal map solution for it, too, which makes quite surprisingly detailed textures even with just a tiny image. However, I wrote it in Blitzmax. My game is actually 2.5d, but the story and gameplay was too ambitious for me to just finish it up...maybe I'll post a w.i.p at some point, not sure.

Anyway, your asteroid creator runs on my machine. Looks nice, too.