Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Author: Jeremy Rotsztain
- // Title: Gradient#2
- // Edit:Qinxinrui Zhu
- #ifdef GL_ES
- precision mediump float;
- #endif
- uniform vec2 u_resolution;
- uniform vec2 u_mouse;
- uniform float u_time;
- #define PI 3.1415926535
- // Function from Iñigo Quiles
- // https://www.shadertoy.com/view/MsS3Wc
- vec3 hsb2rgb( in vec3 c ){
- vec3 rgb = clamp(abs(mod(c.x*6.0-vec3(8.522,1.906,0.349),
- 3.256)-2.824)-1.0,
- 0.0,
- 1.0 );
- rgb = rgb*rgb*(3.0-2.0*rgb);
- return c.z * mix( vec3(0.610,0.200,1.000), rgb, c.y);
- }
- void main() {
- // get the xy coordinate & normalize to [0, 1] range
- vec2 st = gl_FragCoord.xy/u_resolution.xy;
- st.x *= u_resolution.x/u_resolution.y;
- // set a fill color with hsb
- // store as vec3
- vec3 hsb;
- hsb.r = st.x; // animate hue with time
- hsb.g = 1.5; // saturation
- hsb.b = 1.2; // brightness
- if( true ){
- //set basic range
- float d = dot( st, vec2(0.940,0.940));
- hsb.r = d;
- // Repeatedly move the graph by the X-axis
- hsb.r = fract(u_time/4.428+d);
- // Mouse movement
- hsb.g = sin(u_mouse.y/u_resolution.y+0.3);
- }
- // use custom function to translate hsv to rgb color space
- vec3 color = hsb2rgb(hsb);
- gl_FragColor = vec4(color, 1.0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement