-
Notifications
You must be signed in to change notification settings - Fork 53
This is a list and description of the additional uniforms, variables, and functions made available from within The Force's text editor.
vec2 resolution
Returns the pixel dimensions of OpenGL viewport. This may not match the window dimensions, due to ratio selection on the menubar.
float time
System clock time.
float channelTime[4]
Time from a video in one of the texture channels. Currently not implemented.
vec4 mouse
Mouse position in window coordinates are x and y of vec4. Last mouse down position are z and w of vec4. Typically this value is scaled down. If OpenGL context pixel size is set to the default, 2, then
vec2 = mouse.xy / resolution.xy / 2.0;
returns 0.0 - 1.0 position of the mouse.
vec4 date
Returns the current year, month, day, and seconds elapsed of the day.
vec3 channelResolution[4]
Pixel dimensions of loaded textures. Third component is always 1.
vec4 bands
FFT analysis of sound source.
GLSL uniform variable | Frequency |
---|---|
bands.x | 0 - 215Hz |
bands.y | 216Hz - 474Hz |
bands.z | 475Hz - 1034Hz |
bands.w | 1035Hz - 22,050Hz |
vec4 bandsTime
Elapsed time since sound in bands bins peaked.
sampler2D backbuffer
A texture of the previously rendered frame.
float PI = 3.14159
float PI2 = 6.28318
vec3 black = vec3(0.0)
vec3 white = vec3(1.0)
vec3 red = vec3(0.86,0.22,0.27)
vec3 orange = vec3(0.92,0.49,0.07)
vec3 yellow = vec3(0.91,0.89,0.26)
vec3 green = vec3(0.0,0.71,0.31)
vec3 blue = vec3(0.05,0.35,0.65)
vec3 purple = vec3(0.38,0.09,0.64)
vec3 pink = vec3(.9,0.758,0.798)
vec3 lime = vec3(0.361,0.969,0.282)
vec3 teal = vec3(0.396,0.878,0.878)
vec3 magenta = vec3(1.0, 0.189, 0.745)
vec3 brown = vec3(0.96, 0.474, 0.227)
vec2 uvN()
Returns the current pixel in normalized coordinates, 0.0 - 1.0. Top, left is (0, 0).
vec2 uv()
Returns the current pixel in typical four-quadrant Cartesian space. Pixels are aspect-ratio corrected to be square, if window is wider than it tall.
float box(vec2 position, vec2 dimensions, float cornerRadius, float falloff)
Returns the value of a box (inside, outside, or on feathered edge) given the parameters for position, dimensions, corner radius, and falloff. Admit-ably not very useful in current implementation. Try something like the following, because boxes must be positioned relative to what type of coordinate space they are in.
box(uv() - vec2(0, 0), vec2(.1), .001, .001);
float circle(float positionX, float positionY, float radius, float falloff)
Returns the the value of a circle (inside, outside, or on feathered edge) given the parameters for position, radius, and edge falloff. Currently only calculates in uv(), square pixel space.
vec2 rotate(vec2 space, vec2 center, float amount)
Returns a value space rotated around a center by amount of radians. Useful in 2D pixel transformations.
float rand(float x)
float rand(vec2 x)
Returns a pseudo-random float (0.0 - 1.0) with a float parameter. Note, always return value only changes if input changes. Useful when used with time. Consider passing in uv() of uvN() for vec2 version.
float noise(float x)
float noise(vec2 x)
float noise(vec3 x)
An easier to use method of generating random numbers (0.0 - 1.0). This one gives smoothed values and scales better. Same as above, consider passing in vec3(uv(), time) for the vec3 version.
float snoise(vec2 x)
float snoise(vec3 x)
An optimized version of simplex noise generating random numbers (-1.0 - 1.0). Consider passing in vec3(uv(), time) for the vec3 version
float voronoi(vec2 x)
Returns a float value (0.0 - 1.0) representing smooth voronoi.
vec3 voronoi(vec3 x)
X value of returned vec3 gives the voronoi value in three-dimensions. Try
gl_FragColor = vec4(voronoi(vec3(uv() * 10., time)).x, 0., 0., 1.);
Y value gives a linear look, range (0.0 - 1.0).
Z value is something entirely different. Pass value to sin() or cos().
float fbm(float x, int it)
float fbm(vec2 x, int it)
float fbm(vec3 x, int it)
Brownian motion function generator. Second parameter sets the number of iterations the generator should run, typically less than 10.
float rmf(vec2 x, int it)
Ridged Multi-fractal function generator. Second parameter is number of iterations to run, typically less than 10.
float vfbm(vec2 x, int it)
Voronoi version of Brownian motion. Second parameter is number of iterations.
float vrmf(vec2 x, int it)
Voronoi version of ridged multi-fractal. Second parameter is number of iterations.
vec3 hsv2rgb(vec3 c)
Converts from (Hue, Saturation, Value) color space to (Red, Green, Blue).
vec3 sexy()
Returns what may look like a disco ball effect.