Order matters when using ConfigureInput for ScriptableRenderPass (either a bug or missing documentation)

So i’ve been working on this render feature and i needed access to the camera normals and depth texture in the pass.

I configured the inputs for my pass so i can have access to normals and depth, but i noticed that order matters.

this works:

m_ScriptablePass.ConfigureInput(ScriptableRenderPassInput.Depth);
m_ScriptablePass.ConfigureInput(ScriptableRenderPassInput.Normal);

this doesn’t:

m_ScriptablePass.ConfigureInput(ScriptableRenderPassInput.Normal);
m_ScriptablePass.ConfigureInput(ScriptableRenderPassInput.Depth);

fyi it sends

InvalidOperationException: Trying to use a texture (_CameraNormalsTexture) that was already released or not yet created. Make sure you declare it for reading in your pass or you don't read it before it's been written to at least once

and breaks the renderer.

This is not written in the docs, do not sure if this a bug or a documentation error.

I’m using Unity 6000.0.23f1 and URP 17.0.3

Hey @hugohil,

Can you try?
m_ScriptablePass.ConfigureInput(ScriptableRenderPassInput.Normal | ScriptableRenderPassInput.Depth);

ConfigureInput API should only be called once with all the required inputs, by calling it twice you are overriding your initial choice and losing it.

First case:

m_ScriptablePass.ConfigureInput(ScriptableRenderPassInput.Depth);  // required input is depth
m_ScriptablePass.ConfigureInput(ScriptableRenderPassInput.Normal); // required input is now normal only

Second case:

m_ScriptablePass.ConfigureInput(ScriptableRenderPassInput.Depth);  // required input is normal
m_ScriptablePass.ConfigureInput(ScriptableRenderPassInput.Normal); // required input is now depth only

.... // your render feature uses the normal texture but URP is not aware that it is a required input for your pass and therefore the resource is not ready, triggering an error at RenderGraph level.

Thanks

1 Like

Hey!

thanks for your answer!

I tried

m_ScriptablePass.ConfigureInput(ScriptableRenderPassInput.Normal | ScriptableRenderPassInput.Depth);

and don’t have access to the depth texture anymore.

it does the same if i do

m_ScriptablePass.ConfigureInput(ScriptableRenderPassInput.Depth | ScriptableRenderPassInput.Normal);

or

m_ScriptablePass.ConfigureInput(ScriptableRenderPassInput.Depth);
m_ScriptablePass.ConfigureInput(ScriptableRenderPassInput.Normal);

which makes sense with what you said. I have access to the depth texture only if i call it last.

In the end I don’t use the camera normal texture anymore, I do a custom pass, compute the view space normals for a certain render list and use this render attachment in my fullscreen pass. so I’m only configuring for depth.

But i’m curious as to what would be the right way to access both camera depth and camera normal texture in one single render feature. Do you have an idea?

Hey, I’m a bit confused here.

m_ScriptablePass.ConfigureInput(ScriptableRenderPassInput.Normal | ScriptableRenderPassInput.Depth);

This ^ is supposed to be the correct way to require both normal and depth inputs for your pass. We currently use this exact same workflow in URP for SSAO pass (link) and DBuffers (link), and it seems to be working.

How can you tell you don’t have access to the depth texture anymore? Something else might be wrong.

Ok, not sure what happens but when accessing resourceData.cameraDepthTexture in my pass depending on if i’m using
m_ScriptablePass.ConfigureInput(ScriptableRenderPassInput.Depth);
or
m_ScriptablePass.ConfigureInput(ScriptableRenderPassInput.Normal | ScriptableRenderPassInput.Depth);

I have two different cameraDepthTexture. First one with just red channel is first configure, second in grayscale is second configure.

Any idea what’s happening here ? :smiley:

It looks like a bug, please file a bug report with a simple repro case and we will investigate it. Thanks!