A basic vertex/fragment shader combination showing colours

From webglcookbook
Jump to: navigation, search

Here's the vertex shader:

 attribute vec3 aVertexPosition;
 attribute vec4 aVertexColor;
 uniform mat4 uMVMatrix;
 uniform mat4 uPMatrix;
 varying vec4 vColor;
 void main(void) {
   gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);
   vColor = aVertexColor;
 }

...and the fragment shader:

 varying vec4 vColor;
 void main(void) {
   gl_FragColor = vColor;
 }

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox