Regression - Unable to get globals.time in prepass shaders
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## Bevy version
0.12.0
## What you did
In a wgsl shader:
```c
#import bevy_pbr::prepass_bindings globals
// In vertex function:
var texture_index_offset = u32(globals.time / frame_duration_ms) % n_frames;
```
This worked in bevy 0.11.3 but since updating to 0.12 I cannot find a way to get the `globals.time` field.
From my understanding, the globals field is accessible through the `bevy_pbr::mesh_view_bindings::globals` import for non-prepass shaders, and in the `bevy_pbr::prepass_bindings::globals` version for prepass shaders.
## What went wrong
`globals.time` in a prepass shader seems to be unusable in the 0.12 bevy update, and I don't see any place it was moved to.
The code above causes this error to be produced when compiling the shader:
```
error: no definition in scope for identifier: 'bevy_pbr::prepass_bindings::globals'
┌─ cosmos/shaders/animated_prepass.wgsl:194:36
│
194 │ var texture_index_offset = u32(bevy_pbr::prepass_bindings::globals.time / frame_duration_ms) % n_frames;
│ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ unknown identifier
│
= no definition in scope for identifier: 'bevy_pbr::prepass_bindings::globals'
```
Trying to use `bevy_pbr::mesh_view_bindings::globals` instead of the prepass version will crash the game, but this also happened in 0.11.3 so isn't part of the regression.
Error for the `bevy_pbr::mesh_view_bindings::globals` crash if you are curious:
```
2023-11-20T04:18:01.201013Z INFO bevy_asset::server: Reloading cosmos/shaders/animated_prepass.wgsl because it has changed
2023-11-20T04:18:01.248607Z ERROR wgpu::backend::direct: Handling wgpu errors as fatal by default
thread 'Compute Task Pool (0)' panicked at /home/cornchip/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.17.2/src/backend/direct.rs:3056:5:
wgpu error: Validation Error
Caused by:
In Device::create_render_pipeline
note: label = `prepass_pipeline`
Error matching ShaderStages(VERTEX) shader requirements against the pipeline
Shader global ResourceBinding { group: 0, binding: 9 } is not available in the layout pipeline layout
Binding is missing from the pipeline layout
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_render::render_resource::pipeline_cache::PipelineCache::process_pipeline_queue_system`!
thread 'main' panicked at /home/cornchip/.cargo/registry/src/index.crates.io-6f17d22bba15001f/bevy_render-0.12.0/src/pipelined_rendering.rs:145:45:
called `Result::unwrap()` on an `Err` value: RecvError
```
## Additional information
All fields but the `previous_view_proj` seem to have been removed from globals in this commit: https://github.com/bevyengine/bevy/commit/a15d1526358a3e5fd0ac76339f0c23612842167b#diff-c5f333aa41ce294f11ba384a74bdde77ec460f9483391f95afee8bc2fbc092b7.
Contributor guide
Assessment
This issue has not been assessed yet.