Using lights, normals, and materials in the pipeline

We mentioned in Chapter 2, Rendering Geometry, that WebGL buffers, attributes, and uniforms are used as input variables to the shaders and that varyings are used to carry information between the vertex shader and the fragment shader. Let's revisit the pipeline and see where lights, normals, and materials fit in.

Using lights, normals, and materials in the pipeline

Normals are defined on a vertex-per-vertex basis; therefore normals are modeled in WebGL as a VBO and they are mapped using an attribute, as shown in the preceding diagram. Please notice that attributes are never passed to the fragment shader.

Lights and materials are passed as uniforms. ...

Get WebGL Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.