1 in highp vec3 aPosition;
2 in mediump vec2 aTexCoord0;
3 in mediump vec2 aTexCoord1;
6 in lowp vec4 aVertexColor;
8 uniform mediump vec3 uSize;
9 uniform mediump mat4 uModelMatrix;
10 uniform mediump mat4 uViewMatrix;
11 uniform mediump mat4 uProjection;
12 uniform mediump vec3 uLightVector;
13 uniform lowp float uIsPointLight;
14 uniform lowp float uHasVertexColor;
19 out highp vec3 vLightDirection;
20 out highp vec3 vPositionToCamera;
24 highp vec4 invY = vec4(1.0, -1.0, 1.0, 1.0);
25 highp vec4 positionW = uModelMatrix * vec4(aPosition * uSize, 1.0);
26 highp vec4 positionV = uViewMatrix * (invY * positionW);
28 vPositionToCamera = transpose(mat3(uViewMatrix)) * (-vec3(positionV.xyz / positionV.w));
29 vPositionToCamera *= invY.xyz;
31 lowp vec3 bitangent = cross(aNormal, aTangent.xyz) * aTangent.w;
32 vTBN = mat3(uModelMatrix) * mat3(aTangent.xyz, bitangent, aNormal);
37 vLightDirection = mix(-(invY.xyz * uLightVector), (invY.xyz * uLightVector) - (positionW.xyz / positionW.w), uIsPointLight);
39 vColor = mix(vec4(1.0f), aVertexColor, uHasVertexColor);
41 gl_Position = uProjection * positionV; // needs w for proper perspective correction
42 gl_Position = gl_Position/gl_Position.w;