Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef GL_ES
- precision mediump float;
- #endif
- uniform vec2 u_resolution;
- uniform vec2 u_mouse;
- uniform float u_time;
- const float PI = 3.14159;
- float gradient (float point,float x1, float x2){
- return ((point - x1) / (x2 - x1));
- }
- bool liesIn(float x, float left, float right){
- return ((x >= left) && (x <= right));
- }
- void main() {
- vec2 st,res = u_resolution, coord = gl_FragCoord.xy;
- float R = 0.0,
- G = 0.0,
- B = 0.0,
- yGradient,
- oneThirdResX = res.x/3.0, oneSixthResX = res.x/6.0, sinTime = sin(u_time);
- vec3 color;
- if(liesIn(coord.x, 0.0, oneSixthResX)){ //1st segment
- R = 1.0;
- G = gradient(coord.x,0.0,oneSixthResX);
- B = 0.0;
- }
- else if(liesIn(coord.x, oneSixthResX, 2.0*oneSixthResX)){ //2nd segment
- R = 1.0 - gradient(coord.x, oneSixthResX, 2.0*oneSixthResX);
- G = 1.0;
- B = 0.0;
- }
- else if(liesIn(coord.x, 2.0*oneSixthResX, 3.0*oneSixthResX)){ //3rd segment
- R = 0.0;
- G = 1.0;
- B = gradient(coord.x, 2.0*oneSixthResX, 3.0*oneSixthResX);
- }
- else if(liesIn(coord.x, 3.0*oneSixthResX, 4.0*oneSixthResX)){ //4th segment
- R = 0.0;
- G = 1.0 - gradient(coord.x, 3.0*oneSixthResX, 4.0*oneSixthResX);
- B = 1.0;
- }
- else if(liesIn(coord.x, 4.0*oneSixthResX, 5.0*oneSixthResX)){ //5th segment
- R = gradient(coord.x, 4.0*oneSixthResX, 5.0*oneSixthResX);
- G = 0.0;
- B = 1.0;
- }
- else if(liesIn(coord.x, 5.0*oneSixthResX, 6.0*oneSixthResX)){ //6th segment
- R = 1.0;
- G = 0.0;
- B = 1.0 - gradient(coord.x, 5.0*oneSixthResX, 6.0*oneSixthResX);
- }
- sinTime = (sinTime+1.0)/2.0 + 1.0;
- yGradient = (coord.y/(res.y));
- R = mix(R,yGradient,sinTime);
- G = mix(G,yGradient,sinTime);
- B = mix(B,yGradient,sinTime);
- color = vec3(R,G,B);
- gl_FragColor = vec4(color,1.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement