glsl/builtins
vec2
(vec2 [x :cstr y :cstr] :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] :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] :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] :cstr)
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] :cstr)
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] :cstr)
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] :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] :cstr)
cross product.
| a b -- vec3 expression strings |
"cross(a, b)"
Since: v0.1.0
normalize
(normalize [v :cstr] :cstr)
normalize a vector.
| v | vector expression string |
"normalize(v)"
Since: v0.1.0
length
(length [v :cstr] :cstr)
magnitude of a vector.
| v | vector expression string |
"length(v)"
Since: v0.1.0
distance
(distance [a :cstr b :cstr] :cstr)
distance between two points.
| a b -- point expression strings |
"distance(a, b)"
Since: v0.1.0
reflect
(reflect [i :cstr n :cstr] :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] :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] :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] :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] :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] :cstr)
step function.
| edge x -- threshold and input |
"step(edge, x)"
Since: v0.1.0
texture
(texture [sampler :cstr coord :cstr] :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] :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] :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] :cstr)
sine.
cos
(cos [x :cstr] :cstr)
cosine.
tan
(tan [x :cstr] :cstr)
tangent.
asin
(asin [x :cstr] :cstr)
arc sine.
acos
(acos [x :cstr] :cstr)
arc cosine.
atan
(atan [x :cstr] :cstr)
arc tangent (single arg).
atan2
(atan2 [y :cstr x :cstr] :cstr)
arc tangent (two arg: atan(y, x)).
sqrt
(sqrt [x :cstr] :cstr)
square root.
pow
(pow [x :cstr y :cstr] :cstr)
power function.
exp
(exp [x :cstr] :cstr)
e raised to x.
log
(log [x :cstr] :cstr)
natural logarithm.
exp2
(exp2 [x :cstr] :cstr)
2 raised to x.
log2
(log2 [x :cstr] :cstr)
base-2 logarithm.
abs
(abs [x :cstr] :cstr)
absolute value.
min
(min [x :cstr y :cstr] :cstr)
minimum of two values.
max
(max [x :cstr y :cstr] :cstr)
maximum of two values.
sign
(sign [x :cstr] :cstr)
sign of a value (-1, 0, or 1).
floor
(floor [x :cstr] :cstr)
floor function.
ceil
(ceil [x :cstr] :cstr)
ceiling function.
fract
(fract [x :cstr] :cstr)
fractional part.
mod
(mod [x :cstr y :cstr] :cstr)
modulus.
dFdx
(dFdx [x :cstr] :cstr)
partial derivative in x.
dFdy
(dFdy [x :cstr] :cstr)
partial derivative in y.
fwidth
(fwidth [x :cstr] :cstr)
sum of absolute derivatives.
transpose
(transpose [m :cstr] :cstr)
transpose a matrix.
inverse
(inverse [m :cstr] :cstr)
invert a matrix.
determinant
(determinant [m :cstr] :cstr)
compute matrix determinant.
glsl-call
(glsl-call [fname :cstr args :int] :cstr)
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.