I have been running some tests in order to try and render a mesh into a custom target inside a ScriptableRenderFeature, and I’m unable to get a simple test up and running and would like to ask if anyone knows what could be wrong, or has advice to get me on the right track- at this point any suggestions help. To explain what I’ve been trying to do, I create a separate RTHandle in the same format as the camera target, as well as another one for the depth buffer, set them as active targets with ConfigureTarget() and ConfigureClear(), and then use a command buffer to draw a basic mesh with the Sprites/Unlit shader. Then I blit the texture back into the camera target. The only moment where the mesh shows up is right after the editor is done reloading scripts, and it renders for a split second. The pass is set to execute in AfterRenderingOpaques
, but I have tested different stages, like before prepass and after transparents. I have also made sure to test the mesh with a normal MeshRenderer and unlit material.
private RTHandle volumeLightTexture;
private RTHandle depthBuffer;
private Material defaultMaterial = new Material(Shader.Find("Universal Render Pipeline/Lit");
public override void Configure(CommandBuffer cmd, RenderTextureDescriptor descriptor)
{
descriptor.colorFormat = RenderTextureFormat.ARGBFloat;
descriptor.depthBufferBits = 24;
RenderingUtils.ReAllocateIfNeeded(ref volumeLightTexture, Vector2.one, descriptor, FilterMode.Bilinear, TextureWrapMode.Clamp, name: "_FullResColor");
descriptor.colorFormat = RenderTextureFormat.RFloat;
RenderingUtils.ReAllocateIfNeeded(ref depthBuffer, Vector2.one, descriptor, FilterMode.Bilinear, TextureWrapMode.Clamp, name: "_FullResDepthBuffer");
ConfigureTarget(volumeLightTexture, depthBuffer);
ConfigureClear(ClearFlag.All, Color.black);
}
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
var source = renderingData.cameraData.renderer.cameraColorTargetHandle;
LightPassBuffer = CommandBufferPool.Get("Volumetric Light Pass");
if (defaultMaterial != null)
LightPassBuffer.DrawMesh(pointLightMesh, Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one), defaultMaterial);
else
Debug.LogWarning("Material Missing");
Blit(LightPassBuffer, volumeLightTexture, source);
context.ExecuteCommandBuffer(LightPassBuffer);
CommandBufferPool.Release(LightPassBuffer);
}
If there’s anyone that can point me on the right track, it would be greatly appreciated- I’ve been racking my head for a week and nothing seems to be working.