I want to work out the distance of the depth of the waters areas inside my game? I already have the depth texture, but I want to know the gl_FragCoords.z in D3D context.. any ideas how I can achieve this?
thanks
Jack
I want to work out the distance of the depth of the waters areas inside my game? I already have the depth texture, but I want to know the gl_FragCoords.z in D3D context.. any ideas how I can achieve this?
thanks
Jack
https://docs.microsoft.com/en-us/windows/uwp/gaming/glsl-to-hlsl-reference is a good reference for OpenGL <-> D3D. SV_Position is the equivalent semantic in D3D, though it's only supported in D3D10+ (so not D3D9). It's been a while since I really played around with the values of the semantics, but it should contain the Z value as expected (it's a float4, so it's actually the XY, depth, and homogeneous W coordinate if I recall).
For SV_Position the x component is post-projection Z/W, the same value that's stored in the depth buffer. The w component is the reciprocal of post-projection W, and post-projection W is the view-space z component for perspective projections.
EDIT: sorry, I was wrong about the w component of SV_Position. It's just w, not 1/w.