Advertisement
huumanda

gradient shader 2

Feb 15th, 2022 (edited)
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Author: Jeremy Rotsztain
  2. // Course: ShaderArt (DIGF-3011, Winter 2022)
  3. // Title: Hello World (GLSL)
  4.  
  5. // Edited by: Amanda Huynh Feb 16 2022
  6.  
  7. // ignore this for the time being
  8. #ifdef GL_ES
  9. precision mediump float;
  10. #endif
  11.  
  12. uniform vec2 u_resolution;
  13. uniform vec2 u_mouse;
  14. uniform float u_time;
  15.  
  16. void main() {
  17.    
  18.     // get the xy coordinate in pixels & normalize to [0, 1] range
  19.     // by dividing by width (500 x 500 px)
  20.     vec2 st = gl_FragCoord.xy/u_resolution.xy;
  21.    
  22.     //  position in a bit higher than center
  23.     // https://thebookofshaders.com/07/
  24.     float pct = 0.0;
  25.     pct = distance(st,vec2(0.500,0.700));
  26.  
  27.     // fix for aspect ratio
  28.     st.x *= u_resolution.x/u_resolution.y;
  29.  
  30.     vec3 color = vec3(pct);
  31.  
  32.     // red as sinusodal curve positioned pct
  33.     color.r = sin(u_time-pct* 1.5)*3.128;
  34.  
  35.     // // center blue, mouse interaction
  36.     color.b = sin(u_mouse.x/u_resolution.x+pct);
  37.  
  38.     // // green as fract
  39.     color.g = fract(u_time-pct *15.*-st.y);
  40.    
  41. //     RGBA
  42.     gl_FragColor = vec4(color,1.);
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement