Extract tone mapping into function
This commit is contained in:
parent
6f6673ea1f
commit
8c97ccad18
|
|
@ -19,9 +19,13 @@ fn on_vertex(in: Vertex) -> Varying {
|
|||
|
||||
@fragment
|
||||
fn on_fragment(in: Varying) -> @location(0) vec4f {
|
||||
let hdr = textureSample(tex, smp, in.tex).xyz;
|
||||
let pixel = textureSample(tex, smp, in.tex);
|
||||
return vec4(rational_tone_map(pixel.xyz), 1.0);
|
||||
}
|
||||
|
||||
fn rational_tone_map(hdr: vec3<f32>) -> vec3<f32> {
|
||||
let luminosity = dot(hdr, vec3(0.2126, 0.7152, 0.0722));
|
||||
let color = hdr / luminosity;
|
||||
let luma = luminosity / (luminosity + 1.0);
|
||||
return vec4(luma * color, 1.0);
|
||||
return luma * color;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user