Hi there,
I’m trying to create a URP custom renderer feature, but I’m having some difficulties… I’m not sure if I’m doing something wrong, or the sample I used as a starting point is wrong, or if there is a bug in Unity. My starting point was the sample here: Unity - Manual: Example of a complete Scriptable Renderer Feature in URP. In fact, I’m not much further than the starting point - I just wanted to get that working before changing anything. But when I apply the renderer feature, I get a black screen as a result. I’ve looked at what is happening in the frame debugger, and it seems to me that the vertical pass is sampling from the wrong texture:
It is writing to the texture I would expect though (the same one it’s reading from, for reasons I don’t understand):
![]()
To give some context without having to go through the whole page above, the pass is set up like this:
...
TextureHandle srcCamColor = resourceData.activeColorTexture;
TextureHandle dst = UniversalRenderer.CreateRenderGraphTexture(renderGraph,
blurTextureDescriptor, k_BlurTextureName, false);
// Update the blur settings in the material
UpdateBlurSettings();
// This check is to avoid an error from the material preview in the scene
if (!srcCamColor.IsValid() || !dst.IsValid())
return;
// The AddBlitPass method adds a vertical blur render graph pass that blits from the source texture (camera color in this case) to the destination texture using the first shader pass (the shader pass is defined in the last parameter).
RenderGraphUtils.BlitMaterialParameters paraVertical = new(srcCamColor, dst, material, 0);
renderGraph.AddBlitPass(paraVertical, k_VerticalPassName);
So ‘srcCamColor’ is passed as the source, and that comes from resourceData.activeColorTexture (which I think should be the camera target texture). It certainly looks like the source and destination should be different textures. Trying to figure out what is going wrong, I changed it to to blit to and from ‘srcCamColor’ texture like this:
...
RenderGraphUtils.BlitMaterialParameters paraVertical = new(srcCamColor, srcCamColor, material, 0);
renderGraph.AddBlitPass(paraVertical, k_VerticalPassName);
As might be expected the RenderTarget now becomes ‘_CameraTargetAttachmentA’. The _BlitTexture remains ‘_BlurTexture…’ as before though. (For reference, I actually only made this change because the following change on it’s own made both passes redundant, I think, as they no longer show up in the Frame Debugger).
What really surprised me though is if I comment out the horizontal pass that follows the vertical pass:
// RenderGraphUtils.BlitMaterialParameters paraHorizontal = new(dst, srcCamColor, material, 1);
// renderGraph.AddBlitPass(paraHorizontal, k_HorizontalPassName);
Now, the _BlitTexture passed to the vertical pass is good!
So can anyone help advise what is going on here? Is the sample incorrect? Am I doing something wrong (I’ve not much expertise on the rendering side of things, really)? Or is this a bug? I’m using 6000.0.20f1 for reference. Any help greatly appreciated!
Also, if anyone has a working implementation of a renderer feature - especially one that requires an intermediate buffer like this one - that would be very helpful, as I couldn’t find much by googling.
Kind regards,
Andy
