pastebin get z4kWdiKh gfx
This graphics library is for creating fragment shader-style programs. Fragment shaders are programs which take as input a position on the screen and output a color for that pixel. Now, in ComputerCraft, we normally only have a 16 color palette to use, or maybe more if you consider some dithering techniques. However, this API allows you to setup your color palette, and it automatically maps the RGB colorspace to the palette you give it. This just means that you can talk about colors using RGB components and the rest gets handled by the color mapping algorithm.
Well that's nice, but what can you actually use this for? I think in this case, screenshots (and video!) work better than words.
Media
Spoiler
#1Spoiler
Video: http://yevano.me/shr...10_14-49-28.mp4
local res = inputs[1]
local t = inputs[2]
local uv = div2(coord, res)
uv.x = uv.x * res.x/res.y--*2/3
uv.x = uv.x - res.x/res.y/2--*2/3/2
uv.y = uv.y - 0.5
local m = getRotMat2(t)
local uv = mat2mulvec2(m, sub2(uv, vec2(0, 0)))
return vec4((uv.x % 0.4)*5*(sin(t)+1)/2, (uv.y % 0.2)*5*(cos(t)+1)/2, 0, 1)
#2
Spoiler
Video: http://yevano.me/shr...10_14-52-40.mp4
local function shaderFunc(color, coord, inputs)
local res = inputs[1]
local t = inputs[2]
local uv = div2(coord, res)
return vec4(uv.x, uv.y, 0.5 + 0.5 * math.sin(t), 1)
end
#3
Spoiler
Video: http://yevano.me/shr...10_14-57-49.mp4
local function shaderFunc(color, coord, inputs)
local res = inputs[1]
local t = inputs[2]
local uv = div2(coord, res)
uv.x = uv.x * res.x/res.y--*2/3
uv.x = uv.x - res.x/res.y/2--*2/3/2
uv.y = uv.y - 0.5
local m = getRotMat2(t)
local uv = mat2mulvec2(m, sub2(uv, vec2(0, 0)))
local c = vec4((uv.x % 0.4)*5*(sin(t)+1)/2, (uv.y % 0.2)*5*(cos(t)+1)/2, 0, 1)
local d = length2(sub2(uv, vec2(0.3, 0)))
if d < 0.4 then
if d < 0.35 then
return c
end
return vec4(1, 0, 1, 1)
end
return vec4(0, 0, 0, 1)
end
I'm going to add proper documentation for this soon, but for now, this well-commented test file should help anyone who wants to write some shaders. pastebin get Hzg5cCRF test
Let me know if you find this useful!