Adventures and learnings in WebGL. Thanks goes to WebGL2 Fundamentals for the amazing tutorial and example code.
WebGL is a GPU accelerated rasterization API, based on OpenGL. It can be used to generate performant 3D graphics in your web browser.
This diagram summarises the WebGL pipeline.
Image sourced from Elm WebGL.
Clip space is the coordinate system used by WebGL.
Image sourced from here.
Takes vertex data and attributes, along with uniforms. Executed once for every vertex. It coverts vertex coordinates to clip space coordinates. Uniforms (constant for all vertexes) are often used for transforming coordinate systems. It also passed varyings (interpolated values) for use in the fragment shader.
Part of the pipeline between vertex shader and fragment shader that converts clip space vertices into a grid of pixels (on the viewport) ready for colouring. This stage is automatic and does not require programming.
Executed for every pixel (or fragment) within a triangle. Varyings from the vertex shader as well as uniforms are used to calculate the colour of the pixel. The fragment shader can be used to render textures or generate advanced lighting effects.