Handle vertex_uvs if they are present in default prepass fragment shader (#8330)
# Objective - Enabling AlphaMode::Opaque in the shader_prepass example crashes. The issue seems to be that enabling opaque also generates vertex_uvs Fixes https://github.com/bevyengine/bevy/issues/8273 ## Solution - Use the vertex_uvs in the shader if they are present
This commit is contained in:
parent
4580a91171
commit
3f6367d584
@ -84,6 +84,10 @@ fn vertex(vertex: Vertex) -> VertexOutput {
|
|||||||
|
|
||||||
#ifdef PREPASS_FRAGMENT
|
#ifdef PREPASS_FRAGMENT
|
||||||
struct FragmentInput {
|
struct FragmentInput {
|
||||||
|
#ifdef VERTEX_UVS
|
||||||
|
@location(0) uv: vec2<f32>,
|
||||||
|
#endif // VERTEX_UVS
|
||||||
|
|
||||||
#ifdef NORMAL_PREPASS
|
#ifdef NORMAL_PREPASS
|
||||||
@location(1) world_normal: vec3<f32>,
|
@location(1) world_normal: vec3<f32>,
|
||||||
#endif // NORMAL_PREPASS
|
#endif // NORMAL_PREPASS
|
||||||
|
@ -63,7 +63,8 @@ fn setup(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// A quad that shows the outputs of the prepass
|
// A quad that shows the outputs of the prepass
|
||||||
// To make it easy, we just draw a big quad right in front of the camera. For a real application, this isn't ideal.
|
// To make it easy, we just draw a big quad right in front of the camera.
|
||||||
|
// For a real application, this isn't ideal.
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
MaterialMeshBundle {
|
MaterialMeshBundle {
|
||||||
mesh: meshes.add(shape::Quad::new(Vec2::new(20.0, 20.0)).into()),
|
mesh: meshes.add(shape::Quad::new(Vec2::new(20.0, 20.0)).into()),
|
||||||
@ -77,11 +78,15 @@ fn setup(
|
|||||||
NotShadowCaster,
|
NotShadowCaster,
|
||||||
));
|
));
|
||||||
|
|
||||||
// Opaque cube using the StandardMaterial
|
// Opaque cube
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
PbrBundle {
|
MaterialMeshBundle {
|
||||||
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
|
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
|
||||||
material: std_materials.add(Color::rgb(0.8, 0.7, 0.6).into()),
|
material: materials.add(CustomMaterial {
|
||||||
|
color: Color::WHITE,
|
||||||
|
color_texture: Some(asset_server.load("branding/icon.png")),
|
||||||
|
alpha_mode: AlphaMode::Opaque,
|
||||||
|
}),
|
||||||
transform: Transform::from_xyz(-1.0, 0.5, 0.0),
|
transform: Transform::from_xyz(-1.0, 0.5, 0.0),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
@ -96,7 +101,6 @@ fn setup(
|
|||||||
base_color_texture: Some(asset_server.load("branding/icon.png")),
|
base_color_texture: Some(asset_server.load("branding/icon.png")),
|
||||||
..default()
|
..default()
|
||||||
}),
|
}),
|
||||||
|
|
||||||
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
transform: Transform::from_xyz(0.0, 0.5, 0.0),
|
||||||
..default()
|
..default()
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user