Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- uniform float timer;
- vec4 ProcessTexel()
- {
- vec4 finalTex = vec4(0.0,0.0,0.0,0.0);
- vec2 XY = vTexCoord.st;
- vec2 offset = vec2(0.0,0.0);
- vec4 tex0 = getTexel(XY);
- //green channel off the initial texture color offsets timer
- float timer2 = timer * 0.1 + tex0.y;
- //or as another example, the X position is used
- //float timer2 = timer * 0.1 + XY.x;
- //needed as timer2 will be modified later
- float timer3 = timer2;
- XY.x *= 0.25;
- //ensures that only 1 image in the strip is visible at a time
- XY.x = mod(XY.x, 0.25);
- //mirrors image because why not
- XY.x = 0.125 - abs(0.125 - XY.x);
- vec2 XYtwo;
- XYtwo.x = XY.x;
- XYtwo.y = XY.y;
- //animates image
- timer2 = floor(mod(timer2 * 4, 4)) * 0.25;
- //first image
- XY.x += timer2;
- //second image
- XYtwo.x = XY.x + 0.25;
- vec4 tex1 = getTexel(XY);
- vec4 tex2 = getTexel(XYtwo);
- //blend factor. increases until 2nd image is completely visible.
- //when it goes back to 0, the 2nd image becomes the 1st image
- float mixrate = mod(timer3, 0.25) * 4;
- finalTex = ((tex1 * (1 - mixrate)) + (tex2 * mixrate));
- return finalTex;
- }
Advertisement
Add Comment
Please, Sign In to add comment