Download

Mesh decals distance problem

Hi,

I have this problem when I try to use the new 4.13 mesh decals and I see the decals from distance :

68ebc14a41c19b85538c180855b2d914d890b1d6.jpeg

The decals ends up being rendered on top of every object when moving far enough.
I activated Dbuffer, early Z-pass “Opaque and Masked meshes” and Movable in early Z-pass.
My decal is in Dbuffer translucent color blend mode.

Did I miss something ? Is there a way to avoid this problem ?

Thanks !

We have also come across this problem on our PS4 build as well and are looking for a good solution. Not sure whether it is related to any LODs or the materials that the decal is then drawing onto.

tumblr_m5ufc4GwJ61qdhsxp.0.jpg

yeah…

the shader is pushing the geometry towards the camera based on depth, to avoid Z-fighting issues. it even has a “TODO refine or expose” on it :eek:

No way to avoid the prob for the time being then… Thanks for the info.

actually I don’t really know how they plan to fix this
if you remove this part of the shader code you get a lot of Z-fighting (tried it). if they expose the value of “how much to push towards the camera” then the users will be caught up in choosing between Z-fighting or decals going on top of other things… or both

this all comes because mesh decals don’t really behave like decals. not in the way of being “projected” like a regular decal (which is very non trivial to do)
all they are, are meshes that get rendered on the decal pass and as such benefit from a few of its features

If you want to play with the offset you can find it in MeshDecals.usf
Line (106) responsible for it:

When I played with this, I did not find a value that would be satisfying.
Did you try using deferred decal instead?

Thanks vebski ! I’ve removed “Output.Position.z += 0.0001f * Output.Position.w;” Now it seems to work perfectly for what I need.
Here’s an exemple of great mesh decals in Blizzard Overwatch :
48ddc56d9713670c0b06f162ddbea57d1ed96d1b.jpeg
As you can see, they have big offsets probably to avoid Z-fighting but in game you don’t see it if you don’t look really close.

To get over this issue a formula has to be figured out, which would replace


0.0001f

with a value, that depends on distance to the cam. Constant value won’t do.

EDIT: Lowering the offset value to 0.000025 actually helped for most of the decals while not producing any visible Z-Fighting.

if a mesh looks bad at a distance, use an LOD.