HOME  >   HTML5 CANVAS  >   HTML5 Canvas Glacier Wave Undulation Animation
HTML5 Canvas Glacier Wave Undulation Animation
BY Richard7 Jan,2021
Tags:

This time we are going to bring a wave undulation animation based on HTML5 Canvas, this time it is a glacier wave undulation animation, draw the shape of glacier effect on Canvas and then use the animation feature to make these glaciers keep undulating.

Advertisement

HTML5 Canvas Glacier Wave Undulation Animation
HTML Body Code
#ifdef GL_ES
  precision highp float;
  #endif
  
  attribute float displacement;
  uniform float amplitude;
  uniform float tick;
  varying vec3 vNormal;  

  void main()
  {
    
    float amplitudes = cos(position[0] + tick / 500.0) *
    									 cos(position[1] + tick / 500.0) +
                       amplitude;
      
    vec3 newPosition = 	position +
    										normal *
                      	vec3(amplitudes * displacement / 2.0);
  	vNormal = newPosition;
  
    gl_Position = projectionMatrix *
                  modelViewMatrix *
                  vec4(newPosition,1.0);
  }                        

Advertisement