Commit ea15446
Fix binding in generated environment map downsampling pipeline (#21791)
# Objective
When Bevy splits mip generation for environment maps into two passes due
to limits, the second pass binds a view to the the original texture when
it's supposed to be the 6th mip level of an intermediate one. This
causes an error on WebGPU in browsers if that original texture doesn't
already have mipmaps.
This affects the atmosphere example on WebGPU, but there are other
issues there too so it still won't work after this.
## Solution
Create texture view from the texture in the `IntermediateTextures`
component instead of in `RenderEnvironmentMap`
## Testing
<details>
<summary>Example that doesn't work on WebGPU before this (replace
square.png with any power of 2 square image that doesn't store
mipmaps)</summary>
```rust
use bevy::prelude::*;
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.run();
}
fn setup(
mut commands: Commands,
asset_server: Res<AssetServer>,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
commands.spawn((
Camera3d::default(),
Transform::from_xyz(0.0, 0.0, 5.0),
GeneratedEnvironmentMapLight {
environment_map: asset_server.load("square.png"),
intensity: 1000.0,
..Default::default()
},
));
commands.spawn((
Mesh3d(meshes.add(Sphere::new(1.0).mesh().build())),
MeshMaterial3d(materials.add(StandardMaterial {
perceptual_roughness: 0.1,
metallic: 1.0,
..Default::default()
})),
));
}
```
</details>1 parent 48556b7 commit ea15446
1 file changed
+10
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
677 | 677 | | |
678 | 678 | | |
679 | 679 | | |
680 | | - | |
681 | | - | |
682 | | - | |
683 | | - | |
684 | | - | |
685 | | - | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
686 | 690 | | |
687 | 691 | | |
688 | 692 | | |
| |||
0 commit comments