Skip to content

Commit

Permalink
feat(shader-ast-stdlib): add ACES film tonemapping
Browse files Browse the repository at this point in the history
- update module re-exports
  • Loading branch information
postspectacular committed Aug 27, 2020
1 parent 4dfc020 commit 8a0b1a3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/shader-ast-stdlib/src/color/aces-film.ts
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)
)
)
),
]);
3 changes: 3 additions & 0 deletions packages/shader-ast-stdlib/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "./api";

export * from "./color/aces-film";
export * from "./color/linear-srgb";
export * from "./color/luminance";
export * from "./color/porter-duff";
Expand All @@ -21,6 +22,8 @@ export * from "./math/fit";
export * from "./math/magsq";
export * from "./math/maxcomp";
export * from "./math/mincomp";
export * from "./math/mix-cubic";
export * from "./math/mix-quadratic";
export * from "./math/orthogonal";
export * from "./math/polar";
export * from "./math/sincos";
Expand Down

0 comments on commit 8a0b1a3

Please sign in to comment.