Jump to content
  • Advertisement
Sign in to follow this  
FritSolomon

Proper billboarding/impostors for asteroids fields, where object instances are re-scaled

This topic is 813 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am currently in the phase of implementing in my 3D space game a procedurally generated asteroid field. Firstly I generate 10 different asteroid meshes (by displacing the vertices of a sphere). Next, for each asteroid, I do the following: 1) pseudo-randomly pick of the 10 mesh-models; 2) instance it in a pseudo-randomly chosen position; 3) assign an ID based on position; 4) rotate and re-scale the instances to make the look of asteroids more varied.

That process works well, but of course for really high number of asteroids in a big asteroid field, this is not ideal since the game ends up with too many instances to render. In order to increase the number of asteroids while decreasing the performance cost, what I am trying to do is to use billboards/imposters for the many thousands of asteroid instances that are just far away in the scene.

 

There are two basic approaches I can think of about how to implement that. The first attempt is to just store in a texture atlas for each of the 10 mesh-models many different view angles  from which these models can been spotted from afar, then choose a position based on camera angle and position. The problem with that is the following: since the thousands of instances have different re-scaling, a quad used for billboarding/impostoring wouldn't really resemble the real instance since depending on the view angle, stretching the quad would not result in the same asteroid shape as each instance that is intended to be represented.

The second attempt could be to, instead of saving any texture-atlas beforehand, to re-render the models meshes to texture when camera rotates above a given threshold. The problem with that seems obvious: for many thousands of asteroids using those billboards, re-rendering model meshes to texture would end up being pretty expensive.

So, in a nutshell, my main question in generic format is: which billboard/impostor technique can I use to handle my many thousands of instances when these instances are each re-scaled?

Share this post


Link to post
Share on other sites
Advertisement

If you are using instancing, that is 10 different models, so only 10 draw calls. So how many models do you have? What is the vertex count?  Why not LOD the asteroid geometry into 1 or 2 more LOD levels. If you are using displacement mapping then LOD geometry is as simple as a sphere with less subdivisions.

 

If you really wanted to get fancy, those 10 draw calls could be reduces to 1 if you are passing per object matrices and per object id's in range 1 to 10. In the shader you can use a texture array and use the id to look at a certain displacement map. (Not sure if texture arrays are supported in vertex shader but they probably do in the modern feature set).

 

Regardless, how many triangles are you pushing? I would think it would be much simpler to just LOD until performance is good (you could get it down to probably 20 verts per asteroid). You should easily be able to push a million verts which would be 50,000 asteroids above 60fps.

Share this post


Link to post
Share on other sites

Interesting, though I am much more from the 2D world. Out of curiosity, how is it done in 3D to know when you reach a time when extra details adds too many burden and steals an unacceptable amount of cycles?. And that moment you know to put a simple box sky with textures representing the bulk of asteroids (and only the closest or most posing a threat, being real 3 D asteroids).

Share this post


Link to post
Share on other sites

 

Out of curiosity, how is it done in 3D to know when you reach a time when extra details adds too many burden and steals an unacceptable amount of cycles

 

When you are writing the same pixel over and over (meaning you have an asteroid behind an asteroid behind an asteroid and if you draw in reverse order it will continually update the same pixel), or you have very tiny triangles. If you have triangles that are 1x1 pixel or so, then it will chew up performance. Pixel shaders run on 2x2 blocks of pixels for mip mapping reasons so if you have a bunch of tiny triangles it causes a ton more work at a single pixel location.

 

In the case of an asteroid field, most of the screen isn't going to be drawn, just a bunch of small/fairly small asteroids, that is why you want to LOD down to like 20 verts or so because you don't even know the difference at that far away. You can't make out much geometric shape.

Edited by dpadam450

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!