From 703800286e99eb0f42005469f2076bc4a5f32c00 Mon Sep 17 00:00:00 2001 From: walkawayy <81546780+walkawayy@users.noreply.github.com> Date: Fri, 17 Mar 2023 10:37:21 -0400 Subject: [PATCH] wip: fix vertex shader --- bin/shaders/3d.vsh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/bin/shaders/3d.vsh b/bin/shaders/3d.vsh index 5288764ce..37bf9d6b9 100644 --- a/bin/shaders/3d.vsh +++ b/bin/shaders/3d.vsh @@ -6,9 +6,9 @@ layout(location = 1) in vec3 inTexCoords; layout(location = 2) in vec4 inColor; layout(location = 3) in vec3 inNormal; -uniform mat4 transformationMatrix; -uniform mat4 matProjection; -uniform mat4 matModelView; +// uniform mat4 transformationMatrix; +uniform mat4 matProjection; // brings the vertices into clip space. +uniform mat4 matModelView; // equal to transformationMatrix in tutorial uniform vec3 cameraPosition; out vec4 vertColor; @@ -17,7 +17,8 @@ out vec3 reflectedVector; out vec3 pass_normal; void main(void) { - gl_Position = matProjection * matModelView * vec4(inPosition, 1); + vec4 worldPosition = matModelView * vec4(inPosition, 1); + // gl_Position = matProjection * ? * worldPosition; vertColor = inColor / 255.0; vertTexCoords = inTexCoords; @@ -26,7 +27,7 @@ void main(void) { vec3 unitNormal = normalize(inNormal); vec3 positionVector = vec3(matModelView * vec4(inPosition, 1)); - vec3 viewVector = normalize(positionVector - cameraPosition); + vec3 viewVector = normalize(worldPosition.xyz - cameraPosition); // vec3 viewVector = normalize(gl_Position.xyz - cameraPosition); reflectedVector = reflect(viewVector, unitNormal); }