-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e29bf7c
commit 2d4ac35
Showing
18 changed files
with
269 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
crates/bevy_core_pipeline/src/tonemapping/tonemapping_shared.wgsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// from https://64.github.io/tonemapping/ | ||
// reinhard on RGB oversaturates colors | ||
fn tonemapping_reinhard(color: vec3<f32>) -> vec3<f32> { | ||
return color / (1.0 + color); | ||
} | ||
|
||
fn tonemapping_reinhard_extended(color: vec3<f32>, max_white: f32) -> vec3<f32> { | ||
let numerator = color * (1.0 + (color / vec3<f32>(max_white * max_white))); | ||
return numerator / (1.0 + color); | ||
} | ||
|
||
// luminance coefficients from Rec. 709. | ||
// https://en.wikipedia.org/wiki/Rec._709 | ||
fn tonemapping_luminance(v: vec3<f32>) -> f32 { | ||
return dot(v, vec3<f32>(0.2126, 0.7152, 0.0722)); | ||
} | ||
|
||
fn tonemapping_change_luminance(c_in: vec3<f32>, l_out: f32) -> vec3<f32> { | ||
let l_in = tonemapping_luminance(c_in); | ||
return c_in * (l_out / l_in); | ||
} | ||
|
||
fn reinhard_luminance(color: vec3<f32>) -> vec3<f32> { | ||
let l_old = tonemapping_luminance(color); | ||
let l_new = l_old / (1.0 + l_old); | ||
return tonemapping_change_luminance(color, l_new); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.