Created
December 4, 2011 18:32
-
-
Save Darthfett/1430930 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// - DiffuseColor - Returns the Diffuse color for the specified material and light | |
Vector DiffuseColor(Vector materialDiffuse, SceneLight light, Vector normal, Vector lightv) | |
{ | |
float distance = lightv.Magnitude(); | |
float distanceTerm = 1.0f / (light.attenuationConstant + light.attenuationLinear * distance + light.attenuationQuadratic * distance * distance); | |
return materialDiffuse * light.color * (normal.Dot(lightv)) * distanceTerm; | |
} | |
// - SpecularColor - Returns the Specular color for the specified material and light | |
Vector SpecularColor(Vector materialSpecular, float materialShininess, SceneLight light, Vector viewRay, Vector reflect, Vector lightv) | |
{ | |
float distance = lightv.Magnitude(); | |
float distanceTerm = 1.0f / (light.attenuationConstant + light.attenuationLinear * distance + light.attenuationQuadratic * distance * distance); | |
return materialSpecular * light.color * pow((viewRay.Dot(reflect)), materialShininess) * distanceTerm; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment