October 2018
Intermediate to advanced
500 pages
12h 40m
English
Uniforms are available to both the vertex shader and the fragment shader. While attributes differ every time the vertex shader is invoked, uniforms are constant throughout a rendering cycle – that is, during the drawArrays or drawElements WebGL call.
We can use uniforms to pass along information about lights (such as diffuse color and direction), and materials (diffuse color):
uniform vec3 uLightDirection; // incoming light source directionuniform vec4 uLightDiffuse; // light diffuse componentuniform vec4 uMaterialDiffuse; // material diffuse color
Again, the uniform keyword tells us that these variables ...