Skip to content

Commit 889a5fb

Browse files
authored
Fix morph target prepass shader (#9013)
# Objective Since 10f5c92, shadows were broken for models with morph target. When #5703 was merged, the morph target code in `render/mesh.wgsl` was correctly updated to use the new import syntax. However, similar code exists in `prepass/prepass.wgsl`, but it was never update. (the reason code is duplicated is that the `Vertex` struct is different for both files). ## Solution Update the code, so that shadows render correctly with morph targets.
1 parent 94291cf commit 889a5fb

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

crates/bevy_pbr/src/prepass/prepass.wgsl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,18 +57,18 @@ struct VertexOutput {
5757
#ifdef MORPH_TARGETS
5858
fn morph_vertex(vertex_in: Vertex) -> Vertex {
5959
var vertex = vertex_in;
60-
let weight_count = layer_count();
60+
let weight_count = bevy_pbr::morph::layer_count();
6161
for (var i: u32 = 0u; i < weight_count; i ++) {
62-
let weight = weight_at(i);
62+
let weight = bevy_pbr::morph::weight_at(i);
6363
if weight == 0.0 {
6464
continue;
6565
}
66-
vertex.position += weight * morph(vertex.index, position_offset, i);
66+
vertex.position += weight * bevy_pbr::morph::morph(vertex.index, bevy_pbr::morph::position_offset, i);
6767
#ifdef VERTEX_NORMALS
68-
vertex.normal += weight * morph(vertex.index, normal_offset, i);
68+
vertex.normal += weight * bevy_pbr::morph::morph(vertex.index, bevy_pbr::morph::normal_offset, i);
6969
#endif
7070
#ifdef VERTEX_TANGENTS
71-
vertex.tangent += vec4(weight * morph(vertex.index, tangent_offset, i), 0.0);
71+
vertex.tangent += vec4(weight * bevy_pbr::morph::morph(vertex.index, bevy_pbr::morph::tangent_offset, i), 0.0);
7272
#endif
7373
}
7474
return vertex;

0 commit comments

Comments
 (0)