Glossary · 3D on the web

Shader

In short

A shader is a small program that runs on the graphics card and calculates where geometry lands on screen and what colour each pixel receives. On the web, shaders are written in GLSL (WebGL) or WGSL (WebGPU) [1][2].

Vertex and fragment shaders

Two kinds of shader work together to draw an image [1]:

Vertex shaderFragment shader
Runsonce per vertexonce per pixel
Jobcompute the position on screencompute the colour

Because the GPU runs huge numbers of these calculations in parallel, it takes a lot of work off the CPU [1].

Languages

  • GLSL (OpenGL Shading Language) for WebGL: strongly typed, C-like, with plenty of vector and matrix maths [1].
  • WGSL (WebGPU Shading Language) for WebGPU [2][3].

Why shaders matter for configurators

Every material is ultimately a shader. Libraries such as three.js generate them automatically from material settings. Two practical consequences follow:

  • Per-pixel cost: elaborate materials with clearcoat, transmission or sheen need more processing per pixel [4]. On large high-resolution screens this adds up.
  • Compile time: shaders are compiled for the GPU when first used. Many different materials can noticeably lengthen the start of a 3D view.

Example: cut-away view

A cut-away view discards every pixel beyond a clipping plane while drawing. three.js offers such clipping planes as a setting on the renderer and on materials [5], with no custom shader needed. That is how the cut-away view in the planetary gearhead (example configurator, fictional product) works.

Custom shaders

For special effects such as cut faces, highlights or stylised rendering, developers write their own shaders or extend existing ones. That is powerful but makes a project harder to maintain. We only use custom shaders when standard materials cannot reach the goal.

The pillar page 3D configurator shows where such technical choices fit in a project.

Related terms

  • WebGL

    WebGL (Web Graphics Library) is a JavaScript API that lets web pages draw hardware-accelerated 2D and 3D graphics in the browser without plug-ins. It renders into an HTML canvas element using the device's graphics hardware.

  • WebGPU

    WebGPU is a browser interface that lets web pages use the graphics card for rendering and general computation. It is regarded as the successor to WebGL and gives access to more modern GPU features.

  • PBR (physically based rendering)

    PBR (physically based rendering) is a rendering approach that describes materials with physically motivated values such as base colour, metalness and roughness. They then look believable under changing light and similar across different viewers.

  • Draw calls

    A draw call is a single drawing command sent to the graphics card, such as "draw this mesh with this material". Each call carries overhead, so a few large calls are generally faster than many small ones.

Examples to try

Example configurator · fictional product

Planetary gearhead

A planetary gearhead for sales and training: running drive with adjustable input speed, cut-away and exploded views, item numbers and technical data as sample values.

Industrial cells & machines · Opening and mechanism · Exploded or cut-away view · Notes on the model

Sources

  1. MDN Web Docs: GLSL shaders
  2. W3C: WebGPU Shading Language (WGSL)
  3. MDN Web Docs: WebGPU API
  4. three.js docs: MeshPhysicalMaterial
  5. three.js docs: WebGLRenderer

← All terms in the glossary