Posted: 21st Sep 2022 15:26
I was experimenting with shaders and visually i got a good result- but then i discovered that i cant set animations to my 3d models if i apply shader to them.

I am using shader files from this post on this forum https://forum.thegamecreators.com/thread/226425

Anyone can tell me what i need to do to make it work with animations also.
Posted: 21st Sep 2022 19:00
You need to change the the vertex shader to commodate for the bones.
This is the part from AGK's default Bone vertex shader you will need:

+ Code Snippet
attribute highp vec4 boneweights;
attribute mediump vec4 boneindices;
uniform highp vec4 agk_bonequats1[30];
uniform highp vec4 agk_bonequats2[30];

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()
{
	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;
	
	uvVarying = uv * uvBounds0.xy + uvBounds0.zw;
	posVarying = vec4( transformDQ(position,q1,q2), 1.0 );
	gl_Position = agk_ViewProj * posVarying;
	normalVarying = normal + 2.0*cross( q1.xyz, cross(q1.xyz,normal) + q1.w*normal );
	lightVarying = GetVSLighting(normalVarying, posVarying.xyz);
}
Posted: 21st Sep 2022 19:25
Thank you.
It works now.

Just for info to the others who are faceing to the same problem:
I had to edit those lines so my model was not scattered
uniform highp vec4 agk_bonequats1[30]; <---instead of value 30 i needed to change that value to 60
uniform highp vec4 agk_bonequats2[30];

I am still learning this stuff so i have no idea what is going on here actually -so i just tried to edit values and happens to work.