Reputation: 71
I have this shader to implement character animation
uniform mat4 u_mVxP;
uniform mat4 u_mBlendMatrices[54];
uniform vec4 u_vDLDiffuseColor;
uniform vec4 u_vDLAmbientColor;
uniform vec3 u_vLightDir;
attribute vec4 a_Position;
attribute vec3 a_BWeights;
attribute vec3 a_BIndices;
attribute vec3 a_Normal;
attribute vec2 a_TextureCoordinates;
varying vec2 v_TextureCoordinates;
varying vec4 v_Color;
void main()
{
vec4 vPos;
vec3 vNormal;
int i=int(a_BIndices.x);
int j=int(a_BIndices.y);
int k=int(a_BIndices.z);
vPos=a_BWeights.x * a_Position * u_mBlendMatrices[i];
vPos+=a_BWeights.y * a_Position * u_mBlendMatrices[j];
vPos+=a_BWeights.z * a_Position * u_mBlendMatrices[k];
vNormal=a_BWeights.x * vec3(vec4(a_Normal,0.0) * u_mBlendMatrices[i]);
vNormal+=a_BWeights.y * vec3(vec4(a_Normal,0.0) * u_mBlendMatrices[j]);
vNormal+=a_BWeights.z * vec3(vec4(a_Normal,0.0) * u_mBlendMatrices[k]);
vNormal = normalize(vNormal);
v_Color = u_vDLDiffuseColor * max(dot(-u_vLightDir,vNormal),0.0) + u_vDLAmbientColor;
gl_Position = vPos * u_mVxP;
v_TextureCoordinates = a_TextureCoordinates;
}
code runs perfect on galaxy s3 and s4 and my characters have thier animation correctly. but in sony xperia Z and galaxy note3 they are rendered only in bind pos with no animation! after a lot of test i found out that when float converts to int in xperia z and galaxy note3 it only return 0
int i=int(a_BIndices.x); // i is always 0
int j=int(a_BIndices.y); // j is always 0
int k=int(a_BIndices.z); // k is always 0
i even used this code
int i=1;
but i is still 0. could anyone help me what is going on
Upvotes: 2
Views: 263
Reputation: 71
I finally found out that i should use vec4 array instead of matrix array! its weird but solved my case
Upvotes: 1