So, I need to make a shader to replace the gray colors in the texture with the given color. The fragment shader works correctly if I set the color to a specific concrete one, for example
gl_FragColor = vec4(1, 1, 0, 1);
However, I get an error when I try to get the original color of the texture. For some reason, it always returns black.
uniform sampler2D texture; //texture to change void main() { vec2 coords = gl_TexCoord[0].xy; vec3 normalColor = texture2D(texture, coords).rgb; //original color gl_FragColor = vec4(normalColor.r, normalColor.g, normalColor.b, 1); }
Theoretically, it should not do anything - the texture should be unchanged. But instead, it turns completely black. I think the problem is that I'm not sure how to pass the texture as a parameter (to a uniform variable). I am currently using ID (integer), but it seems to always return to black. Therefore, in principle, I do not know how to set the value of a homogeneous texture (or get it in any other way, without using parameters). Code (in Java):
program.setUniform("texture", t.getTextureID());
I use the class of the program that I got from here , as well as the SlickUtils texture class, but I believe that it does not matter.
source share