3 uniform mediump mat4 uProjection;
4 uniform mediump mat4 uModelView;
5 uniform mediump mat4 uMvpMatrix;
7 uniform bool uTextureMapped;
8 uniform mediump vec4 uCustomTextureCoords;
9 attribute highp vec2 aTexCoord;
10 varying mediump vec2 vTexCoord;
12 uniform mat3 uModelViewIT;
13 attribute mediump vec3 aNormal;
14 varying mediump vec3 vNormal;
16 attribute mediump vec3 aPosition;
17 varying mediump vec4 vVertex;
19 #define MAX_BONES_PER_MESH 12
22 uniform int uBoneCount;
23 uniform mediump mat4 uBoneMatrices[MAX_BONES_PER_MESH];
24 uniform mediump mat3 uBoneMatricesIT[MAX_BONES_PER_MESH];
25 attribute mediump vec4 aBoneWeights;
26 attribute mediump vec4 aBoneIndices;
31 mediump vec4 vertexPosition = vec4(aPosition, 1.0);
36 mediump vec4 boneWeights = aBoneWeights;
37 mediump ivec4 boneIndices = ivec4(aBoneIndices);
38 mediump vec3 vertexNormal;
40 // re-calculate the final weight
41 boneWeights.w = 1.0 - dot(boneWeights.xyz, vec3(1.0, 1.0, 1.0));
43 mediump vec4 bonePos = (uBoneMatrices[boneIndices.x] * vertexPosition) * boneWeights.x;
44 bonePos += (uBoneMatrices[boneIndices.y] * vertexPosition) * boneWeights.y;
45 bonePos += (uBoneMatrices[boneIndices.z] * vertexPosition) * boneWeights.z;
46 bonePos += (uBoneMatrices[boneIndices.w] * vertexPosition) * boneWeights.w;
48 vertexNormal = (uBoneMatricesIT[boneIndices.x] * aNormal) * boneWeights.x;
49 vertexNormal += (uBoneMatricesIT[boneIndices.y] * aNormal) * boneWeights.y;
50 vertexNormal += (uBoneMatricesIT[boneIndices.z] * aNormal) * boneWeights.z;
51 vertexNormal += (uBoneMatricesIT[boneIndices.w] * aNormal) * boneWeights.w;
52 vertexNormal = normalize(vertexNormal);
54 vertexPosition = uProjection * bonePos;
56 vNormal = vertexNormal;
61 vertexPosition = uMvpMatrix * vec4(aPosition, 1.0);
62 vVertex = uModelView * vec4(aPosition, 1.0);
63 vNormal = uModelViewIT * aNormal;
67 gl_Position = vertexPosition;
69 mediump vec2 start = uCustomTextureCoords.xy;
70 mediump vec2 scale = uCustomTextureCoords.zw;
71 vTexCoord = vec2(start.x + aTexCoord.x * scale.x, start.y + aTexCoord.y * scale.y);
80 mediump float mOpacity;
81 mediump float mShininess;
88 uniform sampler2D sTexture;
89 uniform sampler2D sOpacityTexture;
90 uniform sampler2D sNormalMapTexture;
91 uniform sampler2D sEffect;
92 varying mediump vec2 vTexCoord;
94 uniform Material uMaterial;
96 uniform lowp vec4 uColor;
97 varying highp vec4 vVertex;
98 varying highp vec3 vNormal;
102 // sample the texture for the initial color
103 mediump vec4 fragColor = texture2D(sTexture, vTexCoord);
105 // apply material properties
106 fragColor.rgb *= (uMaterial.mAmbient + uMaterial.mDiffuse).rgb;
108 // apply material alpha/opacity to alpha channel
109 fragColor.a *= uMaterial.mOpacity * uMaterial.mDiffuse.a;
111 // and finally, apply Actor color
114 gl_FragColor = fragColor;