Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //TODO: RGB -> square instead fix RGB -> triangle
- #ifdef GL_ES
- precision mediump float;
- #endif
- const float PI = 3.14159;
- uniform vec2 u_resolution;
- uniform vec2 u_mouse;
- uniform float u_time;
- float diatance(vec2 p1, vec2 p2){
- return (
- sqrt(
- pow((p2.y - p1.y),2.0) + pow((p2.x - p1.x),2.0)
- ));
- }
- //Translating Points at an angle w.r.t center point using polar form of a straight line
- //Also **note :
- void main() {
- vec2 res = u_resolution.xy;
- vec2 st, center = vec2(res.x/2.0,res.y/2.0);
- center.x += res.x * 0.5 * sin(u_time*3.0);center.y += res.y * 0.5 * cos(u_time*3.0); //--rotating the center
- float dist = distance (gl_FragCoord.xy,center); // in circlular path
- float angle = atan((gl_FragCoord.y - center.y) / (gl_FragCoord.x - center.x));
- angle = (angle + u_time/2.0); //--small increment to angle to show animation, negate addition to
- // rotate counter Clockwise
- if((gl_FragCoord.x - center.x) < 0.0) //--atan() does not return angles in 2nd and 3rd quadrant
- angle += PI; // so we need to write seperate code to implement that logic
- else if((gl_FragCoord.y - center.y) < 0.0)
- angle += 2.0*PI;
- st.x = (dist * cos(angle)) / res.x; //--New color intensity after adding change to angle
- st.y = (dist * sin(angle)) / res.y;
- st.x*= 1.0+st.x;
- st.y*= 1.0+st.y;
- vec3 color;
- color = vec3( //--passing color intensities as a multiple of positive sin() R[0,1] as a function of time to animate
- (1.0 - (st.y - st.x)*1.0)* abs(sin(u_time/2.0)),
- (1.0 - (st.x - st.y)*1.0)* abs(sin(u_time/2.0 + 2.0*PI/3.0)),
- (1.0 - ((st.x + st.y)/2.0)) * abs(sin(u_time/2.0 + 4.0*PI/3.0))
- );
- gl_FragColor = vec4(color,1.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement