GLSL Animated Radiating Colors

WebGL Shader Effect

This Web page includes the GLSL shader source code. This WebGL shader displays animated radiating colors. The WebGL vertex and fragment shaders work with vertex colors to generate a series of blended colorful circular areas.

Vertex Shader Fragment Shader Texture Summary

Vertex Shader

 
attribute vec4 a_position;   
attribute vec4 a_tex_coord0;
varying vec4 v_tex_coord0;
        
uniform mat4 um4_matrix; 
uniform mat4 um4_pmatrix;  

uniform float uf_time;   
    
void main(void) {
   
 gl_Position = um4_pmatrix * um4_matrix *  a_position;
  
 float f_dist = distance(
  a_position, 
  vec4(0.0,0.0,0.0,1.0)
 );
  
 vec4 v4_color = a_tex_coord0; 
 v4_color.rb = v4_color.rb * f_dist / uf_time;
 v_tex_coord0 = v4_color; 
}

Fragment Shader

precision mediump float;
varying vec4 v_tex_coord0;
 
void main(void) {  
 gl_FragColor = v_tex_coord0; 
}

Texture

The Animated Radiating Colors example applies vertex colors rather than a texture. Vertex colors allow rendering color per vertex.

Summary

This WebGL shader displays animated radiating colors. The WebGL vertex and fragment shaders work with vertex colors to generate a series of blended colorful circular areas. See more WebGL shader (GLSL) examples.

Learn 3D Programming with Screen Shots Learn 3D Programming with Screen Shots
Copyright © 2015 Seven Thunder Software. All Rights Reserved.