struct v2f_vertex_lit { vec2 uv; vec4 diff; vec4 spec; }; struct v2f_img { vec4 pos; vec2 uv; }; struct appdata_img { vec4 vertex; vec2 texcoord; }; uniform sampler2D _CameraDepthNormalsTexture; uniform sampler2D _MainTex; vec3 DecodeViewNormalStereo( in vec4 enc4 ); float DecodeFloatRG( in vec2 enc ); void DecodeDepthNormal( in vec4 enc, out float depth, out vec3 normal ); vec4 frag( in v2f_img i ); vec3 DecodeViewNormalStereo( in vec4 enc4 ) { float kScale = 1.77770; vec3 nn; float g; vec3 n; nn = ((enc4.xyz * vec3( (2.00000 * kScale), (2.00000 * kScale), 0.000000)) + vec3( ( -kScale ), ( -kScale ), 1.00000)); g = (2.00000 / dot( nn.xyz , nn.xyz )); n.xy = (g * nn.xy ); n.z = (g - 1.00000); return n; } float DecodeFloatRG( in vec2 enc ) { vec2 kDecodeDot = vec2( 1.00000, 0.00392157); return dot( enc, kDecodeDot); } void DecodeDepthNormal( in vec4 enc, out float depth, out vec3 normal ) { depth = DecodeFloatRG( enc.zw ); normal = DecodeViewNormalStereo( enc); } vec4 frag( in v2f_img i ) { vec4 tex; vec4 depth; float z; vec3 n; vec4 col; tex = texture2D( _MainTex, i.uv); depth = texture2D( _CameraDepthNormalsTexture, i.uv); DecodeDepthNormal( depth, z, n); col.x = z; col.y = ((n.x * 0.500000) + 0.500000); col.z = ((n.y * 0.500000) + 0.500000); col.w = tex.w ; return col; } void main() { vec4 xl_retval; v2f_img xlt_i; xlt_i.pos = vec4(0.0); xlt_i.uv = vec2( gl_TexCoord[0]); xl_retval = frag( xlt_i); gl_FragData[0] = vec4( xl_retval); }