- Home /
Question by
Sinterklaas · May 13, 2021 at 01:35 PM ·
renderingrendertexturedepthclear
CommandBuffer.ClearRenderTarget(true, false, Color.clear, 1f) produces black depth texture?
I've created a render texture and associated command buffer using:
depthTex = new RenderTexture(Camera.main.pixelWidth, Camera.main.pixelHeight, 16,
RenderTextureFormat.Depth);
commandBuffer = new CommandBuffer();
Camera.main.AddCommandBuffer(CameraEvent.AfterDepthTexture, commandBuffer);
I then attempt to clear the depth texture with:
commandBuffer.Clear();
commandBuffer.SetRenderTarget(BuiltinRenderTextureType.CameraTarget, depthTex);
commandBuffer.ClearRenderTarget(true, false, Color.clear, 1f)
This produces a fully black texture, instead of the expected red. Even more strangely, I can render to this texture using a shader that writes to SV_DEPTH, but clearing does not seem to work properly.
Is this a bug, or am I doing something wrong?
Comment
Your answer
Follow this Question
Related Questions
Complex Depth Shader 0 Answers
Set depth buffer for z test on mobile platform 0 Answers
Multiple RenderTexture and depth buffer 1 Answer
How do I get the raw pixels of a RFloat RenderTexture on the CPU? 5 Answers
How can I force FPS per camera? 1 Answer