mirror of
https://github.com/bevyengine/bevy
synced 2024-11-22 12:43:34 +00:00
Separate PBR and tone mapping into 2 functions (#5078)
# Objective - Allow custom shaders to reuse the HDR results of PBR. ## Solution - Separate `pbr()` and `tone_mapping()` into 2 functions in `pbr_functions.wgsl`.
This commit is contained in:
parent
fa56a5cd51
commit
92eec47b99
2 changed files with 7 additions and 4 deletions
|
@ -85,7 +85,7 @@ fn fragment(in: FragmentInput) -> [[location(0)]] vec4<f32> {
|
|||
);
|
||||
pbr_input.V = calculate_view(in.world_position, pbr_input.is_orthographic);
|
||||
|
||||
output_color = pbr(pbr_input);
|
||||
output_color = tone_mapping(pbr(pbr_input));
|
||||
}
|
||||
|
||||
return output_color;
|
||||
|
|
|
@ -186,11 +186,14 @@ fn pbr(
|
|||
cluster_index,
|
||||
);
|
||||
|
||||
return output_color;
|
||||
}
|
||||
|
||||
fn tone_mapping(in: vec4<f32>) -> vec4<f32> {
|
||||
// tone_mapping
|
||||
output_color = vec4<f32>(reinhard_luminance(output_color.rgb), output_color.a);
|
||||
return vec4<f32>(reinhard_luminance(in.rgb), in.a);
|
||||
|
||||
// Gamma correction.
|
||||
// Not needed with sRGB buffer
|
||||
// output_color.rgb = pow(output_color.rgb, vec3(1.0 / 2.2));
|
||||
|
||||
return output_color;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue