Skip to content

Commit

Permalink
Remove redundant math in tonemapping. (#9669)
Browse files Browse the repository at this point in the history
# Objective

- Tony McMapface has some math that cancels out.

## Solution

- Remove it.
  • Loading branch information
DGriffin91 committed Sep 2, 2023
1 parent ea734ab commit e88b6c8
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,11 @@ fn somewhat_boring_display_transform(col: vec3<f32>) -> vec3<f32> {
// By Tomasz Stachowiak
// https://github.com/h3r2tic/tony-mc-mapface

const TONY_MC_MAPFACE_LUT_EV_RANGE = vec2<f32>(-13.0, 8.0);
const TONY_MC_MAPFACE_LUT_DIMS: f32 = 48.0;

fn tony_mc_mapface_lut_range_encode(x: vec3<f32>) -> vec3<f32> {
return x / (x + 1.0);
}

fn sample_tony_mc_mapface_lut(stimulus: vec3<f32>) -> vec3<f32> {
let range = tony_mc_mapface_lut_range_encode(exp2(TONY_MC_MAPFACE_LUT_EV_RANGE.xyy)).xy;
let normalized = (tony_mc_mapface_lut_range_encode(stimulus) - range.x) / (range.y - range.x);
var uv = saturate(normalized * (f32(TONY_MC_MAPFACE_LUT_DIMS - 1.0) / f32(TONY_MC_MAPFACE_LUT_DIMS)) + 0.5 / f32(TONY_MC_MAPFACE_LUT_DIMS));
return sample_current_lut(uv).rgb;
var uv = (stimulus / (stimulus + 1.0)) * (f32(TONY_MC_MAPFACE_LUT_DIMS - 1.0) / f32(TONY_MC_MAPFACE_LUT_DIMS)) + 0.5 / f32(TONY_MC_MAPFACE_LUT_DIMS);
return sample_current_lut(saturate(uv)).rgb;
}

// ---------------------------------
Expand Down

0 comments on commit e88b6c8

Please sign in to comment.