URP Custom RendererFeature is affecting Shader Graph Main Preview

Hi there, I reckon this should be a simple one but I have no idea where to start. I have just finished a custom RendererFeature that draws outlines around specific objects using some blitting back and forth. No problems there!

The issue I am having is that my final result is being blitted to the Shader Graph Main Preview window behind whatever geometry is visible.

I am using the cameraColorTarget as the source and the RenderTargetHandle.CameraTarget as the destination.

if (destination == RenderTargetHandle.CameraTarget)
                    {
                        RenderTextureDescriptor opaqueDescriptor = renderingData.cameraData.cameraTargetDescriptor;
                        opaqueDescriptor.depthBufferBits = 0;

                        cmd.GetTemporaryRT(temporaryColorTexture.id, opaqueDescriptor);

                        Blit(cmd, source, temporaryColorTexture.Identifier(), blendMaterial, 0);
                        Blit(cmd, temporaryColorTexture.Identifier(), source);
                    }
                    else
                    {
                        Blit(cmd, source, destination.Identifier(), blendMaterial, 0);
                    }

I figure that I need to somehow prevent the RenderPass from enqueuing but for only when the Shader Graph Main Preview window is the target.

Any help would be greatly appreciated!

I solved my own issue. Hope this helps someone!

public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        if (renderingData.cameraData.cameraType != CameraType.Preview)
        {
            renderPass.Setup(renderer.cameraColorTarget, RenderTargetHandle.CameraTarget);
            renderer.EnqueuePass(renderPass);
        }        
    }
2 Likes