summaryrefslogtreecommitdiffhomepage
path: root/examples/shaders/resources
diff options
context:
space:
mode:
authorKarl Zylinski <[email protected]>2024-06-11 20:55:13 +0200
committerGitHub <[email protected]>2024-06-11 20:55:13 +0200
commitfffae1a975dbfff8e6c8ee37c989f5256debc90f (patch)
treea5760d83c021b42ae9f74198700b5679f73389c4 /examples/shaders/resources
parent2609211207419ceab2e00113b4a442bfdab434d3 (diff)
downloadraylib-fffae1a975dbfff8e6c8ee37c989f5256debc90f.tar.gz
raylib-fffae1a975dbfff8e6c8ee37c989f5256debc90f.zip
Fix fragPosition using wrong matrix in lighting_instancing.vs (#4056)
fragPosition was multiplied by mvp*instanceTransform, but it should only be multiplied by instanceTransform. Compare to lighting.vs, there we only use mvp for gl_Position, but matModel for the fragPosition.
Diffstat (limited to 'examples/shaders/resources')
-rw-r--r--examples/shaders/resources/shaders/glsl330/lighting_instancing.vs9
1 files changed, 3 insertions, 6 deletions
diff --git a/examples/shaders/resources/shaders/glsl330/lighting_instancing.vs b/examples/shaders/resources/shaders/glsl330/lighting_instancing.vs
index 6775a2eb..3e4da1e2 100644
--- a/examples/shaders/resources/shaders/glsl330/lighting_instancing.vs
+++ b/examples/shaders/resources/shaders/glsl330/lighting_instancing.vs
@@ -22,15 +22,12 @@ out vec3 fragNormal;
void main()
{
- // Compute MVP for current instance
- mat4 mvpi = mvp*instanceTransform;
-
// Send vertex attributes to fragment shader
- fragPosition = vec3(mvpi*vec4(vertexPosition, 1.0));
+ fragPosition = vec3(instanceTransform*vec4(vertexPosition, 1.0));
fragTexCoord = vertexTexCoord;
//fragColor = vertexColor;
fragNormal = normalize(vec3(matNormal*vec4(vertexNormal, 1.0)));
- // Calculate final vertex position
- gl_Position = mvpi*vec4(vertexPosition, 1.0);
+ // Calculate final vertex position, note that we multiply mvp by instanceTransform
+ gl_Position = mvp*instanceTransform*vec4(vertexPosition, 1.0);
}