How to Get Screen’s DepthBuffer and Set it as A RenderTexture’s DepthBuffer?
I’d just make your main camera the parent of another camera with the same settings with this script on it to render the depth to a RenderTexture. You could also render from your main camera to a RenderTexture and then set the RenderTexture target to null once per frame but I feel like this is a much simpler solution.
using UnityEngine;
using System.Collections;
public class RenderDepthTexture : MonoBehaviour {
private Camera camera;
// Use this for initialization
void Start () {
camera = GetComponent<Camera> ();
camera.depthTextureMode = DepthTextureMode.Depth;
}
}
int myRT = Shader.PropertyToID("myRT");
mytestcb.GetTemporaryRT(myRT, -1, -1);
mytestcb.SetRenderTarget(myRT, BuiltinRenderTextureType.Depth);
Warning:
CommandBuffer: built-in render texture type 3 not found while executing mytestcb (SetRenderTarget depth buffer)
What’s the Warning Message Meaning.How to resolve it.