154
edits
Changes
→This Week
* Vertex Shaders
* Lighting in Vertex Shaders
** [http://msdnen.microsoftwikipedia.comorg/wiki/enBlinn%E2%80%93Phong_shading_model Blinn-us/library/aa451203.aspx Lighting FormulasPhong and Phong] - note the corrections below
*** Notation
***: G<sub>a</sub> - global ambient color
***: L<sub>dir<sub>i</sub></sub> - direction vector of light i
***: N - normal to the surface at the vertex
*** Blinn-Phong - use halfway vector instead of reflection vector - adjust power to compensate
***: (N<sup>.</sup>H)<sup>p'</sup>
***: H<sub>i</sub> - halfway vector
***:: H<sub>i</sub> = norm(norm(Camera<sub>position</sub> - Vertex<sub>position</sub>) + L<sub>dir<sub>i</sub></sub>)***:: H<sub>i</sub> = norm([0,0,1] + L<sub>dir<sub>i</sub></sub>) - less computationally intensive - assumes that camera is at infinity along z axis***: p'<sub>i</sub> - adjusted specular power of light i*** Phong - account accurately for position of viewer***: (R<sup>.</sup>V)<sup>p</sup>***: R<sub>i</sub> - reflection vector***:: R<sub>i</sub> = 2 * (N . L<sub>dir<sub>i</sub></sub>) N - L<sub>dir<sub>i</sub></sub>***: V<sub>i</sub> - viewpoint vector***: p<sub>i</sub> - true specular power of light i
***:
*** [http://msdn.microsoft.com/en-us/library/bb172256%28v=VS.85%29.aspx Ambient]
***: C<sub>d</sub> * sum [ L<sub>d</sub><sub>i</sub> * (N . L<sub>dir<sub>i</sub></sub>) * Atten<sub>i</sub> * Spot<sub>i</sub> ]
*** [http://msdn.microsoft.com/en-us/library/bb147399%28VS.85%29.aspx Specular]
***: C<sub>s</sub> * sum [ L<sub>s</sub><sub>i</sub> * (N . H<sub>i</sub>)<sup>p'<sub>i</sub></sup> * Atten<sub>i</sub> * Spot<sub>i</sub> ]- Blinn-Phong***: C<sub>s</sub> * sum [ L<sub>s</sub><sub>i</sub> * (R . V<sub>i</sub>)<sup>p<sub>i</sub></sup> * Atten<sub>i</sub> * Spot<sub>i</sub> ] - Phong
** [http://msdn.microsoft.com/en-us/library/ff471376%28v=vs.85%29.aspx HLSL Intrinsic Functions]
*** [http://msdn.microsoft.com/en-us/library/bb509630%28v=vs.85%29.aspx normalize()] - normalize a vector