bevy/assets/shaders/custom_material_screenspace_texture.wgsl
Jakob Hellermann 3ffa655cdd examples: add screenspace texture shader example (#4063)
Adds a new shader example showing how to sample a texture with screenspace coordinates, similar to the end [portal in minecraft](https://bugs.mojang.com/secure/attachment/163759/portal_frame_112.gif).

https://user-images.githubusercontent.com/22177966/156031195-33d14ed8-733f-4d9e-b1da-0fc807c994a5.mp4

I just used the already existent `models/FlightHelmet/FlightHelmet_Materials_LensesMat_OcclusionRoughMetal.png` texture but maybe we should use a dedicated texture for the example. Suggestions welcome.

Co-authored-by: Carter Anderson <mcanders1@gmail.com>
2022-02-28 22:55:14 +00:00

13 lines
401 B
WebGPU Shading Language

#import bevy_pbr::mesh_view_bind_group
[[group(1), binding(0)]]
var texture: texture_2d<f32>;
[[group(1), binding(1)]]
var texture_sampler: sampler;
[[stage(fragment)]]
fn fragment([[builtin(position)]] position: vec4<f32>) -> [[location(0)]] vec4<f32> {
let uv = position.xy / vec2<f32>(view.width, view.height);
let color = textureSample(texture, texture_sampler, uv);
return color;
}