5,321
edits
Line 142: | Line 142: | ||
Here, the image is a linear combination of ambient, diffuse, and specular colors. | Here, the image is a linear combination of ambient, diffuse, and specular colors. | ||
If <math>N</math> is the normal vector, <math>V</math> is a vector from the vertex to the viewer, <math>L</math> from the light to the vertex, and <math>R</math> the incident vector (i.e. L rotated 180 around N) then | If <math>\mathbf{N}</math> is the normal vector, <math>\mathbf{V}</math> is a vector from the vertex to the viewer, <math>\mathbf{L}</math> from the light to the vertex, and <math>\mathbf{R}</math> the incident vector (i.e. <math>\mathbf{L}</math> rotated 180 around <math>\mathbf{N}</math>) then | ||
* Ambient is a constant color for every pixel. | * Ambient is a constant color for every pixel. | ||
* The diffuse coefficient is <math>N \cdot L</math>. | * The diffuse coefficient is <math>N \cdot L</math>. | ||
* The specular coefficient is <math>(R \cdot V)^n</math> where <math>n</math> is the ''shininess''. | * The specular coefficient is <math>(\mathbf{R} \cdot \mathbf{V})^n</math> where <math>n</math> is the ''shininess''. | ||
The final color is <math>k_{ambient} * ambientColor + k_{diffuse} * (N \cdot L) * diffuseColor + k_{specular} * (R \cdot V)^n * specularColor</math>. | The final color is <math>k_{ambient} * ambientColor + k_{diffuse} * (\mathbf{N} \cdot \mathbf{L}) * diffuseColor + k_{specular} * (\mathbf{R} \cdot \mathbf{V})^n * specularColor</math>. | ||
;Notes | ;Notes |