A small depth offset, but a large effect

Hmm… I’m not sufficiently familiar with that specific part of rendering to be confident in judging, but it seems as though it might work.

(As it happens, my decals already use a shader of their own, so this would just be a matter of modifying an extant shader, rather than making a new one.)

Thank you for that–I’ll hopefully give it a shot soon! :slight_smile:

A quick question, if I may: What would the scale of “fudge” be? Would it be equivalent to the units of “setDepthOffset”? Or smaller increments (0.1, 0.01, etc.)? Or larger (10, 100, etc.)?

Perfect! Then you’re all set up, you can make your decals co-planar with the wall polys and the shader will adjust the z values so you don’t have any z-fighting.

1 Like

Oops, missed this piece.

It’s a totally arbitrary value, it’ll just modify your depth buffer values relative to the depth precision that you have based on your view frustum near/far planes. So unfortunately you’ll just want to use the absolute smallest value that you can, that stops zfighting. Some trial / error.

If you use too big a value you’ll see similar artifacts, you’re essentially pushing pixels ‘into’ the camera when you do this, so you want the effect gentle.

Some lightmap implementations I’ve seen use something around 0.01 iirc (it’s been a while since I wrote lightmap code, ~ 15 years ago).

Hope it helps, curious to see how it goes, keep us posted!

Okay, got it, and thank you again! :slight_smile:

I will likely report back when I have results! :slight_smile:

[edit]
I can confirm that it seems to work! :slight_smile:

Very cool! Glad to hear. Maybe a useful snippit to have for folks doing coplanar decals, when we have time for a writeup sometime in the future :slight_smile:

1 Like

In all fairness, from what rdb said there seem to be plans in place to address this within the engine, so the above solution may not be required in later versions.

1 Like