Spellcaster Studios

Make it happen…

More issues with decals…

Unfortunately, my initial idea that screen-space decals was some sort of magic bullet was completely wrong…

They work great a lot of the time, easy to implement, fast… but (there’s always a but) they have some small details which break it down…

The issue I talked about yesterday was mostly solved with the stencil buffer:

screen428

So that’s good, I can mask where the decals is drawn and where it isn’t… But unfortunately, it doesn’t solve the issue with the explosions, since there we want to draw the decal, but “behind” the explosion, but due to the way alpha blending works, it doesn’t work:

screen429

If you’d see the stencil buffer, you’d notice that on the edge of the explosion (where there isn’t almost any color, but it’s necessary for its smoothness) is flagged as not allowing the decal, but we’d like a decal there, and then the explosion… I can maybe solve this by playing around with the passes (move the explosion to the effect pass, and only draw decals on the alpha pass), but it’s getting to be a sloppier and sloppier implementation…

Another issue is the edge of the geometry… For example, on the window of the Skydancer, this works fine if the explosion isn’t on top of the glass:

screen430

But as soon as it overlaps, the UVs get stretched:

screen431

This one I was actually expecting and I can probably solve it with some threshold on the angle between the decal normal and the world normal.

One more issue, mostly relating to the “scorch marks” decal: what happens on the edges of objects:

screen434

It seems the scorch is something planar… I can fix partly finish this by extending the decal box on the Y-axis, but it would just extend the black on top the the wall, which would look very weird…

One possible solution for this one is to create some sort of “radial decal”, which instead of being a box, ends up being a sphere and with some different mapping (might be hard for the artist to build the texture for this).

Finally, another expression of the alpha issue and the fact that alpha-objects aren’t affected by decals (by not letting decals be drawn):

screen433

The glow of the beam is a billboard drawn on the ground, which will fill the stencil buffer with a mark saying “don’t draw here”, which stops the decal from being drawn, which spoils the decal effect…

Again, this one might be sorted by doing a separate decal pass…

Finally, one of the problems that isn’t a real problem now is the fact that this requires a lot of rendering in separate passes, etc… This could be minimized by doing a “gather” phase before rendering… Basically, just iterate all objects and fetch all the meshes and materials in the scene, with some more properties describing what kind of usage they have… With that I can then just iterate it and draw/not draw according to the specific circumstance…

So, basically decals have extended my to-do list instead of reducing it… For a lot of stuff (like bullet holes on walls), the current solution would work fine, but my main interest at this point was to use the decals for the scorch marks (with the above results), entity shadows (think that one would work in most cases, except inside the facilities) and the shadows for the poison cloud and storm cloud (might work).

So I think the next stop will be creating the gather phase (which I also hope will help clean up the code and optimize a lot, even if there isn’t a big need for it), which is extremely boring! Smile

Now listening to “Savage Poetry” by “Edguy”

Link of the Day: Found this white paper on how to make a system for AABB trees for collision detection while saving loads of RAM, you might find it interesting… I know I did: http://www.codercorner.com/ZeroByteBVH.pdf

Comment