RendererFeatures not getting camera target source in urp 10

Hello
I don’t know if it’s been mentionned, but I think there’s a problem with the new version of ForwardRenderer.cs in the 10.0.0-preview.26.
The

AddRenderPasses(ref renderingData);

in the Setup is made before the

ConfigureCameraTarget(activeColorRenderTargetId, activeDepthRenderTargetId);

I think you cannot get the camera target in the RenderPasses, so it’s not possible to render to a temporary render target and then back to the original source. At least, that’s what happens in my RendererFeatures. For example, if I save the source in my setup and put it back at the end, everything that happens after is writing to a “no name” render target. If I set my RendererFeature before Transparents, I lose all Transparents objects because they are written to an unknown render target instead of the _CameraColorTexture. I’ve been trying to modify the code in the ForwardRenderer without succes for now. Except being able to effectively get the good source in the RendererFeatures and send back the camera to this target at the end.
Btw, with the previous version of the urp, I didn’t have this problem. And, of course, the ForwardRenderer.cs in this version is adding the RenderPasses after configuring the camera target.
But… maybe the whole process has changed and I’m doing something wrong.

(Edit)
I just moved

AddRenderPasses(ref renderingData);

after

            // Assign camera targets (color and depth)
            {
                var activeColorRenderTargetId = m_ActiveCameraColorAttachment.Identifier();
                var activeDepthRenderTargetId = m_ActiveCameraDepthAttachment.Identifier();

#if ENABLE_VR && ENABLE_XR_MODULE
                if (cameraData.xr.enabled)
                {
                    activeColorRenderTargetId = new RenderTargetIdentifier(activeColorRenderTargetId, 0, CubemapFace.Unknown, -1);
                    activeDepthRenderTargetId = new RenderTargetIdentifier(activeDepthRenderTargetId, 0, CubemapFace.Unknown, -1);
                }
#endif

                ConfigureCameraTarget(activeColorRenderTargetId, activeDepthRenderTargetId);
            }

And it’s working…

1 Like

Have you submitted a bug report?

You are right, I should have… so I just did it.

It seems it’s working now with the original ForwardRenderer.cs. There was a new warning message that you should not use the renderer.cameraColorTarget outside of the ScriptableRenderPass, unlike what’s shown in the examples.
I saved a reference to the renderer in the pass via the setup and got the source from the renderer in the configure method Inside the ScriptableRenderPass. Code extract below :

        public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
        {
            scriptablePass.Setup(renderer);
            renderer.EnqueuePass(scriptablePass);
        }
            private RenderTargetIdentifier source { get; set; }
            private ScriptableRenderer renderer;

            public void Setup(ScriptableRenderer renderer)
            {
                this.renderer = renderer;
            }
            public override void Configure(CommandBuffer cmd, RenderTextureDescriptor cameraTextureDescriptor)
            {
                this.source = renderer.cameraColorTarget;
            // (...)       
            }

That did it.

2 Likes