Render Texture Create Failed with Confusing Error Message and Inconsistent Behaviour

Not sure where to put this, sorry if this is the wrong forum. I’m getting “RenderTexture.Create failed: colorFormat & depthStencilFormat cannot both be none.” for a render texture with a Color Format of None but a set Depth Stencil Format.

8996380--1239079--Capture2.PNG
On macOS this error doesn’t seem to matter as the render texture still works fine but on Windows the render texture does not work, though this could also be because of the shaders as they do not act consistently between the platforms.

I get the same error and Unity 2022.1.24f crashes completely in my build application.

I’m getting this on 2021.3.32f
Looks like it could be related to this Unity Issue Tracker - Console outputs errors when Render Texture Color Format is set to None and Depth Stencil Format is set to anything except None

Documentation on 2021 LTS :
graphicsFormat The color format of the render texture. You can set the color format to None to achieve depth-only rendering.

Code (which actually create the same texture as in OP)
depthRT = new RenderTexture (bufferSize, bufferSize, 32, RenderTextureFormat.Depth, RenderTextureReadWrite.Linear)

Result :
RenderTexture.Create failed: colorFormat & depthStencilFormat cannot both be none.

Gotcha : why is the issue marked as duplicate without any link to the issue it duplicates ? Because right now it seems like a bug.

I got this error after adding a “Fullscreen Render Feature” in the post processing stack for my URP render data asset.

I was able to make the error disappear by disabling “Fetch Color Buffer” on the Fullscreen Render Feature, however then the color was not available to the shader anymore.

Not really a full solution, but might help someone else trying to track down this issue.

I ran into this issue in a BiRP project. I have a camera that targets a depth-only RenderTexture.

In my case, it was caused by a shader with a GrabPass. Since the grab pass does not capture depth, and my original render target doesn’t use color, Unity tries to create a RT that contains nothing!

I’m figuring out a workaround, but that’s what’s causing the error, at least.