Skip to content

Commit ab46258

Browse files
committed
[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.
1 parent 1106f6a commit ab46258

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/3d/shaders/instanced.vert

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ void main()
2121
// which all keep "w" set to 1. correctly we should use translation matrix...
2222
vec4 offsetPos = inst * vec4(vertexPosition, 1.0) + vec4(pos, 0.0);
2323

24-
worldNormal = normalize(modelViewNormal * mat3(instNormal) * vertexNormal);
25-
worldPosition = vec3(modelView * offsetPos);
24+
worldNormal = normalize(mat3(instNormal) * vertexNormal);
25+
worldPosition = vec3(offsetPos);
2626

2727
gl_Position = modelViewProjection * offsetPos;
2828
}

0 commit comments

Comments
 (0)