Due to popular demand, i'll explain the npc coloring method in a little more detail. This is the base texture:
For this, i created a coloring map. It looks like this:
This map flags the hair as red, the trousers as green and the shirt as blue. This map is the second texture layer of the npc.
The idea is to write a shader can takes three additional color modifiers for the red, green and blue channels of the coloring map. So you read the base texture's color and multiply it with color_channel_intensity*color_modifier_for_channel for each channel and add up the results. The result has to be added to the base color multiplied with (1-color_channel_intensity) for each channel. The resulting fragment shader looks something like this:
precision highp float;
uniform sampler2D textureUnit0;
uniform sampler2D textureUnit1;
varying vec2 texCoord0;
varying vec4 vertexColor;
varying vec4 fogVertexColor;
uniform vec3 colorMul0;
uniform vec3 colorMul1;
uniform vec3 colorMul2;
void main (void)
{
vec4 col0 = texture2D(textureUnit0, texCoord0);
vec4 blend = texture2D(textureUnit1, texCoord0);
float w1=blend.r;
float w2=blend.g;
float w3=blend.b;
gl_FragColor = vertexColor * mix(mix(mix(col0, col0*vec4(colorMul0, 1.0), w1), col0*vec4(colorMul1, 1.0), w2), col0*vec4(colorMul2, 1.0), w3) + fogVertexColor;
}
The mix/mix/mix-part might be hard to understand, so here's the actual operation of that part:
(vec4(col0.rgb*(1.0-w1)*(1.0-w2)*(1.0-w3),0.0) + vec4(col0.rgb*w1*colorMul0,0.0) + vec4(col0.rgb*w2*colorMul1,0.0) + vec4(col0.rgb*colorMul2*w3,0.0))