-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(shader-ast-stdlib): add ACES film tonemapping
- update module re-exports
- Loading branch information
1 parent
4dfc020
commit 8a0b1a3
Showing
2 changed files
with
24 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { add, defn, div, mul, ret } from "@thi.ng/shader-ast"; | ||
import { clamp01 } from "../math/clamp"; | ||
|
||
/** | ||
* Filmic HDR -> LDR mapping based on ACES. | ||
* | ||
* Reference: | ||
* https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/ | ||
* | ||
* @param col | ||
*/ | ||
export const ACESFilm = defn("vec3", "ACESFilm", ["vec3"], (col) => [ | ||
ret( | ||
clamp01( | ||
div( | ||
mul(col, add(mul(col, 2.51), 0.03)), | ||
add(mul(col, add(mul(col, 2.43), 0.59)), 0.14) | ||
) | ||
) | ||
), | ||
]); |
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