returns a rotation matrix corresponding to, in order, a rotation about the x-axis with 'r.x' radians, a rotation about the y-axis with 'r.y' radians, a rotation about the z-axis with 'r.z' radians, and is therefore vulnerable to gimbal lock.
returns a ``random'' number between [0,1] given a 'n'
returns a random, cos-weighted, hemisphere sample in the direction of 'n'
returns a random cone sample in the direction of 'dir' where 'extent' represents the hemisphere area ratio of the cone. (so between [0,1] where 1 represents the whole hemisphere)
The following functions give the distance to a select primitive from the point 'p'.
float distancePlane(vec3 p, vec3 n) float distanceHalfSpacce(vec3 p, vec3 n) float distanceBox( vec3 p, vec3 b ) float distanceCube( vec3 p, float b ) float distanceSphere( vec3 p, float s ) float distanceOctahedronExact( in vec3 p, in float s) float distanceOctahedronInexact( in vec3 p, in float s) float distanceTetrahedron(vec3 p) float distanceTorus( vec3 p, vec2 t ) float distanceCylinder( vec3 p, float r) float distanceCappedCylinder( vec3 p, float h, float r ) return distances to a lot of primitives. all primitives are centered at the origin.
All other parameters define the shape of the primitive.
The following functions have to do with making fractals. 's' always keeps track of the current scaling which is important in keeping the distance fields proper.
Reflect 'p' conditionally (i.e. a fold), about the plane with normal 'n'.
Performs a boxfold where the box is defined by 'min' and 'max'
Performs a sphere inversion.
Performs an iteration of the Menger Sponge IFS. Uniforms included.
Returns the distance to the Menger Sponge fractal. Basically performs mengerSpongeIteration multiple times after which the distance to a cube is taken. Uniforms included.
Performs an iteration of the Kleinian IFS. Uniforms included.
Returns the distance to the Kleinian fractal. Basically performs kleinianIteration multiple times after which the distance to a plane(with normal [0,1,0]) is taken. Uniforms included.