Spellcaster Studios

Make it happen…

What’s life without some problems?!…

Well… Just finished implementing decals… It went better than expected, since I’ve never tried implementing screen-space decals before…

screen424

The main difficulty of screen-space decals is the occlusion. Most of the code is related to this, and mine is working great:

screen425

One problem I’m already seeing is the fact that the way the decal maps removes a bit of the volume of the scene in the affected area… Not sure if the problem is the texture (need to run tests), or if the UV mapping is not correct (but it seems to be, at least on this kind of “orthographic” decal, if it was a perspective decal, the contour of the underlying terrain might be more noticeable). This can also be minimized by using some sort of smoothing of the blend based on the angle of the underlying normal and the decal normal.

I have more serious issues, though, namely the alpha objects:

screen426

They get rendered “behind” the decal… The reason for this is very simple: the decal is completely drawn based on the existing depth, and the alpha objects usually don’t draw to depth, which means that from the decal rendering point of view, they simply aren’t there… This is a tricky one to solve…

The other one has another reason for it, but it’s also as tricky to solve:

screen427

Here, the sprite is drawn on the depth map, but the decal is still rendered “on top” of it… Here the issue is the fact that the decal act as sort of “projector” that affects EVERYTHING in the scene, including the player… Of course, this isn’t the goal (most of the time…)

Not sure exactly how I can solve this issue… One solution is to render to a stencil map what can or not be affected by the decals… Basically, I’d set on the stencil buffer to 1 in all the static geometry (which I want affected by the decals), and to 0 all the dynamic stuff (or more precisely, just don’t draw to the stencil buffer).

This is not a very elegant solution in my opinion because it requires me to render to another buffer, but in all honesty, I don’t see any way around it: the decals need to be aware where they can be drawn in screen-space. From a perfomance point of view this can be made quite fast with a Z-equal test, no color or z-writes, and choosing the objects I’m interested in “decaling”.

The good news is that they are rather fast (at least on my PC) and on static geometry they work as a charm!

Now listening to “Songs from a Room” by “Leonard Cohen”

Link of the Day: I’m not a big fan of online competitive games, so I’m not seeing myself playing this one, but it looks extremely cool: http://www.polygon.com/2015/1/27/7917991/dreadnought-video-gameplay-preview

Comment