I can enable the depth texture for in-game cameras using the instructions here:
However I don’t know how to enable the depth texture for the editor’s scene camera. This means I can’t see the shader I’m working on (which requires a depth texture) unless I’m running the game. Is there a way to specify that the editor camera should generate a depth texture?
From release notes.
Scene view camera renders the depth texture if you set the game view camera to render it, so the reason why you don’t see your shader might be something else.
Thanks for the info. At the moment the game camera only has a depth texture when the game is running (the code that enables it is in the Start() function). How would I go about enabling it in editor mode?
Bump with this problem too.
I have editor camera, I used Camera.main.depthTextureMode = DepthTextureMode.Depth; in OnEnable(), I use _CameraDepthTexture and the shader result is visible only in GameView Editor’s camera doesn’t render anything.
I have being trying to start\stop game simulation - no success, editor’s camera doesn’t show anything.
Similar issue here. I have a URP postprocessing render feature (using the Scene Depth node in Shader graph) that replaces the render with its depth texture. In game, it works mostly fine.
However, in scene view, it looks like this – all black and white. It stays like this even if I have an editor script to enable depth textures. (I’m guessing this is because the script given above enables depth textures on the in-game camera… but not the Scene view camera.)
Being unable to see depth texture based shaders in Scene view makes it really hard to test them!
Note: It DOES work if you switch to game view while the game isn’t running, so it’s not a Play vs Edit mode thing. It seems to be an issue with the Scene camera never rendering depth textures, or doing so improperly.