Hey,
I am trying to compute world normals using only scene depth. I am using URP so there is no normal buffer available. In my shader I have access to the scene depth so I tried computing the normals like so:
float vectorLength = 0.001;
float2 y = float2(0, vectorLength);
float2 x = float2(vectorLength,0);
float depth1 = SampleDepth(_CameraDepthTexture, sampler_ScreenTextures_linear_clamp, uv + y).r;
float depth2 = SampleDepth(_CameraDepthTexture, sampler_ScreenTextures_linear_clamp, uv + x).r;
float3 p1 = float3(y, depth1 - depth);
float3 p2 = float3(x, depth2 - depth);
float3 normal = cross(p1, p2);
normal.z = -normal.z;
return normalize(normal);
However I realized this is creating more like screenspace normal than world normal. Anyone knows how I could do that?
Thanks!