Skip to content
Permalink
Browse files

[3d] fix shading of 3D point symbols

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 22, 2019
1 parent 1782384 commit 50692fc60e5abf860c7c1685944c8b369dd79b94
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/3d/shaders/instanced.vert
@@ -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.
You can’t perform that action at this time.