Hello! I am trying to map textures with empty pixels (not white pixels) to openGL rects. However, I am running into an issue. Almost all of the empty pixels are discarded, but a few white pixels remain around the edges of my texture, despite not being there in the image file. You can see the problem in the image attached below.
[ATTACH=CONFIG]1169[/ATTACH]
Here is the shader code I’m using to discard empty pixels:
#version 330 core
in vec2 TexCoords;
out vec4 color;
uniform sampler2D Texture;
uniform vec4 uniformColor;
void main()
{
vec4 texColor = texture(Texture, TexCoords) * uniformColor;
if(texColor.a < 0.1)
discard;
color = texColor;
}
And here is where I am loading textures, using the SOIL library.
GLuint loadTexture(const char* filePath)
{
int textureWidth, textureHeight;
GLuint texture;
//Generates the Texture ID and stores in var
glGenTextures(1, &texture);
//Binds the texture so future fx calls will affect this texture
glBindTexture(GL_TEXTURE_2D, texture);
//Loads the image using soil
unsigned char* image = SOIL_load_image(filePath, &textureWidth,
&textureHeight, 0, SOIL_LOAD_RGBA);
//Generates Texture info
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureWidth, textureHeight, 0,
GL_RGBA, GL_UNSIGNED_BYTE, image);
glGenerateMipmap(GL_TEXTURE_2D);
//de allocates resources and unbinds texture
SOIL_free_image_data(image);
glBindTexture(GL_TEXTURE_2D, 0);
return texture;
}
Does anyone have any idea what might be causing this issue? Let me know if I could provide any other useful information, and thanks in advance for any help you can provide.