Skip to content

Commit

Permalink
[3d] fix shading of 3D point symbols
Browse files Browse the repository at this point in the history
The vertex shader was incorrectly transforming world position and normal
vectors for phong shading. This was causing wrong appearance that was noticeable
when moving/rotating camera (e.g. specular reflection was always in the same place).
This was caused by involving view matrix (i.e. camera position and orientation)
to the vectors, but the world position and normal should be independent from camera.
  • Loading branch information
wonder-sk committed Apr 23, 2019
1 parent 1782384 commit 50692fc
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/3d/shaders/instanced.vert
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ void main()
// which all keep "w" set to 1. correctly we should use translation matrix...
vec4 offsetPos = inst * vec4(vertexPosition, 1.0) + vec4(pos, 0.0);

worldNormal = normalize(modelViewNormal * mat3(instNormal) * vertexNormal);
worldPosition = vec3(modelView * offsetPos);
worldNormal = normalize(mat3(instNormal) * vertexNormal);
worldPosition = vec3(offsetPos);

gl_Position = modelViewProjection * offsetPos;
}

0 comments on commit 50692fc

Please sign in to comment.