Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* FOR THIS TO WORK, YOU MUST SET PASSES TO 3 in GIF TOOLS PANEL */
- precision highp float;
- varying vec2 UV;
- varying vec2 lastUV;
- uniform float time;
- uniform int pass;
- uniform sampler2D lastPass;
- uniform float ratio;
- #define PI 3.14159265359
- #define PI2 6.28318
- void main(void){
- float x = UV.x * ratio;
- float y = UV.y;
- vec2 pos = vec2(x, y);
- vec4 col = vec4(0.0);
- if(pass == 1){
- // Original pass: a simple circle
- vec2 center = vec2(0.5,0.5);
- float distance_from_center = distance(pos, center);
- if(distance_from_center < 0.3){
- col.rgba = vec4(0.4, 0.5, 0.6, 1.0);
- }
- } else if (pass == 2){
- // Second pass: have fun with position via an offset
- vec2 pos_offset = vec2(0.0);
- pos_offset.x += 0.002 * cos(time * PI2 + pos.y * 100.0);
- col = texture2D(lastPass, lastUV + pos_offset);
- float size = 80.0;
- vec2 pixels = 1.0/size * floor(size * pos);
- vec2 inpixel = vec2(0.0);
- inpixel = mod(pos * size, 1.0);
- if(inpixel.x < 0.31){
- col.rgb *= vec3(1.0, 0.0, 0.0);
- }
- if(inpixel.x > 0.34 && inpixel.x < 0.6){
- col.rgb *= vec3(0.0, 1.0, 0.0);
- }
- if(inpixel.x > 0.68){
- col.rgb *= vec3(0.0, 0.0, 1.0);
- }
- if(inpixel.y > 0.9 || inpixel.y < 0.1){
- col.rgb *= 0.0;
- }
- col += 0.02 * (floor(cos(pos.y * 10.0 - pos.x * 0.4 + time * PI2) * 3.0) + 1.0);
- } else if (pass == 3){
- // Pass3 glow
- float blurf = 0.002;
- vec4 blur = vec4(0.0);
- for(int i = 0; i < 2; i++){
- blurf *= 1.8;
- blur +=
- texture2D(lastPass, lastUV + vec2(blurf, 0.00)) +
- texture2D(lastPass, lastUV + vec2(-blurf, 0.00)) +
- texture2D(lastPass, lastUV + vec2(0.00, -blurf)) +
- texture2D(lastPass, lastUV + vec2(0.00, blurf));
- }
- col = texture2D(lastPass, lastUV) * 0.4 + 0.2 * blur;
- }
- col.a = 1.0;
- gl_FragColor = col;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement