Can a basic SpatialMaterial add a Z offset?
Asked Answered
C

2

0

I have a scene that has a lot of semi transparent decals that need to be applied to walls. The decals use a duplicate of the geometry of the surfaces they are being applied to - so all the polygons of the decals exactly match the vertex positions of the underlying mesh. They just have different UVs and a different material. Also, the decal shader is partially transparent while the base mesh does not.

I would like the decals to be drawn over top of the base mesh. Since their triangles coincide, I'm worried this will cause fighting. I know in OpenGL there is a parameter you can set that adds a small offset to a fragment's Z value to get around this issue. I was wondering if the Spatial Material had a similar feature, or if I would have to write my own shader just to manually tweak the Z value?

Ciaracibber answered 5/2, 2022 at 15:32 Comment(0)
S
0

I don't know a way to do it without shader intervention, although you don't need to write much. Simply convert spatial material to shader material and in shader code get FRAGCOORD.z, adjust its value and assign it to DEPTH.

Secunda answered 5/2, 2022 at 16:29 Comment(0)
T
0

If the mesh's normals are correctly configured, using the SpatialMaterial Grow property on the decal pass should do the trick.

Turnbow answered 5/2, 2022 at 18:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.