Skip to content

Commit 8b7ebe1

Browse files
committed
Fix post_processing and shader_prepass examples (#7419)
# Objective - Fix `post_processing` and `shader_prepass` examples as they fail when compiling shaders due to missing shader defs - Fixes #6799 - Fixes #6996 - Fixes #7375 - Supercedes #6997 - Supercedes #7380 ## Solution - The prepass was broken due to a missing `MAX_CASCADES_PER_LIGHT` shader def. Add it. - The shader used in the `post_processing` example is applied to a 2D mesh, so use the correct mesh2d_view_bindings shader import.
1 parent 937fc03 commit 8b7ebe1

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

assets/shaders/custom_material_chromatic_aberration.wgsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#import bevy_pbr::mesh_view_bindings
1+
#import bevy_sprite::mesh2d_view_bindings
22
#import bevy_pbr::utils
33

44
@group(1) @binding(0)
@@ -22,7 +22,7 @@ fn fragment(
2222
textureSample(texture, our_sampler, uv + vec2<f32>(-offset_strength, 0.0)).g,
2323
textureSample(texture, our_sampler, uv + vec2<f32>(0.0, offset_strength)).b,
2424
1.0
25-
);
25+
);
2626

2727
return output_color;
2828
}

crates/bevy_pbr/src/prepass/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ use bevy_utils::{tracing::error, HashMap};
4646
use crate::{
4747
AlphaMode, DrawMesh, Material, MaterialPipeline, MaterialPipelineKey, MeshPipeline,
4848
MeshPipelineKey, MeshUniform, RenderMaterials, SetMaterialBindGroup, SetMeshBindGroup,
49-
MAX_DIRECTIONAL_LIGHTS,
49+
MAX_CASCADES_PER_LIGHT, MAX_DIRECTIONAL_LIGHTS,
5050
};
5151

5252
use std::{hash::Hash, marker::PhantomData};
@@ -211,6 +211,10 @@ where
211211
"MAX_DIRECTIONAL_LIGHTS".to_string(),
212212
MAX_DIRECTIONAL_LIGHTS as i32,
213213
));
214+
shader_defs.push(ShaderDefVal::Int(
215+
"MAX_CASCADES_PER_LIGHT".to_string(),
216+
MAX_CASCADES_PER_LIGHT as i32,
217+
));
214218

215219
if layout.contains(Mesh::ATTRIBUTE_UV_0) {
216220
shader_defs.push("VERTEX_UVS".into());

0 commit comments

Comments
 (0)