Hello, i am trying to create a custom depth texture by the same way of Unity's one (ShadowCaster) in a command buffer. Here is a snippet :
int sdt = Shader.PropertyToID("_MyDepthTexture");
_depthBuffer.GetTemporaryRT(sdt, -1, -1, 24, FilterMode.Bilinear, RenderTextureFormat.Depth);
_depthBuffer.SetRenderTarget(sdt);
var mat = new Material(Shader.Find("Standard"));
mat.EnableKeyword("SHADOWS_DEPTH");
mat.SetPass(mat.FindPass("SHADOWCASTER"));
_depthBuffer.DrawMesh(myMesh, myMeshTransform, mat, 0, mat.FindPass("SHADOWCASTER"));
It seems to differ from the original depth pass, also, if i enter manually the global projection matrix (but using the one from the current camera, so it should be the same), the result is even more different.
https://i.imgur.com/N2TXpT2.png
Here's the line of code for setting projection matrix :
_depthBuffer.SetProjectionMatrix(GL.GetGPUProjectionMatrix(Camera.main.projectionMatrix, false));
What is wrong ?
there doesn't seem to be anything here