All of the assets in my game are white gradients. Essentially they could easily be stored inside of an alpha channel only texture.
How can I use this to speed up rendering/texturing and the size of my program?
I know of programs that can find the optimal format for an image maybe lowering its channels somehow. Is this the only way?
Would texture2D calls be faster if I just put texture2D(coolTex, uv).x? Or would that be ultimately slower or cause code branching of some sort?
I didn’t test it, but I would guess that the easiest way is to just create a texture with a 8-bit format.
One of those: GL_R8UI, GL_R8I, GL_R8, GL_R8_SNORM
Alpha-channel textures are deprecated in modern OpenGL. Use a GL_RED texture instead.
You can obtain behaviour equivalent to a legacy GL_LUMINANCE texture by using glTexParameter() with GL_TEXTURE_SWIZZLE_* so that green and blue are both taken from the red channel. This may be useful if you need to use such textures with a shader which is expecting RGB. But it’s better if you can write the shader to use a single float rather than a vec3 whose components will always be identical.
Reading one component from a three-component texture won’t be any faster than reading all three components. Using a single-component texture will be faster as it will reduce the memory bandwidth. Subsequent processing may be faster if you’re using a single float rather than a vec3.