Open woodroww opened 1 year ago
Still occurs on main 97eda02f421ae7f61c1f308a112c09822c3fd2b6 (0.12.0-dev)
The cause for the issue is
https://github.com/bevyengine/bevy/blob/97eda02f421ae7f61c1f308a112c09822c3fd2b6/crates/bevy_pbr/src/prepass/mod.rs#L532-L535 in the prepass descriptor.fragment
can be None
, leading to that panic in CustomMaterial::specialize
when the shadows are enabled.
There are 2 pairs of vertex and fragment shaders in Material
, the non-prepass and prepass. specialize
takes in a RenderPipelineDescriptor
which just takes 1 pair. If it's being called in prepass/mod.rs
for specifying the prepass shaders, then the functionality overlaps with specifying the non-prepass shaders. Like the comment says at L534, it's a potential issue. In the case that the prepass doesn't use a fragment shader, then specialize
breaks.
In most cases the specializing should affect both pairs equally, but perhaps it'd be ideal if there was a way of distinguishing when the call is for the prepass shaders.
Like using
// Might not work for all prepass configurations.
const PREPASS: MeshPipelineKey = MeshPipelineKey::DEPTH_PREPASS
.union(MeshPipelineKey::NORMAL_PREPASS)
.union(MeshPipelineKey::MOTION_VECTOR_PREPASS);
let is_prepass = !(key.mesh_key & PREPASS).is_empty();
if !is_prepass {
descriptor.vertex.entry_point = "main".into();
descriptor.fragment.as_mut().unwrap().entry_point = "main".into();
}
as this stops the example from panicking for me.
Maybe even add PREPASS
to MeshPipelineKey
Bevy version
0.10.0
[Optional] Relevant system information
cargo 1.68.0 (115f34552 2023-02-26)
the operating system
This crashed on two systems, they are both Intel mac machines, one macos, one linux.
MacOS 13.2.1
Linux 20.04 Ubuntu
I tried testing the examples of upstream dependency
wgpu
for rendering problemsWhat you did
I copied the example exactly from: bevy/examples/shader/shader_material_glsl.rs and added a PointLightBundle with shadows_enabled and crash.
It also does not work with DirectionalLightBundle or SpotLightBundle with the shadows_enabled on the inner light.
This is my repository
Crashes:
Runs:
What went wrong
App crashes. The fragment shader is None in the specialize function (main.rs line 113).
Additional information
I searched around issues and doc.rs for a while, but found nothing.
Logs
on MacOS
on Linux