Advertisement
mivebe

Ex: 5 - Scaling

Nov 21st, 2023
1,008
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #version 300 es
  2. #ifdef GL_ES
  3. precision mediump float;
  4. #endif
  5.  
  6. uniform vec2 u_resolution;
  7. uniform float u_time;
  8. out vec4 outColor;
  9.  
  10. mat2 scale(vec2 scale) {
  11.   return mat2(scale.x, 0.0, 0.0, scale.y);
  12. }
  13.  
  14. float circleShape(vec2 position, float radius) {
  15.   return step(radius, length(position - vec2(0.5)));
  16. }
  17.  
  18. void main() {
  19.   vec2 coord = gl_FragCoord.xy / u_resolution.x;
  20.   vec3 color = vec3(0.0);
  21.  
  22.   coord = scale(vec2(sin(u_time) + 2.0)) * coord;
  23.  
  24.   color += vec3(circleShape(coord, 0.3));
  25.  
  26.   outColor = vec4(color, 1.0);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement