The effect is still off, but I think I have identified the problem. I added the divide by w to the uv calculations (good eye), but it still seems wrong, check out the following test (which should calculate the uv coord for the primary texel)...
Code: Select all
// view-space position
//this seems to be accurate now
float4 D = computeViewPos(inRay, geom.w);
// view-space normals
float3 N = geom.xyz;
//but this is all wrong...
float4 nuv = mul(proj, float4(D.xyz,1));
nuv.xy = ( (nuv.xy / nuv.w) + 1.0f ) / 2.0f;
nuv.y = 1-nuv.y;
return tex2D(depthMap, nuv.xy);
...which is just 5 different kinds of messed up.
Can you see anything wrong with the way im taking a view space position, and calculating a uv from it?
*onlything I can think of its that the projection matrix gets changed during a compositor render. Should I try manually passing in the main cameras projection matrix? Right now I am just doing a auto param in the material...
Code: Select all
param_named_auto proj projection_matrix