tezvyn:

WebGL Uniforms: Global State for Shaders

Source: developer.mozilla.orgintermediate

WebGL uniforms are global constants for your shaders, set once per frame from JavaScript to provide the same value to every vertex and pixel. Use them for scene-wide data like a camera's projection matrix. The footgun: changing a uniform is a CPU-to-GPU call.

Think of WebGL uniforms as global constants for your shaders, set once per frame from JavaScript. Unlike attributes that vary per-vertex, a uniform provides the exact same value to every vertex and pixel processed in a draw call. This is ideal for scene-wide data like the camera's projection matrix or a light source's color. The main footgun is performance: updating a uniform requires a new API call, which can become a bottleneck if done excessively inside a loop.

Read the original → developer.mozilla.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

WebGL Uniforms: Global State for Shaders · Tezvyn