Dynamically uniform shader values

According to this document, texture samplers and storage buffer indexes must be dynamically uniform: Core Language (GLSL) - OpenGL Wiki

How then did id Software make their OpenGL 4.5 forward renderer in Doom?: DOOM (2016) - Graphics Study - Adrian Courrèges

It looks like they use a texture atlas to store all shadow maps, so that solves the texture samples problem:


However, there is still the problem of buffer lookups for lighting info:

Indices into a single uniform block or shader storage block don’t need to be dynamically uniform. It’s arrays of blocks (with a separate block per array index) where indices need to be dynamically uniform.

Also: textures are better handled using array textures (GL_TEXTURE_2D_ARRAY) than atlases, as array textures correctly handle wrapping/clamping at the edges (atlases require care to avoid “bleeding” at the edges of tiles). Array textures don’t need dynamically uniform indices. The only advantage of an array of sampler2D over an array texture is that the layers of an array texture all have the same format, dimensions, and parameters (filter and wrap modes), while individual textures don’t have this restriction. This is rarely useful, though.

1 Like

Thanks for the info. It looks like the minimum value for MAX_ARRAY_TEXTURE_LAYERS is 2048 in OpenGL 4.5, which is quite generous.