I would like to have one object (StaticModel) always visible over one chosen another object (regardless of depth), something like using technique ‘NoTextureOverlay’, but my object should be rendered normally in relation to all other models (with depth test, etc…). Please, let me know how to do it?
Thanks in advance
It’s quite tricky request because it contradicts usual rendering pipeline.
It’s possible with stencil tricks, but this is really hard way.
What’s the target hardware and how much objects you want to draw this way?
Thanks for your answer, I was hoping that there is some simple way to do this…
I want to draw only one object this way. Target platform: PC with Windows.
The problem is that you need depht test enabled to draw any non-convex object, so you need depth test on for both objects. On the other hand, you don’t want these objects to interfere with each other…
If you use forward lighting for these objects, the problem become even more severe.
Possible solution (no forward lighting) is:
- Draw object below, depth test on, depth write on.
- Redraw the object below with custom shader that sets depth to 1. depth test on, depth write on, depth function equal.
- Draw object above, depth test on, depth write on.
- Draw object below again, depth test on, depth write on, color write off.
In the result you will get object below, overlapping object above and valid depth for both objects.
This might be of interest: How to control render order?