Compositor setup with depth textures and RTV Topic is solved

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


jwwalker
Goblin
Posts: 268
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 19

Compositor setup with depth textures and RTV

Post by jwwalker »

I'm trying to change my compositor so that rendering goes to locally-created textures until the end, at which point it may be copied to a window. But I'm having a problem with depths.

If I set up a compositor node to use local color and depth textures, linked with an RTV, can I then pass them to other nodes, and have the depth texture still be the depth buffer for the color texture? Setting up an RTV in a script seems to be too new to be in the manual, and unfortunately the phpBB forum software won't let me search for a 3-letter word like "rtv".

Consider the following:

Code: Select all

compositor_node Start
{
    in 0 ultimateDestination
    
    texture colorTx target_width target_height target_format
    texture depthTx target_width target_height PFG_D32_FLOAT

    rtv colorTx
    {
        depth depthTx
    }
    
    target colorTx
    {
        pass render_scene
        {
            load { all clear }
            store { all store }
            rq_first    0
            rq_last     210
        }
    }
    
    out 0 ultimateDestination
    out 1 colorTx
    out 2 depthTx
}

compositor_node Halo
{
    in 0 ultimateDestination
    in 1 colorTx
    in 2 depthTx
    
    texture selDepth target_width target_height PFG_D32_FLOAT

    target selDepth
    {
        pass render_scene
        {
            load { depth clear }
            store { depth store }
            rq_first 211
            rq_last 212
        }
    }
    
    target colorTx
    {
        pass render_quad
        {
            load { all load }
            store { all store }
            material JWHalo
            input 0 selDepth
        }
    }
    
    out 0 ultimateDestination
    out 1 colorTx
    out 2 depthTx
}

compositor_node Finish
{
    in 0 ultimateDestination
    in 1 colorTx
    in 2 depthTx

    target ultimateDestination
    {
        pass render_quad
        {
            load { all clear }
            store { all store }
            material JWCopy
            input 0 depthTx
            input 1 colorTx
        }
    }
}

It looks as if the depth check always passes in the quad pass of the Halo node. That didn't happen when the quad pass of the Halo node was rendering to the window.

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5477
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1359

Re: Compositor setup with depth textures and RTV

Post by dark_sylinc »

Hi!

RTVs are local to the node they're defined in.

So when you define Halo node, I strongly suspect you meant to do this:

Code: Select all

compositor_node Halo
{
    in 0 ultimateDestination
    in 1 colorTx
    in 2 depthTx
    
    texture selDepth target_width target_height PFG_D32_FLOAT

    // We need to create "colorTx2" because "colorTx" can't be overriden due to being an input
    rtv colorTx2
    {
        colour colorTx
        depth depthTx
    }

    target selDepth
    {
        // ... Same definition you had
    }
    
    target colorTx2
    {
        // ... Same definition you had for colorTx
    }
    
    out 0 ultimateDestination
    out 1 colorTx
    out 2 depthTx
}

Otherwise by default OgreNext will look at the depth buffer pool ID of colorTx and assign an existing (non-texture) depth buffer; which likely it will have to create a new one. That's why your render_pass looks like it always passes. It's using a new depth buffer.

That didn't happen when the quad pass of the Halo node was rendering to the window.

The Window's depth buffer is a special case so it has a special depth buffer that sticks with it.
Though I don't know why your compositor was working (or maybe it was buggy in a different way and you just didn't notice)

jwwalker
Goblin
Posts: 268
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 19

Re: Compositor setup with depth textures and RTV

Post by jwwalker »

dark_sylinc wrote: Wed Jun 21, 2023 6:08 am

RTVs are local to the node they're defined in.

Aha! That's the piece of (undocumented?) knowledge I was missing. Thanks!