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 lowp int uLightType;
13 uniform mediump vec3 uLightVector;
14 uniform lowp int uIsColor;
19 flat out int visLight;
20 out highp vec3 vLightDirection;
21 out highp vec3 vPositionToCamera;
25 highp vec4 invY = vec4(1.0, -1.0, 1.0, 1.0);
26 highp vec4 positionW = uModelMatrix * vec4( aPosition * uSize, 1.0 );
27 highp vec4 positionV = uViewMatrix * ( invY * positionW );
29 vPositionToCamera = transpose( mat3( uViewMatrix ) ) * ( -vec3( positionV.xyz / positionV.w ) );
30 vPositionToCamera *= invY.xyz;
32 lowp vec3 bitangent = cross(aNormal, aTangent.xyz) * aTangent.w;
33 vTBN = mat3( uModelMatrix ) * mat3(aTangent.xyz, bitangent, aNormal);
41 vLightDirection = ( invY.xyz * uLightVector ) - ( positionW.xyz / positionW.w );
43 else if( uLightType == 2 )
45 vLightDirection = -( invY.xyz * uLightVector );
55 vColor = aVertexColor;
58 gl_Position = uProjection * positionV; // needs w for proper perspective correction
59 gl_Position = gl_Position/gl_Position.w;