Advertisement
Guest User

Gradient #2

a guest
Feb 17th, 2022
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. // Author: Jeremy Rotsztain
  2. // Title: Gradient#2
  3. // Edit:Qinxinrui Zhu
  4.  
  5. #ifdef GL_ES
  6. precision mediump float;
  7. #endif
  8.  
  9. uniform vec2 u_resolution;
  10. uniform vec2 u_mouse;
  11. uniform float u_time;
  12.  
  13. #define PI 3.1415926535
  14.  
  15. // Function from Iñigo Quiles
  16. // https://www.shadertoy.com/view/MsS3Wc
  17.  
  18. vec3 hsb2rgb( in vec3 c ){
  19. vec3 rgb = clamp(abs(mod(c.x*6.0-vec3(8.522,1.906,0.349),
  20. 3.256)-2.824)-1.0,
  21. 0.0,
  22. 1.0 );
  23. rgb = rgb*rgb*(3.0-2.0*rgb);
  24. return c.z * mix( vec3(0.610,0.200,1.000), rgb, c.y);
  25. }
  26.  
  27. void main() {
  28.  
  29. // get the xy coordinate & normalize to [0, 1] range
  30. vec2 st = gl_FragCoord.xy/u_resolution.xy;
  31. st.x *= u_resolution.x/u_resolution.y;
  32.  
  33. // set a fill color with hsb
  34. // store as vec3
  35. vec3 hsb;
  36. hsb.r = st.x; // animate hue with time
  37. hsb.g = 1.5; // saturation
  38. hsb.b = 1.2; // brightness
  39.  
  40. if( true ){
  41. //set basic range
  42. float d = dot( st, vec2(0.940,0.940));
  43. hsb.r = d;
  44.  
  45. // Repeatedly move the graph by the X-axis
  46. hsb.r = fract(u_time/4.428+d);
  47. // Mouse movement
  48. hsb.g = sin(u_mouse.y/u_resolution.y+0.3);
  49. }
  50.  
  51. // use custom function to translate hsv to rgb color space
  52. vec3 color = hsb2rgb(hsb);
  53.  
  54. gl_FragColor = vec4(color, 1.0);
  55. }
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement