Reputation: 10075
Is it possible to find the internal format of a texture within the shader (glsl)?
For example, if I have a texture with the format GL_RG
, is it possible to recognize in the shader that the blue and alpha value are "constant" and can be ignored?
I know I can use a uniform to pass the texture type from c++ to the shaders. But is there an "intrinsic" way to find out from within the shader?
Upvotes: 4
Views: 249
Reputation: 54652
No, I don't believe there is anything that would give you this information directly.
Looking at the latest GLSL spec (4.50 at this time), I would expect a hypothetical function to get this information to be listed in section "8.9.1. Texture Query Functions" starting on page 158. But the only functions listed there are:
textureSize
: Get size of texture.textureQueryLod
: Get the level of detail used for the given texture coordinates.textureQueryLevels
: Get the number of mipmap levels in the texture.textureSamples
: Get the number of samples for a multisampled texture.So unless there is something completely different I missed, what you're looking for does not exist.
Upvotes: 3