-
-
Notifications
You must be signed in to change notification settings - Fork 153
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): variadic sdf isec/sub/union
- Loading branch information
1 parent
9d52838
commit fbff935
Showing
3 changed files
with
18 additions
and
12 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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { FloatTerm, max } from "@thi.ng/shader-ast"; | ||
|
||
/** | ||
* Inline function. SDF shape intersection (a & b). | ||
* Inline function. Variadic SDF shape intersection (a & b) for any number of | ||
* terms (at least 1 required). | ||
* | ||
* @param a - float | ||
* @param b - float | ||
* @param a - | ||
* @param terms - | ||
*/ | ||
export const sdfIntersect = (a: FloatTerm, b: FloatTerm) => max(b, a); | ||
export const sdfIntersect = (a: FloatTerm, ...terms: FloatTerm[]) => | ||
terms.reduce((a, b) => max(a, b), a); |
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import { FloatTerm, max, neg } from "@thi.ng/shader-ast"; | ||
|
||
/** | ||
* Inline function. SDF shape subtraction (a - b). | ||
* Inline function. Variadic SDF shape subtraction (a - b) for any number of | ||
* terms (at least 1 required). | ||
* | ||
* @param a - float | ||
* @param b - float | ||
* @param a - | ||
* @param terms - | ||
*/ | ||
export const sdfSubtract = (a: FloatTerm, b: FloatTerm) => max(neg(b), a); | ||
export const sdfSubtract = (a: FloatTerm, ...terms: FloatTerm[]) => | ||
terms.reduce((a, b) => max(a, neg(b)), a); |
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