Skip to content

Commit

Permalink
wip: fix vertex shader
Browse files Browse the repository at this point in the history
  • Loading branch information
walkawayy committed Mar 17, 2023
1 parent afdd4f4 commit 7038002
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions bin/shaders/3d.vsh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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);
}

0 comments on commit 7038002

Please sign in to comment.