Hello everyone
As in the topic title I’ve this simple question:
Is it possible to have the following rendering flow?
I need this for prototype my 2.5D test application (3D objects with 2D background). I already tried with depth texture but due to non linear z buffer is a bit difficult to manage.
In pratical what I need is a high resolution background, a very simple geometry for occludes objects in midground (so only depth is written and no color).
I already tried in the past with this way, but for occludes in a good way midgrouds objects I need a very precise geometry and this is not good because geometry must have same detail of final render.
So my idea was to render a very simple geometry for occludes a “superset” of midground object, and then a stencil to follow the 2D object boundary (for examole if I have a table in the room, the geometry can be a simple cube, and stencil follow the table details). In this way I have a precise rendering and simple geometry. My idea was this, is it possible?
Render a quad with background
Write only depth for geometry
Render 3D actors.
3.1. For each actor pixel, if depth test passes, so render the pixel, otherwise (3.2).
3.2. make the stencil and test stencil, if passes render the pixel, otherwise NOT render.
Logic should be ok in my opinion, but I don’t how to do it in a smart way with good performances.
If the depth test fails, the fragment colour and depth remain unchanged.
You can choose whether the fragment’s stencil value is updated if the depth test fails. Stencilling has 3 cases: stencil test fails, stencil test passes and depth test fails, stencil test and depth test both pass. But this only affects the stencil value; the colour and depth are only modified if all tests pass.
Hi GClements,
Second case should be what I need, so depth test failed and stencil, but sorry it’s still not so clear from my side if it’s possible to obtain my behavior, in a nutshell for what I need the actor pixels must be NOT written only if either depth and stencil failed, in all other case must be written.
From what I know of your application, you don’t need stencilling, you just need a sufficiently-accurate depth texture with which to initialise the depth buffer each frame.
Dear GClements,
thanks a lot for your support, yes, you understood well, infact filling the depth buffer with a depth texture was my first (and also favourite) idea, I tried this also trick because I had problems with first idea, but now that I have an example I can show you a bit better my problems on the original topic (just to don’t go OT)