# About Reconstruct Pixel Position From Depth?

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

## Recommended Posts

I have read some article about this topic. But i found that they all render a quad(two triangles) in final pass, perhaps, that's deferred rendering? But, i usally render all scene primitives in final pass(example SSAO pass). I want to reconstruct pixel's view space position as below. Is this correct? In application, I render all scene primitives by calling DrawIndexedPrimitive. //------------------------------------------------------------------------- In Vertex Shader, I calculate: float4 oPos_ProjSpace:TEXCOORD1 //that's vertex position in projection space. float4 oPos_ViewSpace:TEXCOORD2 //that's vertex position in view space. oPos_ProjSpace = mul(float4(iPos_ModelSpace), matWVP); oPos_ViewSpace = mul(float4(iPos_ModelSpace), matWV); //------------------------------------------------------------------------- Then, In Pixel Shader. I use oPos_ProjSpace to calcuate the Texture coordinate(Textrue is Linear Depth Render Target. Value = .z/fFarZ), and use it to sample Linear Depth Render Target to get Depth. //ProjS=>NDC=>Texcoord oPos_ProjS /= oPos_ProjS.w; float2 Texcoord = (oPos_ProjS.xy + 1.0f) * 0.5f; Texcoord.y = 1.0f - Texcoord.y; fDepth = tex2D(smpLinearDepth, Texcoord).r; I use oPos_ViewSpace and fDepth*fFarZ to combinate pixel's view space position. oPos_ViewSpace.z = fDepth*fFarZ. Then the oPos_ViewSpace is the pixel's View space position. //-------------------------------------------------------------------------- I want to know is it correct? Thanks all!

1. 1
Rutin
37
2. 2
3. 3
4. 4
5. 5

• 11
• 10
• 13
• 103
• 11
• ### Forum Statistics

• Total Topics
632976
• Total Posts
3009672
• ### Who's Online (See full list)

There are no registered users currently online

×