shader
Shaders: what every pixel of the screen becomes, written as a function. The numbers and values in that function are a shader's own: they have up to 4 parts (x, y, z, w, or r, g, b, a), and +, -, *, /, % and ^ work on them part by part.
shader.new
shader.new(function(pixel), numbers?)Makes a shader: the function says what every pixel of the screen becomes, and gives back its colour. It is called once, with what it needs to know about the pixel (see pixel). numbers: a table of the shader's own numbers, which a script can change later, like { strength = 1 }: inside the function each is pixel.strength, outside it made.strength. The shader shows at once.
shader.on
made.onWhether a shader shows: false switches it off, true switches it back on.
shader:remove
made:remove()Takes a shader away for good. (A level can have 8 at once, and 4 of them showing.)
shader.vec
shader.vec(...)Puts parts together into one value of up to 4 parts: shader.vec(0.5, 0.5) is a place, shader.vec(colour.rgb, 1) a colour.
shader.mix
shader.mix(a, b, t)From a to b: a where t is 0, b where t is 1, and in between for the rest.
shader.clamp
shader.clamp(v, low, high)v kept between low and high.
shader.step
shader.step(edge, v)0 where v is under edge, 1 where it is not.
shader.smooth
shader.smooth(low, high, v)0 where v is under low, 1 where it is over high, and a smooth rise in between.
shader.less
shader.less(a, b)1 where a is under b, 0 where it is not: a yes or no for every pixel, for shader.pick.
shader.more
shader.more(a, b)1 where a is over b, 0 where it is not.
shader.pick
shader.pick(test, a, b)a where test is 0.5 or more, b where it is less: what a shader has for 'if'.
shader.min
shader.min(a, b)The smaller of the two, part by part.
shader.max
shader.max(a, b)The bigger of the two, part by part.
shader.mod
shader.mod(a, b)What is left over when a is divided by b (as a % b).
shader.pow
shader.pow(a, b)a to the power b (as a ^ b). a counts without its sign.
shader.abs
shader.abs(v)v without its sign.
shader.floor
shader.floor(v)v rounded down to a whole number.
shader.fract
shader.fract(v)The part of v after the point: 0.25 for 3.25.
shader.sqrt
shader.sqrt(v)The square root of v.
shader.sin
shader.sin(v)The sine of v (v in radians): it swings between -1 and 1 as v grows.
shader.cos
shader.cos(v)The cosine of v (v in radians).
shader.tan
shader.tan(v)The tangent of v (v in radians).
shader.atan2
shader.atan2(y, x)The angle of the point x across and y up, in radians.
shader.exp
shader.exp(v)e to the power v.
shader.log
shader.log(v)The natural logarithm of v.
shader.sign
shader.sign(v)-1 where v is under 0, 1 where it is over, 0 where it is 0.
shader.dot
shader.dot(a, b)The parts of a and b multiplied one by one and added up: a single number.
shader.length
shader.length(v)How long v is: how far a place is from 0, 0.
shader.distance
shader.distance(a, b)How far apart two places are.
shader.grey
shader.grey(colour)How bright a colour is, as a single number: its grey.
shader.random
shader.random(place, seed?)A number from 0 to 1 that looks random. The same place (taken in whole numbers) and seed always give the same number.