Reading the following topic:
https://forum.thegamecreators.com/thread/214598
the AppGameKit help shader pages and some nice guides around the internet, I've manage to write a simple shader that blends textures at stages 0 and 1
I am not sure if I have apply the build in AppGameKit lighting and fog correct. Here are the vertex and pixel shaders:
uniform highp mat4 agk_World;
uniform highp mat3 agk_WorldNormal;
uniform highp mat4 agk_ViewProj;
uniform vec4 uvBounds0;
mediump vec3 GetVSLighting( mediump vec3 normal, highp vec3 pos );
void main()
{
uvVarying = uv * uvBounds0.xy + uvBounds0.zw;
highp vec4 pos = agk_World * vec4(position, 1.0);
gl_Position = agk_ViewProj * pos;
mediump vec3 norm = normalize(agk_WorldNormal * normal);
posVarying = pos.xyz;
normalVarying = norm;
lightVarying = GetVSLighting( norm, posVarying );
}
uniform sampler2D texture0;
uniform sampler2D texture1;
varying highp vec3 posVarying;
varying mediump vec3 normalVarying;
varying mediump vec2 uvVarying;
varying mediump vec3 lightVarying;
mediump vec3 GetPSLighting( mediump vec3 normal, highp vec3 pos );
mediump vec3 ApplyFog( mediump vec3 color, highp vec3 pointPos );
void main()
{
mediump vec3 norm = normalize(normalVarying);
mediump vec3 light = lightVarying + GetPSLighting( norm, posVarying );
mediump vec3 color0 = texture2D(texture0, uvVarying).rgb * light;
mediump vec3 color1 = texture2D(texture1, uvVarying).rgb * light;
color0 = ApplyFog( color0, posVarying );
color1 = ApplyFog( color1, posVarying );
vec4 colorResult0 = vec4(color0, texture2D(texture0, uvVarying).a);
vec4 colorResult1 = vec4(color1, texture2D(texture1, uvVarying).a);
gl_FragColor = mix(colorResult0, colorResult1, colorResult1.a);
}