glsl/builtins
vec2
(vec2 [x : cstr y : cstr] :)
build a vec2 constructor expression.
| x y -- component expression strings |
"vec2(x, y)"
(vec2 "1.0" "0.0") ; => "vec2(1.0, 0.0)"
Since: v0.1.0
vec3
(vec3 [x : cstr y : cstr z : cstr] :)
build a vec3 constructor expression.
| x y z -- component expression strings |
"vec3(x, y, z)"
(vec3 "1.0" "0.0" "0.0") ; => "vec3(1.0, 0.0, 0.0)"
Since: v0.1.0
vec4
(vec4 [x : cstr y : cstr z : cstr w : cstr] :)
build a vec4 constructor expression.
| x y z w -- component expression strings |
"vec4(x, y, z, w)"
(vec4 "pos" "1.0" "0.0" "0.0")
Since: v0.1.0
mat2
(mat2 [args : int] :)
build a mat2 constructor from a cons list of expressions.
| args | cons list of 4 component expression strings |
"mat2(c0, c1, c2, c3)"
Since: v0.1.0
mat3
(mat3 [args : int] :)
build a mat3 constructor from a cons list of expressions.
| args | cons list of 9 component expression strings |
"mat3(c0, ..., c8)"
Since: v0.1.0
mat4
(mat4 [args : int] :)
build a mat4 constructor from a cons list of expressions.
| args | cons list of 16 component expression strings |
"mat4(c0, ..., c15)"
Since: v0.1.0
dot
(dot [a : cstr b : cstr] :)
dot product.
| a b -- vector expression strings |
"dot(a, b)"
(dot "normal" "lightDir") ; => "dot(normal, lightDir)"
Since: v0.1.0
cross
(cross [a : cstr b : cstr] :)
cross product.
| a b -- vec3 expression strings |
"cross(a, b)"
Since: v0.1.0
normalize
(normalize [v : cstr] :)
normalize a vector.
| v | vector expression string |
"normalize(v)"
Since: v0.1.0
length
(length [v : cstr] :)
magnitude of a vector.
| v | vector expression string |
"length(v)"
Since: v0.1.0
distance
(distance [a : cstr b : cstr] :)
distance between two points.
| a b -- point expression strings |
"distance(a, b)"
Since: v0.1.0
reflect
(reflect [i : cstr n : cstr] :)
reflect a vector around a normal.
| i n -- incident and normal vectors |
"reflect(i, n)"
Since: v0.1.0
refract
(refract [i : cstr n : cstr eta : cstr] :)
compute refraction direction.
| i n eta -- incident, normal, and eta |
"refract(i, n, eta)"
Since: v0.1.0
mix
(mix [x : cstr y : cstr a : cstr] :)
linear interpolation.
| x y a -- start, end, blend factor |
"mix(x, y, a)"
(mix "a" "b" "0.5") ; => "mix(a, b, 0.5)"
Since: v0.1.0
clamp
(clamp [x : cstr mn : cstr mx : cstr] :)
clamp a value to a range.
| x mn mx -- value, minimum, maximum |
"clamp(x, mn, mx)"
Since: v0.1.0
smoothstep
(smoothstep [edge0 : cstr edge1 : cstr x : cstr] :)
smooth Hermite interpolation.
| edge0 edge1 x -- lower edge, upper edge, input value |
"smoothstep(edge0, edge1, x)"
Since: v0.1.0
step
(step [edge : cstr x : cstr] :)
step function.
| edge x -- threshold and input |
"step(edge, x)"
Since: v0.1.0
texture
(texture [sampler : cstr coord : cstr] :)
sample a texture.
| sampler | sampler expression string | |
| coord | texture coordinate expression string |
"texture(sampler, coord)"
(texture "diffuseMap" "TexCoord")
Since: v0.1.0
texture-lod
(texture-lod [sampler : cstr coord : cstr lod : cstr] :)
sample a texture at a specific LOD.
| sampler | sampler expression string | |
| coord | texture coordinate expression string | |
| lod | level-of-detail expression string |
"textureLod(sampler, coord, lod)"
Since: v0.1.0
swizzle
(swizzle [v : cstr components : cstr] :)
component swizzle access.
| v | vector expression string | |
| components | swizzle keyword, e.g. ":rgb", ":xy", ":x" |
"v.components" (leading ':' stripped from components).
(swizzle "color" ":rgb") ; => "color.rgb"
Since: v0.1.0
sin
(sin [x : cstr] :)
sine.
cos
(cos [x : cstr] :)
cosine.
tan
(tan [x : cstr] :)
tangent.
asin
(asin [x : cstr] :)
arc sine.
acos
(acos [x : cstr] :)
arc cosine.
atan
(atan [x : cstr] :)
arc tangent (single arg).
atan2
(atan2 [y : cstr x : cstr] :)
arc tangent (two arg: atan(y, x)).
sqrt
(sqrt [x : cstr] :)
square root.
pow
(pow [x : cstr y : cstr] :)
power function.
exp
(exp [x : cstr] :)
e raised to x.
log
(log [x : cstr] :)
natural logarithm.
exp2
(exp2 [x : cstr] :)
2 raised to x.
log2
(log2 [x : cstr] :)
base-2 logarithm.
abs
(abs [x : cstr] :)
absolute value.
min
(min [x : cstr y : cstr] :)
minimum of two values.
max
(max [x : cstr y : cstr] :)
maximum of two values.
sign
(sign [x : cstr] :)
sign of a value (-1, 0, or 1).
floor
(floor [x : cstr] :)
floor function.
ceil
(ceil [x : cstr] :)
ceiling function.
fract
(fract [x : cstr] :)
fractional part.
mod
(mod [x : cstr y : cstr] :)
modulus.
dFdx
(dFdx [x : cstr] :)
partial derivative in x.
dFdy
(dFdy [x : cstr] :)
partial derivative in y.
fwidth
(fwidth [x : cstr] :)
sum of absolute derivatives.
transpose
(transpose [m : cstr] :)
transpose a matrix.
inverse
(inverse [m : cstr] :)
invert a matrix.
determinant
(determinant [m : cstr] :)
compute matrix determinant.
glsl-call
(glsl-call [fname : cstr args : int] :)
build an arbitrary GLSL function call.
| fname | function name string | |
| args | cons list of argument expression strings |
"fname(arg0, arg1, ...)"
(glsl-call "myFunc" (cons "a" (cons "b" 0))) ; => "myFunc(a, b)"
Since: v0.1.0
Internal definitions
__call1-- helper: build a one-arg GLSL function call.__call2-- helper: build a two-arg GLSL function call.__call3-- helper: build a three-arg GLSL function call.