0
Under review

Depth Blend doesn't work on opaque shaders

robert briscoe 10 years ago updated 10 years ago 2
For some reason Depth Blend doesn't seem to work on opaque shaders, see the screenshot below for my super simple shader: 

Image 246

With this shader, I would expect a border around where the sphere intersects with the ground, however there is none.

I can only fix this by turning on alpha blending in the shader (or plugging a value into the alpha slot) which is undesirable due to sorting issues etc.

Image 247

Is there a reason Depth Blend only works for transparent shaders?
Under review
The reason is this:

Opaque objects write to the depth buffer
Transparent objects usually don't
Depth blend (And the scene depth node) both read from the depth buffer.

So if you write to the depth buffer, depth blend won't work. You could make an opaque shader, and uncheck auto-sort in the blending options, and then disable write to depth buffer. You'll still most likely get some issues someplace, but it at least won't be alpha-blended

Let me know if it works/doesn't work :)
Thanks for the suggestion, I tried it out just now and unfortunately the results were not as I'd expect:


For some reason the object turns semi-transparent and has a strange white border around the edge.

I then started playing with the Render Types and found that most of the other modes seem to work, even with Write to Depth Buffer checked - it's just alpha clip and opaque that don't... odd!