46
Projects / Re: New Library And Game
« on: November 19, 2012, 10:43:55 pm »
I like it already It reminds me my first project for Android: Trace_On
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
void main(void)
{
vec4 normal4 = vec4(normal, 0);
vec4 position4 = modelViewMatrix * position;
vec3 position3 = position4.xyz / position4.w;
vec4 eyeNormal4 = modelViewMatrix * normal4;
varNormal = eyeNormal4.xyz;
varLightDir[0] = normalize(lightPositions[0] - position3);
varSpotDir[0] = normalize((modelViewMatrix * vec4(lightSpotDir0,0)).xyz);
varLightDist[0] = length(lightPositions[0] - position3 );
texCoord = texture0;
gl_Position = modelViewProjectionMatrix * position;
}
void main (void)
{
vec4 finalColor;
float spotAngle;
vec3 n = normalize(varNormal);
vec3 normalLightDir;
float diff;
float att;
vec4 base = texture2D(textureUnit0, texCoord);
finalColor = base * ambientColor;
normalLightDir = normalize(varLightDir[0]);
diff = max(0.0, dot(n, normalLightDir));
if(diff > 0.0)
{
spotAngle = dot(normalize(-varSpotDir[0]), normalLightDir);
if(spotAngle > 0.75) //spot cut off
{
spotAngle = pow(spotAngle, 12.0);
//att = spotAngle / (0.6 + 0.001 * tempDistance + 0.1 * tempDistance * tempDistance );
att= 1.0;
finalColor += (base) * diff * att ;
}
}
finalColor.a = alpha;
gl_FragColor = finalColor;
}
animGroup.getRoot().setVisibility(false);