Billboards and depth buffer

In many games I see that use billboards, for example something drops on the floor and some dust is generated by rendering some billboards, or there is a light bulb and they render a light bloom (light glow, light halo, light flare) around the bulb,
the billboards get cut if they intersect another geometry nearby like the ground or a wall.

I suppose one could generate the billboards such that they don’t intersect anything which costs CPU time. It would not be easy to make it look good.

Could some graphics trick be used to prevent the billboards from getting cut?

Frequent solutions are :

  • offset billboard depth towards the viewer (seen in Quake3 for explosions, not perfect), simple yet very effective for light bulbs.
  • use physics to keep billborads away from geometry, like in car racing games so that dust won’t go through the ground. Physics in this case are often simplified (ie, it will intersect trees and such), I believe that is what you mentioned regarding CPU usage.

… just an idea, maybe a clever pixel shader to blend the hard cut : store the scene depth (without billboards) in a texture, then when drawing a billboard set transparency depending on the depth difference, so that the hard cut end up being a smooth gradient. Some kind of simplified volume fog. Can be a fillrate killer though.

Offsetting is a cheap solution but I’m thinking of something that’s more effective. I would need extreme offsetting in the case of a light in the corner of a room.

I may apply a different solutions depending on the type of billboard, so #2 is fine for rapid billboards.
Humus’s volumetric lights 2 looks good.
Some explanation would be nice.

Other tricks:

  • Know where the floor or wall plane is (in object space), and make the last few inches of the billboard fade away when close to the plane.

  • Use depth replace to make the billboard non-flat. A curved intersection surface often looks much better. Draw these last in your scene, because when using depth replace, further drawing until the next Z clear will not get the advantage of early Z.

  • Use lots of small particles with very faint texturing on them, so that the total sum will look like a better simulation.

Originally posted by jwatte:
- Use depth replace to make the billboard non-flat. A curved intersection surface often looks much better. Draw these last in your scene, because when using depth replace, further drawing until the next Z clear will not get the advantage of early Z.

I’m going to give this one a try. It should give visually consistent results and I’m not worried about the performance at this point. I’ll post a screenshot of my test.