Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/draw/modes/shaders/common_view_lib.glsl')
-rw-r--r--source/blender/draw/modes/shaders/common_view_lib.glsl35
1 files changed, 19 insertions, 16 deletions
diff --git a/source/blender/draw/modes/shaders/common_view_lib.glsl b/source/blender/draw/modes/shaders/common_view_lib.glsl
index bdf184cb31e..99410b41ce6 100644
--- a/source/blender/draw/modes/shaders/common_view_lib.glsl
+++ b/source/blender/draw/modes/shaders/common_view_lib.glsl
@@ -14,23 +14,26 @@ layout(std140) uniform viewBlock
vec4 clipPlanes[2];
};
- /** Transform shortcuts. */
- /* Rule of thumb: Try to reuse world positions and normals because converting though viewspace
- * will always be decomposed in at least 2 matrix operation. */
+uniform mat4 ModelMatrix;
+uniform mat4 ModelMatrixInverse;
- /**
- * Some clarification:
- * Usually Normal matrix is transpose(inverse(ViewMatrix * ModelMatrix))
- *
- * But since it is slow to multiply matrices we decompose it. Decomposing
- * inversion and transposition both invert the product order leaving us with
- * the same original order:
- * transpose(ViewMatrixInverse) * transpose(ModelMatrixInverse)
- *
- * Knowing that the view matrix is orthogonal, the transpose is also the inverse.
- * Note: This is only valid because we are only using the mat3 of the ViewMatrixInverse.
- * ViewMatrix * transpose(ModelMatrixInverse)
- **/
+/** Transform shortcuts. */
+/* Rule of thumb: Try to reuse world positions and normals because converting though viewspace
+ * will always be decomposed in at least 2 matrix operation. */
+
+/**
+ * Some clarification:
+ * Usually Normal matrix is transpose(inverse(ViewMatrix * ModelMatrix))
+ *
+ * But since it is slow to multiply matrices we decompose it. Decomposing
+ * inversion and transposition both invert the product order leaving us with
+ * the same original order:
+ * transpose(ViewMatrixInverse) * transpose(ModelMatrixInverse)
+ *
+ * Knowing that the view matrix is orthogonal, the transpose is also the inverse.
+ * Note: This is only valid because we are only using the mat3 of the ViewMatrixInverse.
+ * ViewMatrix * transpose(ModelMatrixInverse)
+ **/
#define normal_object_to_view(n) (mat3(ViewMatrix) * (transpose(mat3(ModelMatrixInverse)) * n))
#define normal_object_to_world(n) (transpose(mat3(ModelMatrixInverse)) * n)
#define normal_world_to_object(n) (transpose(mat3(ModelMatrix)) * n)