Advertisement
huumanda

gradient shader 1

Feb 15th, 2022 (edited)
111
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: RGB Gradients
  4.  
  5. // Edited by: Amanda Huynh Feb 9 2022
  6.  
  7. #ifdef GL_ES
  8. precision mediump float;
  9. #endif
  10.  
  11. uniform vec2 u_resolution;
  12. uniform vec2 u_mouse;
  13. uniform float u_time;
  14.    
  15. void main() {
  16.    
  17.     // normalize our canvas
  18.     vec2 st = gl_FragCoord.xy/u_resolution.xy;
  19.    
  20.     // normalize our mouse position
  21.     vec2 mouseXY = u_mouse / u_resolution;
  22.    
  23.     // set color #1 manually (peach)
  24.     vec3 red = vec3(1.664,0.009,0.280);
  25.    
  26.     // pick color #2 manually (blue)
  27.     vec3 blue = vec3(0.037,0.081,2.128);
  28.    
  29.     // change the 'space' where the gradient changes
  30.     // using GLSL "shaping functions"
  31.     vec3 color = mix( red, blue, smoothstep( 0.032,0.5*2.224, st.x));
  32.  
  33.     gl_FragColor = vec4(color,1.0);
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement