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#define TONEMAPPING_PASS
3#import bevy_render::{
4 view::View,
5 maths::powsafe,
6}
7#import bevy_core_pipeline::{
8 fullscreen_vertex_shader::FullscreenVertexOutput,
9 tonemapping::{tone_mapping, screen_space_dither},
12@group(0) @binding(0) var<uniform> view: View;
14@group(0) @binding(1) var hdr_texture: texture_2d<f32>;
15@group(0) @binding(2) var hdr_sampler: sampler;
16@group(0) @binding(3) var dt_lut_texture: texture_3d<f32>;
17@group(0) @binding(4) var dt_lut_sampler: sampler;
19@fragment
20fn fragment(in: FullscreenVertexOutput) -> @location(0) vec4<f32> {
21 let hdr_color = textureSample(hdr_texture, hdr_sampler, in.uv);
23 var output_rgb = tone_mapping(hdr_color, view.color_grading).rgb;
25#ifdef DEBAND_DITHER
26 output_rgb = powsafe(output_rgb.rgb, 1.0 / 2.2);
27 output_rgb = output_rgb + screen_space_dither(in.position.xy);
28 // This conversion back to linear space is required because our output texture format is
29 // SRGB; the GPU will assume our output is linear and will apply an SRGB conversion.
30 output_rgb = powsafe(output_rgb.rgb, 2.2);
31#endif
33 return vec4<f32>(output_rgb, hdr_color.a);
Contents