Search code examples
openglglsl

How much locations do sampler2D take?


Let's consider the following shader code:

layout(location = 0) uniform sampler2D someTexture;
layout(location = ?) uniform int someInteger

How do I know what to replace the question mark with? How many locations does sampler2D take?


Solution

  • All single variables of non-aggregate types take up a single uniform location. Vectors, matrices, and yes samplers and other opaque types all take up one location.

    This is unlike vertex shader/fragment shader input/output variables.