Skip to content

Commit c4e791d

Browse files
committed
bevy_pbr: Normalize skinned normals (#6543)
# Objective - Make the many foxes not unnecessarily bright. Broken since #5666. - Fixes #6528 ## Solution - In #5666 normalisation of normals was moved from the fragment stage to the vertex stage. However, it was not added to the vertex stage for skinned normals. The many foxes are skinned and their skinned normals were not unit normals. which made them brighter. Normalising the skinned normals fixes this. --- ## Changelog - Fixed: Non-unit length skinned normals are now normalized.
1 parent 99c815f commit c4e791d

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

crates/bevy_pbr/src/render/pbr_functions.wgsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ fn apply_normal_mapping(
9191
// calculates the normal maps so there is no error introduced. Do not change this code
9292
// unless you really know what you are doing.
9393
// http://www.mikktspace.com/
94-
N = normalize(Nt.x * T + Nt.y * B + Nt.z * N);
94+
N = Nt.x * T + Nt.y * B + Nt.z * N;
9595
#endif
9696
#endif
9797
#endif
9898

99-
return N;
99+
return normalize(N);
100100
}
101101

102102
// NOTE: Correctly calculates the view vector depending on whether

crates/bevy_pbr/src/render/skinning.wgsl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ fn skin_normals(
3030
model: mat4x4<f32>,
3131
normal: vec3<f32>,
3232
) -> vec3<f32> {
33-
return inverse_transpose_3x3(mat3x3<f32>(
34-
model[0].xyz,
35-
model[1].xyz,
36-
model[2].xyz
37-
)) * normal;
33+
return normalize(
34+
inverse_transpose_3x3(
35+
mat3x3<f32>(
36+
model[0].xyz,
37+
model[1].xyz,
38+
model[2].xyz
39+
)
40+
) * normal
41+
);
3842
}

0 commit comments

Comments
 (0)