No matching definitions.

glsl/builtins

src/glsl/builtins.tur
defn

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

defn

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

defn

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

defn

mat2

(mat2 [args : int] :)

build a mat2 constructor from a cons list of expressions.

argscons list of 4 component expression strings

"mat2(c0, c1, c2, c3)"

Since: v0.1.0

defn

mat3

(mat3 [args : int] :)

build a mat3 constructor from a cons list of expressions.

argscons list of 9 component expression strings

"mat3(c0, ..., c8)"

Since: v0.1.0

defn

mat4

(mat4 [args : int] :)

build a mat4 constructor from a cons list of expressions.

argscons list of 16 component expression strings

"mat4(c0, ..., c15)"

Since: v0.1.0

defn

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

defn

cross

(cross [a : cstr b : cstr] :)

cross product.

a b -- vec3 expression strings

"cross(a, b)"

Since: v0.1.0

defn

normalize

(normalize [v : cstr] :)

normalize a vector.

vvector expression string

"normalize(v)"

Since: v0.1.0

defn

length

(length [v : cstr] :)

magnitude of a vector.

vvector expression string

"length(v)"

Since: v0.1.0

defn

distance

(distance [a : cstr b : cstr] :)

distance between two points.

a b -- point expression strings

"distance(a, b)"

Since: v0.1.0

defn

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

defn

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

defn

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

defn

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

defn

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

defn

step

(step [edge : cstr x : cstr] :)

step function.

edge x -- threshold and input

"step(edge, x)"

Since: v0.1.0

defn

texture

(texture [sampler : cstr coord : cstr] :)

sample a texture.

samplersampler expression string
coordtexture coordinate expression string

"texture(sampler, coord)"

(texture "diffuseMap" "TexCoord")

Since: v0.1.0

defn

texture-lod

(texture-lod [sampler : cstr coord : cstr lod : cstr] :)

sample a texture at a specific LOD.

samplersampler expression string
coordtexture coordinate expression string
lodlevel-of-detail expression string

"textureLod(sampler, coord, lod)"

Since: v0.1.0

defn

swizzle

(swizzle [v : cstr components : cstr] :)

component swizzle access.

vvector expression string
componentsswizzle keyword, e.g. ":rgb", ":xy", ":x"

"v.components" (leading ':' stripped from components).

(swizzle "color" ":rgb")  ; => "color.rgb"

Since: v0.1.0

defn

sin

(sin [x : cstr] :)

sine.

defn

cos

(cos [x : cstr] :)

cosine.

defn

tan

(tan [x : cstr] :)

tangent.

defn

asin

(asin [x : cstr] :)

arc sine.

defn

acos

(acos [x : cstr] :)

arc cosine.

defn

atan

(atan [x : cstr] :)

arc tangent (single arg).

defn

atan2

(atan2 [y : cstr x : cstr] :)

arc tangent (two arg: atan(y, x)).

defn

sqrt

(sqrt [x : cstr] :)

square root.

defn

pow

(pow [x : cstr y : cstr] :)

power function.

defn

exp

(exp [x : cstr] :)

e raised to x.

defn

log

(log [x : cstr] :)

natural logarithm.

defn

exp2

(exp2 [x : cstr] :)

2 raised to x.

defn

log2

(log2 [x : cstr] :)

base-2 logarithm.

defn

abs

(abs [x : cstr] :)

absolute value.

defn

min

(min [x : cstr y : cstr] :)

minimum of two values.

defn

max

(max [x : cstr y : cstr] :)

maximum of two values.

defn

sign

(sign [x : cstr] :)

sign of a value (-1, 0, or 1).

defn

floor

(floor [x : cstr] :)

floor function.

defn

ceil

(ceil [x : cstr] :)

ceiling function.

defn

fract

(fract [x : cstr] :)

fractional part.

defn

mod

(mod [x : cstr y : cstr] :)

modulus.

defn

dFdx

(dFdx [x : cstr] :)

partial derivative in x.

defn

dFdy

(dFdy [x : cstr] :)

partial derivative in y.

defn

fwidth

(fwidth [x : cstr] :)

sum of absolute derivatives.

defn

transpose

(transpose [m : cstr] :)

transpose a matrix.

defn

inverse

(inverse [m : cstr] :)

invert a matrix.

defn

determinant

(determinant [m : cstr] :)

compute matrix determinant.

defn

glsl-call

(glsl-call [fname : cstr args : int] :)

build an arbitrary GLSL function call.

fnamefunction name string
argscons 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.