Having a non bound sampler inside an uniform branch

Viewed 84

Lets say I have pixel shader that sometimes need to read from one sampler and sometimes needs to read from two different samplers, depending on a uniform variable

layout (set = 0, binding = 0) uniform UBO {
   ....
   bool useSecondTexture;
} ubo;
...
void main() {
   vec3 value0 = texture(sampler1, pos).rgb;
   vec3 value2 = vec3(0,0,0);
   if(ubo.useSecondTexture) {
       value2 = texture(sampler2, pos).rgb;
   }
   value0 += value2;
} 

Does the second sampler; sampler2 need to be bound to a valid texture even though the texture will not be read if useSecondTexture is false.

1 Answers
Related