- \n
- vTexCoord = aTexCoord;\n
- \n
- vec3 vNormal = normalize(uNormalMatrix * aNormal);\n
- vec3 vTangent = normalize(uNormalMatrix * aTangent);\n
- vec3 vBiNormal = normalize(uNormalMatrix * aBiNormal);\n
- \n
- vec4 vertPos4 = uModelView * vec4(aPosition.xyz, 1.0);\n
- vec3 vertPos = vec3(vertPos4) / vertPos4.w;\n
- \n
- vec4 lightPos4 = uModelView * vec4(uLightPosition, 1.0);\n
- vec3 lightPos = vec3(lightPos4) / lightPos4.w;\n
- \n
- vec3 vecToLight = lightPos - vertPos;
- vLightDirection.x = dot(vecToLight, vTangent);
- vLightDirection.y = dot(vecToLight, vBiNormal);
- vLightDirection.z = dot(vecToLight, vNormal);
- vLightDirection = normalize(vLightDirection);
- \n
- vec3 viewDir = normalize(vertPos);
- \n
+
+ vec4 vertPos = uModelView * vec4(aPosition.xyz, 1.0);\n
+ vec4 lightPos = uModelView * vec4(uLightPosition, 1.0);\n
+
+ vec3 tangent = normalize(uNormalMatrix * aTangent);
+ vec3 binormal = normalize(uNormalMatrix * aBiNormal);
+ vec3 normal = normalize(uNormalMatrix * aNormal);
+
+ vec3 vecToLight = normalize( lightPos.xyz - vertPos.xyz );\n
+ vLightDirection.x = dot(vecToLight, tangent);
+ vLightDirection.y = dot(vecToLight, binormal);
+ vLightDirection.z = dot(vecToLight, normal);
+
+ vec3 viewDir = normalize(-vertPos.xyz);