Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Author:Qinxinrui Zhu
- // Title:Color Harmony
- #ifdef GL_ES
- precision mediump float;
- #endif
- #define PI 3.14159265359
- #define Orange vec3(1.,0.427,0.)
- #define Purple vec3(0.141,0.,0.275)
- #define Green vec3(0.0,1.0,0.0)
- #define White vec3(1.0)
- uniform vec2 u_resolution;
- uniform vec2 u_mouse;
- uniform float u_time;
- //rotate the canvas
- mat2 rotate2d(float angle){
- return
- mat2(
- cos (angle), - sin(angle),
- sin(angle), - cos(angle)
- );
- }
- //Create many small square bars to divide the canvas by x-axis
- float create_blind(float start, float blind_width,float direction){
- return -1.0*(step(start, direction) - smoothstep(start + blind_width, start + blind_width+0.05,direction) - 1.0);
- }
- void main() {
- vec2 st = gl_FragCoord.xy/u_resolution.xy;
- float blind_width =0.15;
- //rotate our st make the animation move in the opposite direction
- st.x -= 1.0;
- st = rotate2d(PI)*st;
- // canvas color
- vec3 lights = mix(Purple, Orange,st.x);
- lights = mix(lights,Green,sin(20.0*u_time)*1.0-st.x);
- //Animated values
- //Use abs() to keep the motion in a range with a spacing of 0.15 for each frame
- float Animated_blind_width = blind_width - abs(blind_width*sin(1.5*u_time));
- //Parameters and position of each small bar
- float blind0 = create_blind(0.00,Animated_blind_width,st.x);
- float blind1 = create_blind(0.15,Animated_blind_width,st.x);
- float blind2 = create_blind(0.30,Animated_blind_width,st.x);
- float blind3 = create_blind(0.45,Animated_blind_width,st.x);
- float blind4 = create_blind(0.60,Animated_blind_width,st.x);
- float blind5 = create_blind(0.75,Animated_blind_width,st.x);
- float blind6 = create_blind(0.90,Animated_blind_width,st.x);
- vec3 allblinds = White * blind0 * blind1 * blind2 * blind3 * blind4 * blind5 * blind6;
- gl_FragColor = vec4(allblinds*lights,1.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement