Skip to content

Commit 6703bb6

Browse files
Fixed the way Utilities.GetViewProjectionMatrix works when given the LookAt parameters so that it matches the camera.worldToCameraMatrix APIs (fixed skybox temporary Cubemap from being flipped)
1 parent 7860f21 commit 6703bb6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Assets/ScriptableRenderLoop/HDRenderLoop/Utilities.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,19 @@ public static Matrix4x4 GetViewProjectionMatrix(Matrix4x4 worldToViewMatrix, Mat
165165
// The actual projection matrix used in shaders is actually massaged a bit to work across all platforms
166166
// (different Z value ranges etc.)
167167
var gpuProj = GL.GetGPUProjectionMatrix(projectionMatrix, false);
168-
var gpuVP = gpuProj * worldToViewMatrix;
168+
var gpuVP = gpuProj * worldToViewMatrix * Matrix4x4.Scale(new Vector3(1.0f, 1.0f, -1.0f)); // Need to scale -1.0 on Z to match what is being done in the camera.wolrdToCameraMatrix API.
169169

170170
return gpuVP;
171171
}
172172

173173
public static Matrix4x4 GetViewProjectionMatrix(Camera camera)
174174
{
175-
return GetViewProjectionMatrix(camera.worldToCameraMatrix, camera.projectionMatrix);
175+
// The actual projection matrix used in shaders is actually massaged a bit to work across all platforms
176+
// (different Z value ranges etc.)
177+
var gpuProj = GL.GetGPUProjectionMatrix(camera.projectionMatrix, false);
178+
var gpuVP = gpuProj * camera.worldToCameraMatrix;
179+
180+
return gpuVP;
176181
}
177182

178183
public static Vector4 ComputeScreenSize(Camera camera)

0 commit comments

Comments
 (0)