Created
April 11, 2013 15:08
-
-
Save jimmiebergmann/5364146 to your computer and use it in GitHub Desktop.
PS3 GLSL Depth to position
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Convert to 24bit | |
| const float3 depthFactor = float3(65536.0f/16777215.0f, 256.0f/16777215.0f, 1.0f/16777215.0f ); | |
| float GetDepth( float4 raw_depth ) | |
| { | |
| return dot( round( raw_depth.xyz * 255.0f.xxx ), depthFactor.xyz); | |
| } | |
| float2 texcoord = in.vpos/g_Resolution; | |
| pos.xy = in.vpo; | |
| pos.z = GetDepth( tex2D(g_Depthmap,texcoord).rgba ); | |
| pos = 2.0*pos-1.0; | |
| float4 Clip = mul(g_MatrixInverseViewProj,float4(pos,1.0)); | |
| pos = (Clip.xyz / Clip.w); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment