Hi
I'm not very at shader, but, I have understand some little things
.
When you use an animated shader, it's not the same code as for an "non-animated" shader.
If you want to know what is the code which is used for the default AppGameKit shader (for example, to know what is the code for a defaut animated shader (with fog, light,....), you can use the functions :
txt1$ = GetObjectMeshVSSource(n,1)
txt2$ = GetObjectMeshPSSource(n,1)
OpenToWrite(1,"shadervs.txt")
WriteLine(1,txt1$)
CloseFile(1)
OpenToWrite(1,"shaderps.txt")
WriteLine(1,txt2$)
CloseFile(1)
So you will get those kind of code (it's the default AppGameKit shader code, for an animated objet) :
Shader VS :
attribute highp vec3 position;
attribute mediump vec3 normal;
varying highp vec3 posVarying;
varying mediump vec3 normalVarying;
varying mediump vec3 lightVarying;
mediump vec3 GetVSLighting( mediump vec3 normal, highp vec3 pos );
uniform highp mat4 agk_ViewProj;
attribute highp vec2 uv;
varying highp vec2 uvVarying;
uniform highp vec4 uvBounds0;
attribute highp vec4 boneweights;
attribute mediump vec4 boneindices;
uniform highp vec4 agk_bonequats1[28];
uniform highp vec4 agk_bonequats2[28];
highp vec3 transformDQ( highp vec3 p, highp vec4 q1, highp vec4 q2 )
{
p += 2.0 * cross( q1.xyz, cross(q1.xyz, p) + q1.w*p );
p += 2.0 * (q1.w*q2.xyz - q2.w*q1.xyz + cross(q1.xyz,q2.xyz));
return p;
}
void main()
{
uvVarying = uv * uvBounds0.xy + uvBounds0.zw;
highp vec4 q1 = agk_bonequats1[ int(boneindices.x) ] * boneweights.x;
q1 += agk_bonequats1[ int(boneindices.y) ] * boneweights.y;
q1 += agk_bonequats1[ int(boneindices.z) ] * boneweights.z;
q1 += agk_bonequats1[ int(boneindices.w) ] * boneweights.w;
highp vec4 q2 = agk_bonequats2[ int(boneindices.x) ] * boneweights.x;
q2 += agk_bonequats2[ int(boneindices.y) ] * boneweights.y;
q2 += agk_bonequats2[ int(boneindices.z) ] * boneweights.z;
q2 += agk_bonequats2[ int(boneindices.w) ] * boneweights.w;
highp float len = 1.0/length(q1);
q1 *= len;
q2 = (q2 - q1*dot(q1,q2)) * len;
highp vec4 pos = vec4( transformDQ(position,q1,q2), 1.0 );
gl_Position = agk_ViewProj * pos;
normalVarying = normal + 2.0*cross( q1.xyz, cross(q1.xyz,normal) + q1.w*normal );
posVarying = pos.xyz;
lightVarying = GetVSLighting( normalVarying, posVarying );
}
Shader PS :
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 );
mediump vec3 ApplyFog( mediump vec3 color, highp vec3 pointPos );
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 vec3 light = lightVarying + GetPSLighting( norm, posVarying );
mediump vec4 texColor = texture2D(texture0, uvVarying);
gl_FragColor = texColor * blendTex * vec4(light,1.0) * agk_MeshDiffuse + agk_MeshEmissive;
gl_FragColor.rgb = ApplyFog( gl_FragColor.rgb, posVarying );
gl_FragColor = (texture2D(texture0, uvVarying) * agk_MeshDiffuse);
}
So, to change your shader, tperh'aps this could work :
PS shader file :
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 );
mediump vec3 ApplyFog( mediump vec3 color, highp vec3 pointPos );
uniform mediump vec4 agk_MeshDiffuse;
uniform mediump vec4 agk_MeshEmissive;
uniform vec4 MaskColor;
void main()
{
mediump vec4 blendTex = vec4(1.0,1.0,1.0,1.0);
mediump vec3 norm = normalize(normalVarying);
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;
gl_FragColor.rgb = ApplyFog( gl_FragColor.rgb, posVarying );
// gl_FragColor = (texture2D(texture0, uvVarying) * agk_MeshDiffuse);
if (gl_FragColor == MaskColor) discard;
}
Tell me if it works
EDIT : of course, you have to use the shader VS (code) for animated onject too
AGK2 tier1 - http://www.dracaena-studio.com