Having looked around at various similar topics, they mostly seem to point to needing a shader that “samples” the _CameraDepthTexture in order to achieve this. This does not seem to be the case for HDRP though as trying to do so in ShaderGraph results in error. I know barely anything but the pure basics of shaders and have only played around a little in ShaderGraph so I would like some clear pointers here.
Will I even need a specific shader for this? I would prefer if I could just use some C# code such as this coroutine that can take regular screenshots from my singular camera.
private IEnumerator CoroutineTakeScreenshot()
{
yield return new WaitForEndOfFrame();
int width = Screen.width;
int height = Screen.height;
Debug.Log("width = " + width + ", height = " + height);
Texture2D renderResult = new Texture2D(width, height, TextureFormat.ARGB32, false);
renderResult.ReadPixels(new Rect(0, 0, width, height), 0, 0);
byte[] byteArray = renderResult.EncodeToPNG();
System.IO.File.WriteAllBytes(Application.dataPath + "/Output/Screenshot.png", byteArray);
}
I also noticed this very recent topic and tried to add the shader that edvart-ros provided but it seemed to do nothing and gave errors in visual studio. Though I am not even sure it should have done something similar even so.
TLDR: How-to screenshot the depth texture of the camera? Some help would be appreciated.