oh i see, i looked through the debugger its _obj-Color:R/G/B
my logger keeps flooding the console with "Binding texture 0" and "Binding texture 1", even with LL_ERRORS_ONLY
so I cant even see these messages.
I'm building a model viewer where you can change colors for certain parts on the fly, as in using user input.
The model is color coded in the sense that certain mesh parts are one specific color, so im just using crude logic to identify the color,
and use if statements inside the shader to change it to user color, if existing color is within a certain tolerance range.
I now see that the texture swapping solution will be way more elegant.
Also, im assuming if there is any material in the file that is not being used will not be TEXTURED, right ?
that would explain why my total texture count is less than the number of materials in the .mtl file
BTW, your engine is the best I've seen for android. I was able to get it up and running in 1 day. I use AndEngine but its only good for 2D stuff.
Thank you so much for writing this.
here is a sample
// Changing COLORS AT RUNTIME IN THE FRAG SHADER
// If "check" is within a certain tolerance, then we have the correct color that must be replaced.
// "check" is being read from the texture, and compared to the known RGB color "x"
// x is the known value of the color which must be replaced.
bool isWithin(float check, float x, float tol) {
if( (check >= (x - tol)) &&
(check <=(x + tol)))
return true;
return false;
}
void main () {
vec4 printCol;
vec4 base = texture2D(textureUnit0, TEX0);
if (isWithin(base.x, mod1.x, modTol) && isWithin(base.y, mod1.y, modTol) && isWithin(base.z, mod1.z, modTol) )
printCol = vec4(mod1NewColor.xyz, 1);
else
printCol = vec4(base.xyz, 1);// myAddColor;// * diffuse;// vDiffuse;
gl_FragColor = printCol;
}