Fix T63108 Eevee: Wrong Reflection plane matrix if camera view is not centered
authorClément Foucault <foucault.clem@gmail.com>
Thu, 4 Apr 2019 16:08:42 +0000 (18:08 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Thu, 4 Apr 2019 16:08:42 +0000 (18:08 +0200)
Invert X axis of the Window Matrix (AKA Projection matrix) instead of the
View matrix.

source/blender/draw/engines/eevee/eevee_lightprobes.c

index 90a3691f6e5002087943f67c6d277dc01322cfce..5d4601df7cf4f675502f2d72bdb7e5c8724d8573 100644 (file)
@@ -666,16 +666,17 @@ static void lightbake_planar_compute_render_matrices(
         EEVEE_PlanarReflection *eplanar, DRWMatrixState *r_matstate,
         const float viewmat[4][4], const float winmat[4][4])
 {
+       /* Temporal sampling jitter should be already applied to the DRW_MAT_WIN. */
+       copy_m4_m4(r_matstate->winmat, winmat);
+       /* Invert X to avoid flipping the triangle facing direction. */
+       r_matstate->winmat[0][0] = -r_matstate->winmat[0][0];
+       r_matstate->winmat[1][0] = -r_matstate->winmat[1][0];
+       r_matstate->winmat[2][0] = -r_matstate->winmat[2][0];
+       r_matstate->winmat[3][0] = -r_matstate->winmat[3][0];
        /* Reflect Camera Matrix. */
        mul_m4_m4m4(r_matstate->viewmat, viewmat, eplanar->mtx);
-       /* Invert X to avoid flipping the triangle facing direction. */
-       r_matstate->viewmat[0][0] = -r_matstate->viewmat[0][0];
-       r_matstate->viewmat[1][0] = -r_matstate->viewmat[1][0];
-       r_matstate->viewmat[2][0] = -r_matstate->viewmat[2][0];
-       r_matstate->viewmat[3][0] = -r_matstate->viewmat[3][0];
        /* Apply Projection Matrix. */
-       /* Temporal sampling jitter should be already applied to the DRW_MAT_WIN. */
-       mul_m4_m4m4(r_matstate->persmat, winmat, r_matstate->viewmat);
+       mul_m4_m4m4(r_matstate->persmat, r_matstate->winmat, r_matstate->viewmat);
 }
 
 static void eevee_lightprobes_extract_from_cache(EEVEE_LightProbesInfo *pinfo, LightCache *lcache)