Skip to content
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 23, 2019
1 parent 1106f6a commit ab46258c616608c53b93e8e0c0cf84ea70d59550
Showing 1 changed file with 2 additions and 2 deletions.
@@ -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 ab46258

Please sign in to comment.