I am trying to make it possible for my GUIs to change color in game, without having to load in a new texture. Here is how I have it implemented as of now.
I get the color of the texture using Sampler2D in the fragment shader, then with the help of some uniform variables,
uniform int maxSwapColors;
uniform bool colorSwap;
uniform vec3 textureColors[3];
uniform vec3 toBeColors[3];
I check to see if the fragment's color should be changed, i.e. that it is equal to a color within textureColors. Where textureColor is the color of the actual preloaded texture gathered from the Sampler2D.
for(int i = 0; i < maxSwapColors; i++) {
if(textureColor.xyz == textureColors[i]) {
textureColor.xyz = toBeColors[i];
}
}
This works except for one problem.
The color switches almost completely except for 4 bands of color where it blends for some reason. The actual texture is comprised of two colors full red and full green. In these bands you can see the color of the preloaded texture.
I assume that the blending is occuring because of OpenGL at some point but I do not know where or why. And this occurs even when I GL11.glDisable(GL11.GL_BLEND);
I have tried using glsl's greaterThan() and lessThan() methods to create a range for textureColors. This makes the bands smaller but does NOT completely remove them, so I am looking for a more comprehensive solution.
Thank you, and any help is appreciated!