Hi,
I’m trying to port some effects from Cinematic Image Effects. I’ve successfully ported Tonemapping Color Grading, but i’m struggling with Ambient Occlusion. I’ve correctly modified uv coordinates, using UnityStereoScreenSpaceUVAdjust and UnityStereoTransformScreenSpaceTex. I have ambient occlusion kind of working, but there is a some artifacts, which are eye dependant. So one eye is different from the other, resulting in eye strain. Here is some pictures illustrating the problem :
What it looks without single pass stereo :
With single pass stereo (the pillar should not be grey) :
The same view, with the camera turned a little bit (the pillar’s left face is now white) :
Theses artifacts are view dependant, and different for each eye. I included the shader in attached files.
I think the problem comes froms this part :
// Parameters used in coordinate conversion
float3x3 proj = (float3x3)unity_CameraProjection;
float2 p11_22 = float2(unity_CameraProjection._11, unity_CameraProjection._22);
float2 p13_31 = float2(unity_CameraProjection._13, unity_CameraProjection._23);
// View space normal and depth
float3 norm_o;
float depth_o = SampleDepthNormal(uv, norm_o);
#if _SOURCE_DEPTHNORMALS
// Offset the depth value to avoid precision error.
// (depth in the DepthNormals mode has only 16-bit precision)
depth_o -= _ProjectionParams.z / 65536;
#endif
// Reconstruct the view-space position.
float3 vpos_o = ReconstructViewPos(uv, depth_o, p11_22, p13_31);
The view space calculated is wrong, leading to these artifacts. What cause this can be the projection matrix used (is it the same for both eyes ?), or an incorrect uv, due to sampling a 2-in-1 texture.
In the first case, a different matrix for each eye would be needed (i don’t know how), and in the second case, we would have to correct uv coordinates (but how, it should be corrected). So how can i resolve this ?
Thanks for your help.
2719387–193015–AmbientOcclusion.shader (15.2 KB)