-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bevy 0.12 panics when loading a skinned GLTF mesh with shadow-enabled directional light in WASM #10509
Comments
I think on webgl2 we had to add a workaround for the base instance index not being part of the instance index value and we had to get the base instance index into the shader via a push constant. I think the bug is something to do with that but can’t look into it right now. See instance_index.wgsl and its get_instance_index function. |
Just repro-ed with the |
It looks like Also discussion about possible workaround on discord: https://discord.com/channels/691052431525675048/743663924229963868/1174881166705315880 |
Following up: sounds like this is only broken on some platform configurations. Still broken, but so far only reproducible on linux + nvidia. |
and linux + integrated radeon graphics 👍 |
A summary of the problem:
@cwfitzgerald let us know that one way to work around this is to ensure that every shader uses the push constant. Sure enough, by adding this to #ifdef VERTEX_OUTPUT_INSTANCE_INDEX
out.instance_index = get_instance_index(vertex_no_morph.instance_index);
#endif
// Hack: adding this line ensures the push constant is always used, as get_instance_index accesses the push constant
out.position.x += f32(get_instance_index(0u)) * 0.00001;
return out;
} However, this breaks down the second a shader is used that doesn't use the push constant. Therefore it is not a "real" fix, although it does make simple examples work / any game that sticks with the built in materials + shaders. Therefore as a short term solution I think we should roll with this. One medium term-solution is to cut out the "push constant" entirely and use a uniform buffer. Given that this is what wgpu's WebGL2 push constant emulation is doing anyway, thats actually not too big of a deal. This will take a bit of engineering work to update our data flow. The long-term solution is to wait for the next wgpu release so we can use instance_index everywhere. |
This isn't actually true, we emulate them using gl uniforms which are closer to push constants than a proper buffer. If this change is made, once 0.19 comes out, it probably should be rolled back. |
Makes sense. Thanks! |
…10706) # Objective Kind of helps #10509 ## Solution Add a line to `prepass.wgsl` that ensure the `instance_index` push constant is always used on WebGL 2. This is not a full fix, as the _second_ a custom shader is used that doesn't use the push constant, the breakage will resurface. We have satisfying medium term and long term solutions. This is just a short term hack for 0.12.1 that will make more cases work. See #10509 for more details.
Moving to 0.13 as we have kind of mitigated this for 0.12.1 with #10706 |
…10706) # Objective Kind of helps #10509 ## Solution Add a line to `prepass.wgsl` that ensure the `instance_index` push constant is always used on WebGL 2. This is not a full fix, as the _second_ a custom shader is used that doesn't use the push constant, the breakage will resurface. We have satisfying medium term and long term solutions. This is just a short term hack for 0.12.1 that will make more cases work. See #10509 for more details.
Did wgpu 0.19 fix this? |
Seems like the entire mechanism for working around this was removed in #11280, and my code that previously used the workaround seems to work fine. |
Bevy version
Bevy v0.12.0
[Optional] Relevant system information
cargo --version
)I get this both when building locally and
$ uname -srvmpio Linux 6.5.9-arch2-1 #1 SMP PREEMPT_DYNAMIC Thu, 26 Oct 2023 00:52:20 +0000 x86_64 unknown unknown GNU/Linux
If your bug is rendering-related, copy the adapter info that appears when you run Bevy.
Formatted for readability:
What you did
Note that this is a minimal example. If I don't add an armature - the bug does not replicate. If I don't enable shadows on the directional lights - the bug does not replicate. I have no idea how these two are related...
Here is a repository that demonstrates the problem: https://github.com/idanarye/demonstrate-bevy-0.12-wasm-shadows-bug
What went wrong
The text was updated successfully, but these errors were encountered: