If I'm using the internal normal mapping then I use "SetObjectNormalMap(1,2)", where the normal image is loaded as image 2.
When I grab the shader, I load the image and then use "setobjectimage(1,2,2)", where the normal image is loaded as image 2.
The shader outputs as such:
varying highp vec2 uvVarying;
uniform sampler2D texture0;
varying mediump vec3 normalVarying;
varying mediump vec3 lightVarying;
varying highp vec3 posVarying;
mediump vec3 GetPSLighting( mediump vec3 normal, highp vec3 pos );
uniform sampler2D texture2;
varying mediump vec3 tangentVarying;
varying mediump vec3 binormalVarying;
uniform mediump vec2 agk_NormalScale;
uniform mediump vec4 agk_MeshDiffuse;
uniform mediump vec4 agk_MeshEmissive;
void main()
{
mediump vec4 blendTex = vec4(1.0,1.0,1.0,1.0);
mediump vec3 norm = normalize(normalVarying);
mediump vec2 texture2UV = uvVarying;
mediump vec3 normalmap = texture2D(texture2, texture2UV*agk_NormalScale).xyz;
normalmap = normalmap * 2.0 - 1.0;
mediump vec3 tangent = normalize(tangentVarying);
mediump vec3 binormal = normalize(binormalVarying);
mediump mat3 TBN = mat3( tangent, binormal, norm );
norm = TBN * normalmap;
mediump vec3 light = lightVarying + GetPSLighting( norm, posVarying );
mediump vec4 texColor = texture2D(texture0, uvVarying);
gl_FragColor = texColor * blendTex * vec4(light,1.0) * agk_MeshDiffuse + agk_MeshEmissive;
}
Now, what I've found (I think) is that in the gl_Fragcolor line at the bottom, there is actually no reference AT ALL to the normal texture. So, I have added in the normal texture, and I get a normal map, but with a deep blue colour.