mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
594074149d
# Objective Fix the screenspace_texture example not working on the WebGPU examples page. Currently it fails with the following error in the browser console: ``` 1 error(s) generated while compiling the shader: :213:9 error: redeclaration of 'uv' let uv = coords_to_viewport_uv(position.xy, view.viewport); ^^ :211:14 note: 'uv' previously declared here @location(2) uv: vec2<f32>, ``` ## Solution Rename the shader variable `uv` to `viewport_uv` to prevent variable redeclaration error.
17 lines
468 B
WebGPU Shading Language
17 lines
468 B
WebGPU Shading Language
#import bevy_pbr::mesh_view_bindings
|
|
#import bevy_pbr::utils
|
|
|
|
@group(1) @binding(0)
|
|
var texture: texture_2d<f32>;
|
|
@group(1) @binding(1)
|
|
var texture_sampler: sampler;
|
|
|
|
@fragment
|
|
fn fragment(
|
|
@builtin(position) position: vec4<f32>,
|
|
#import bevy_pbr::mesh_vertex_output
|
|
) -> @location(0) vec4<f32> {
|
|
let viewport_uv = coords_to_viewport_uv(position.xy, view.viewport);
|
|
let color = textureSample(texture, texture_sampler, viewport_uv);
|
|
return color;
|
|
}
|