Custom Depth Stencil Sorting

If i understand correctly this setup should give ability to control sorting of stencil masks by stencil value.

But doesn’t seem like it works. Sorting happening based on last object i changed stencil value on. Am i missing something?

If you’re still working on this, the setting “All bits (255), ignore depth” will cause the object to overwrite the current Custom Stencil buffer with whatever value you have given it, ignoring the object’s depth. In your images, setting the chair to 1 causes it to write 1 to the stencil buffer regardless of its depth or what other values are in the buffer. This is why it appears on top if it’s the last object you touched.

Changing the setting to something else like “First bit (255), ignore depth” will still allow it to ignore the depth, but it will only write to the first bit instead of all 8. This way, you could allow multiple overlapping object to write to the same stencil pixel by having each object write to a different bit.

~zshore

1 Like

thanks for the reply, now i think i understand the system