Skip to content

Instantly share code, notes, and snippets.

@rgngl
Created December 29, 2013 23:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgngl/c6849beed2d56e80fdbe to your computer and use it in GitHub Desktop.
Save rgngl/c6849beed2d56e80fdbe to your computer and use it in GitHub Desktop.
#define DIRECTIONAL_LIGHT_COUNT 1
vec3 computeLighting(vec3 normalVector, vec3 lightDirection, vec3 lightColor, float attenuation) {
float diffuse = max(dot(normalVector, lightDirection), 0.0);
vec3 diffuseColor = lightColor * _baseColor.rgb * diffuse * attenuation;
return diffuseColor;
}
// Directional light contribution
#if (DIRECTIONAL_LIGHT_COUNT > 0)
for (int i = 0; i < DIRECTIONAL_LIGHT_COUNT; ++i)
{
vec3 lightDirection = normalize(u_directionalLightDirection[i]);
combinedColor += computeLighting(normalVector, -lightDirection, u_directionalLightColor[i], 1.0);
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment