I have rendered viewport and depth texture:
I try
void PS()
{
vec4 depthInput = texture2D(sDepthBuffer, vTexCoord);
#ifdef HWDEPTH
float depth = ReconstructDepth(depthInput.r);
#else
float depth = DecodeDepth(depthInput.rgb);
#endif
vec4 H = vec4(vTexCoord.x * 2 - 1, vTexCoord.y * 2 - 1, depth, 1);
vec4 D = H * cViewProjInv;
vec4 worldPos = D / D.w;
// TEST - TRANSFORM BACK
vec4 clipPos = worldPos * cViewProj;
vec2 textureCoord = vec2(clipPos.x / clipPos.w * 0.5 + 0.5, clipPos.y / clipPos.w * 0.5 + 0.5);
gl_FragColor = vec4(texture2D(sDiffMap, textureCoord).rgb, 1);
}
but it does not works. What is wrong?
Matrix4 viewProj = camera.projection * camera.view;
renderPath.shaderParameters["ViewProjInv"] = Variant(viewProj.Inverse());
renderPath.shaderParameters["ViewProj"] = Variant(viewProj);