Jump to content
  • Advertisement
Sign in to follow this  

Recreating Depth Value

This topic is 2808 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i am working on improving my gbuffer and rendering. currently, i recreate my position using the Inverse View Projection. this works fine. however, reading thru a tutorial, and trying to implement his method, i have run into a problem. my shades do not use D3D10_SHADER_PACK_MATRIX_ROW_MAJOR flag, which the tutorial does. so i am assuming the problem lies somewhere in that issue.

inside the shader code, are the following segments, and i am hoping someone can help me port these over so that ROW_MAJOR is not required.

Snippet One
float3 ComputePositionViewFromZ(float2 positionScreen, float viewSpaceZ) {
float2 screenSpaceRay = float2(positionScreen.x / cCameraProj._11, positionScreen.y / cCameraProj._22);

float3 positionView;
positionView.z = viewSpaceZ;
// Solve the two projection equations
positionView.xy = screenSpaceRay.xy * positionView.z;

return positionView;

Snippet Two
float viewSpaceZ = cCameraProj._43 / (zBuffer - cCameraProj._33);

Thanks much in advance

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!