I think there’s an error in this section?
https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@14.0/manual/renderer-features/create-custom-renderer-feature.html#code-render-pass
Unless I misunderstand something, why would you destroy the material after every single renderpass?
Seems wasteful to create/destroy this often, and also seems incorrect since we create the material with the renderfeature, and seem to be disposing it there as well. Just looks like a bad copy-paste.
eg. here we’re mistakenly disposing in the renderpass. I think we should just be releasing the textureHandleHere.
public void Dispose()
{
#if UNITY_EDITOR
if (EditorApplication.isPlaying)
{
Object.Destroy(material);
}
else
{
Object.DestroyImmediate(material);
}
#else
Object.Destroy(material);
#endif
if (blurTextureHandle != null) blurTextureHandle.Release();
}
and again here we’re double-disposing in the renderfeature, with the exact same code. this one looks right, the above looks wrong.
protected override void Dispose(bool disposing)
{
blurRenderPass.Dispose();
#if UNITY_EDITOR
if (EditorApplication.isPlaying)
{
Destroy(material);
}
else
{
DestroyImmediate(material);
}
#else
Destroy(material);
#endif
}