CS 3110--WebGL Example 6
Use 1, 2, or 3 for different camera angles.
This example uses attributes for each vertex's position and normal.
A uniform variable is used for the colour of the pyramid.
The shader is a Gouraud Shader with one light source. Uniform variables are used to position the light and
set up the lighting and material parameters.
OpenGL Shader Variables
-
Attribute Variable: variables that describe each vertex. In this example there is an attribute for position and normal.
-
Uniform Variable: Variables that are used to describe one or more primitives like Triangles, or Lines.
This example uses modelling, viewing, and projection transforms. Uniform variables are also used for the lighting calculation.
-
Varying Variables: Variables that are computed in the vertex shader and passed to the fragment shader. Varying variables
are interpolated for each fragment. If triangles are being drawn the varying variables are interploated between the calculations for each
vertex of the triangle. There is one varying variable for the colour in this example.
Code Attribution
-
initshaders.js - Dave Shreiner, Graham Sellers, John Kessenich, Bill Licea-Kane
-
webgl-utils.js - Google
-
HTML and code structure - based on examples by Dave Shreiner, Graham Sellers, John Kessenich, Bill Licea-Kane and Ed Angel