This is the code for the fragment shader.
in vec2 TexCoord;
uniform sampler2D texture1;
out vec4 OutColor;
void main()
{
OutColor = texture( texture1 , TexCoord);
}
Whenever any GL_RED format texture is passed the greyscale image outputs as red in color.
I can fix that by using the red parameter of the texture in the shader but is it possible to send GL_RED image as GL_RGBA image to the shader.
unsigned char* image = SOIL_load_image(file, &width, &height, &channels , SOIL_LOAD_AUTO);
// Set The Internal Format
if (channels == 4)
{
texture.Internal_Format = gammaCorrect ? GL_SRGB_ALPHA : GL_RGBA;
texture.Image_Format = gammaCorrect ? GL_SRGB_ALPHA : GL_RGBA;
}
else if(channels == 3)
{
texture.Internal_Format = gammaCorrect ? GL_SRGB : GL_RGB;
texture.Image_Format = gammaCorrect ? GL_SRGB : GL_RGB;
}
else if (channels == 1)
{
texture.Internal_Format = GL_RED;
texture.Image_Format = GL_RED;
}