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#import bevy_pbr::{
2 pbr_fragment::pbr_input_from_standard_material,
3 pbr_functions::alpha_discard,
4}
6#ifdef PREPASS_PIPELINE
7#import bevy_pbr::{
8 prepass_io::{VertexOutput, FragmentOutput},
9 pbr_deferred_functions::deferred_output,
11#else
12#import bevy_pbr::{
13 forward_io::{VertexOutput, FragmentOutput},
14 pbr_functions::{apply_pbr_lighting, main_pass_post_lighting_processing},
16#endif
18struct MyExtendedMaterial {
19 quantize_steps: u32,
22@group(2) @binding(100)
23var<uniform> my_extended_material: MyExtendedMaterial;
25@fragment
26fn fragment(
27 in: VertexOutput,
28 @builtin(front_facing) is_front: bool,
29) -> FragmentOutput {
30 // generate a PbrInput struct from the StandardMaterial bindings
31 var pbr_input = pbr_input_from_standard_material(in, is_front);
33 // we can optionally modify the input before lighting and alpha_discard is applied
34 pbr_input.material.base_color.b = pbr_input.material.base_color.r;
36 // alpha discard
37 pbr_input.material.base_color = alpha_discard(pbr_input.material, pbr_input.material.base_color);
39#ifdef PREPASS_PIPELINE
40 // in deferred mode we can't modify anything after that, as lighting is run in a separate fullscreen shader.
41 let out = deferred_output(in, pbr_input);
42#else
43 var out: FragmentOutput;
44 // apply lighting
45 out.color = apply_pbr_lighting(pbr_input);
47 // we can optionally modify the lit color before post-processing is applied
48 out.color = vec4<f32>(vec4<u32>(out.color * f32(my_extended_material.quantize_steps))) / f32(my_extended_material.quantize_steps);
50 // apply in-shader post processing (fog, alpha-premultiply, and also tonemapping, debanding if the camera is non-hdr)
51 // note this does not include fullscreen postprocessing effects like bloom.
52 out.color = main_pass_post_lighting_processing(pbr_input, out.color);
54 // we can optionally modify the final result here
55 out.color = out.color * 2.0;
56#endif
58 return out;
Contents