From 32ebab499fc6156c4e70a6c038a2cb3587f898f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Mon, 24 Jan 2022 13:25:22 +0100 Subject: [PATCH] Shaders: reduce redundant expression in MeshVisualizer.vert. Doesn't seem to have any effect on the (slow AF) perf of the shader, so I guess the most time is spent in the GS. --- src/Magnum/Shaders/MeshVisualizer.vert | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Magnum/Shaders/MeshVisualizer.vert b/src/Magnum/Shaders/MeshVisualizer.vert index 43359b178..91f2355e7 100644 --- a/src/Magnum/Shaders/MeshVisualizer.vert +++ b/src/Magnum/Shaders/MeshVisualizer.vert @@ -343,22 +343,23 @@ void main() { #ifdef TWO_DIMENSIONS gl_Position.xywz = vec4(transformationProjectionMatrix*vec3(position, 1.0), 0.0); #elif defined(THREE_DIMENSIONS) - gl_Position = projectionMatrix*transformationMatrix*position; + highp const vec4 transformedPosition4 = transformationMatrix*position; + gl_Position = projectionMatrix*transformedPosition4; #else #error #endif #ifdef TANGENT_DIRECTION - tangentEndpoint = projectionMatrix*(transformationMatrix*position + vec4(normalize(normalMatrix*tangent.xyz)*lineLength, 0.0)); + tangentEndpoint = projectionMatrix*(transformedPosition4 + vec4(normalize(normalMatrix*tangent.xyz)*lineLength, 0.0)); #endif #ifdef BITANGENT_FROM_TANGENT_DIRECTION vec3 bitangent = cross(normal, tangent.xyz)*tangent.w; #endif #if defined(BITANGENT_DIRECTION) || defined(BITANGENT_FROM_TANGENT_DIRECTION) - bitangentEndpoint = projectionMatrix*(transformationMatrix*position + vec4(normalize(normalMatrix*bitangent)*lineLength, 0.0)); + bitangentEndpoint = projectionMatrix*(transformedPosition4 + vec4(normalize(normalMatrix*bitangent)*lineLength, 0.0)); #endif #ifdef NORMAL_DIRECTION - normalEndpoint = projectionMatrix*(transformationMatrix*position + vec4(normalize(normalMatrix*normal)*lineLength, 0.0)); + normalEndpoint = projectionMatrix*(transformedPosition4 + vec4(normalize(normalMatrix*normal)*lineLength, 0.0)); #endif #if defined(WIREFRAME_RENDERING) && defined(NO_GEOMETRY_SHADER)