I've always used RGB textures. Now comes up the need of use of YUV textures (a set of three texture, specifying 1 luminance and 2 chrominance channels). Of course the YUV texture could be converted on CPU, getting the RGB texture usable as usual... but I need to get RGB pixel directly on GPU, to avoid unnecessary processor load... The problem became strange, since I require to specifyin the shader source, because a single texture, the following items:
- Three samplers uniforms, one for each channel
- Two integer uniforms, for specifying the chrominance channels sampling
- a mat3 uniform, for specific YUV to RGB conversion matrix.
This should be done for each YUV texture...
Is it possible to "compress" required uniforms, and getting RGB values quite easily?
Actually i think this could aid:
- Texture sizes, including mipmaps, could be queried. With this, its possible to save the two integer uniforms, since the uniform values are derived the ratio between texture extents
- The mat3 uniforms could be collected as globals, and with preprocessor could be selected.
But what design should I use for specify three (related) textures?
Is it possible to use textures levels for accessing multiple textures? Texture arrays could be usable? And what about using rectangle textures, which doesn't supports mipmaps? Maybe a shader abstraction (struct definition and related function) could aid?
Thank you.