Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1//! A shader that samples its emissive texture at screen space positions rather
2//! than UVs.
3//!
4//! This is used for the mirror example: `examples/3d/mirror.rs`.
6import bevy_pbr::render::{
7 forward_io::{VertexOutput, FragmentOutput},
8 pbr_bindings::emissive_texture,
9 pbr_fragment::pbr_input_from_standard_material,
10 pbr_functions::{alpha_discard, apply_pbr_lighting, main_pass_post_lighting_processing}
11};
13/// This is unused, but it's here to satisfy `ExtendedMaterial` requirements.
14/// See the comment in `ScreenSpaceTextureExtension` in `examples/3d/mirror.rs`
15/// for more information.
16struct ScreenSpaceTextureMaterial {
17 /// An unused value.
18 dummy: f32,
21@group(constants::MATERIAL_BIND_GROUP) @binding(100) var<uniform> material: ScreenSpaceTextureMaterial;
23@fragment
24fn fragment(in: VertexOutput, @builtin(front_facing) is_front: bool) -> FragmentOutput {
25 var pbr_input = pbr_input_from_standard_material(in, is_front);
27 // Use zero alpha to avoid multiplying the emissive by the view exposure.
28 pbr_input.material.emissive = vec4(
29 textureLoad(emissive_texture, vec2<i32>(floor(in.position.xy)), 0).rgb,
30 0.0
31 );
33 var out: FragmentOutput;
34 out.color = apply_pbr_lighting(pbr_input);
35 out.color = main_pass_post_lighting_processing(pbr_input, out.color);
36 return out;
Contents