Skip to content

Commit

Permalink
Fix: Tcmask point lighting normals
Browse files Browse the repository at this point in the history
Co-Authored-By: vlj <[email protected]>
  • Loading branch information
past-due and vlj committed Jan 27, 2024
1 parent 65dca8a commit 9ec1d56
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion data/base/shaders/tcmask_instanced.frag
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,9 @@ void main()
0., 1., 0.,
0., 0., 1.
);
light += iterateOverAllPointLights(clipSpaceCoord, fragPos, -N, normalize(halfVec - lightDir), diffuse, specularMapValue, identityMat);
// Normals are in view space, we need to get back to world space
vec3 worldSpaceNormal = -(inverse(ViewMatrix) * vec4(N, 0.f)).xyz;
light += iterateOverAllPointLights(clipSpaceCoord, fragPos, worldSpaceNormal, normalize(halfVec - lightDir), diffuse, specularMapValue, identityMat);
#endif

light.rgb *= visibility;
Expand Down
4 changes: 3 additions & 1 deletion data/base/shaders/vk/tcmask_instanced.frag
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,9 @@ void main()
0., 1., 0.,
0., 0., 1.
);
light += iterateOverAllPointLights(clipSpaceCoord, fragPos, -N, normalize(halfVec - lightDir), diffuse, specularMapValue, identityMat);
// Normals are in view space, we need to get back to world space
vec3 worldSpaceNormal = -(inverse(ViewMatrix) * vec4(N, 0.f)).xyz;
light += iterateOverAllPointLights(clipSpaceCoord, fragPos, worldSpaceNormal, normalize(halfVec - lightDir), diffuse, specularMapValue, identityMat);
}

light.rgb *= visibility;
Expand Down

0 comments on commit 9ec1d56

Please sign in to comment.