Skip to content

Commit

Permalink
feat(model): optimize normal transformation in vertex shader
Browse files Browse the repository at this point in the history
  • Loading branch information
fallenoak committed Feb 11, 2024
1 parent 6819fcd commit bffa6a6
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/lib/model/shader/vertex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ const VERTEX_SHADER_MAIN_SKINNING = `
`;

const VERTEX_SHADER_MAIN_NORMAL = `
vec3 objectNormal = normal;
#ifdef USE_SKINNING
mat4 skinMatrix = mat4(0.0);
Expand All @@ -95,10 +93,9 @@ vec3 objectNormal = normal;
skinMatrix += skinWeight.w * boneMatW;
#endif
vec3 skinNormal = vec4(skinMatrix * vec4(objectNormal, 0.0)).xyz;
vViewNormal = normalize(skinNormal);
vViewNormal = normalize(mat3(skinMatrix) * normal);
#else
vViewNormal = normalize(normalMatrix * objectNormal);
vViewNormal = normalize(normalMatrix * normal);
#endif
`;

Expand Down

0 comments on commit bffa6a6

Please sign in to comment.