The other day, I started to mess with shaders, which was... fun?
I have done practically no C programming and zero graphics or game development, so this was all new to me. There was only one example I saw in the orbit layout (bloom) so I started looking around..
This has a couple cool things that I was able to implement:
http://www.geeks3d.com/shader-library/Here is a site where you can play around with stuff:
https://www.shadertoy.com/new#And here is a site where people have played around (WARNING: no joke, some of these could probably induce an epileptic seizure):
http://glsl.heroku.com/Here is the ones I thought were pretty cool and maybe useful:
pixelate.frag//http://www.geeks3d.com/20101029/shader-library-pixelation-post-processing-effect-glsl/
uniform sampler2D texture;
void main()
{
float rt_w = 480.0;
float rt_h = 360.0;
float pixel_w = 4.0;
float pixel_h = 2.0;
vec2 uv = gl_TexCoord[0].xy;
vec3 tc = vec3(1.0, 0.0, 0.0);
float dx = pixel_w*(1./rt_w);
float dy = pixel_h*(1./rt_h);
vec2 coord = vec2(dx*floor(uv.x/dx),
dy*floor(uv.y/dy));
tc = texture2D(texture, coord).rgb;
gl_FragColor = vec4(tc, 1.0);
}
ripple.frag//http://www.geeks3d.com/20110316/shader-library-simple-2d-effects-sphere-and-ripple-in-glsl/
uniform sampler2D texture;
uniform float ttime;
void main()
{
float time = ttime / 1000.0;
vec2 tc = gl_TexCoord[0].xy;
vec2 p = -1.0 + 2.0 * tc;
float len = length(p);
vec2 uv = tc + (p/len)*cos(len*12.0-time*4.0)*0.03;
vec3 col = texture2D(texture,uv).xyz;
gl_FragColor = vec4(col,1.0);
}
Ripple requires you to send a parameter, ttime, so your layout.nut would look something like:
local fshader = fe.add_shader(Shader.Fragment, "pixelate.frag");
fshader.set_texture_param("texture");
local snap = fe.add_artwork("snap", 50, 50, 480, 360);
snap.shader = fshader;
fe.add_ticks_callback("onTick");
function onTick( ttime ) {
fshader.set_param("ttime", ttime);
}
scanlines.frag//http://glsl.heroku.com/e#15689.0
uniform sampler2D texture;
void main()
{
vec4 pixel = texture2D(texture, gl_TexCoord[0].xy);
gl_FragColor = pixel - vec4( step(1.0,mod(gl_FragCoord.y,2.0)) );
}
I tried to convert these as best I could and I only really grasped a little about fragment shaders - vertex is still a bit of a mystery to me. So, I guess.. share your shader info??