Phong reflection model: Difference between revisions

Content deleted Content added
tidy a bit
Link suggestions feature: 3 links added.
Tags: Visual edit Mobile edit Mobile web edit Newcomer task Suggested: add links
 
(2 intermediate revisions by 2 users not shown)
Line 1:
{{Short description|Shading algorithm in computer graphics}}
{{distinguish|Phong shading}}
[[Image:Phong components version 4.png|thumb|700px|Visual illustration of the Phong equation: here the light is white, the ambient and diffuse colors are both blue, and the specular color is white, reflecting a small part of the light hitting the surface, but only in very narrow highlights. The intensity of the diffuse component varies with the direction of the surface, and the ambient component is uniform (independent of direction).]]
 
The '''Phong reflection model''' (also called '''Phong illumination''' or '''Phong lighting''') is an [[Empirical modelling|empirical model]] of the [[illumination model|local illumination]] of points on a [[Surface (mathematics)|surface]] designed by the computer graphics researcher [[Bui Tuong Phong]]. In [[3D computer graphics]], it is sometimes referred to as <!--DO NOT LINK-->"Phong shading"<!--DO NOT LINK-->, particularly if the model is used with the [[Phong shading|interpolation method of the same name]] and in the context of [[pixel shader]]s or other places where a lighting calculation can be referred to as “[[shading]]”.
Line 54:
:<math>\max(0, \hat{R}_m \cdot \hat{V})^\alpha = \max(0, 1-\lambda)^{\beta \gamma} = \left(\max(0,1-\lambda)^\beta\right)^\gamma \approx \max(0, 1 - \beta \lambda)^\gamma </math>
 
where <math>\lambda = 1 - \hat{R}_m \cdot \hat{V}</math>, and <math>\beta = \alpha / \gamma\,</math> is a [[real number]] which doesn't have to be an [[integer]]. If <math>\gamma</math> is chosen to be a power of 2, i.e. <math>\gamma = 2^n</math> where <math>n</math> is an integer, then the expression <math>(1 - \beta\lambda)^\gamma</math> can be more efficiently calculated by squaring <math>(1 - \beta\lambda)\ n</math> times, i.e.
 
:<math>(1 - \beta\lambda)^\gamma \,=\, (1 - \beta\lambda)^{2^n} \,=\, (1 - \beta\lambda)^{\overbrace{\scriptstyle 2\,\cdot\,2\,\cdot\,\dots\,\cdot\,2}^n} \,=\, (\dots((1 - \beta\lambda)\overbrace{^2)^2\dots)^2}^n.</math>
Line 87:
:<math>1 = \sqrt{(N_x^2 + N_z^2)}</math>
 
Because of the powers of two in the equation there are two possible solutions for the normal direction. Thus some prior information of the geometry is needed to define the correct normal direction. The normals are directly related to angles of inclination of the line on the object surface. Thus the normals allow the calculation of the relative surface heights of the line on the object using a [[line integral]], if we assume a continuous surface.
 
If the object is not cylindrical, we have three unknown normal values <math>N=[N_x, N_y, N_z]</math>. Then the two equations still allow the normal to rotate around the view vector, thus additional constraints are needed from prior geometric information. For instance in [[facial recognition system|face recognition]] those geometric constraints can be obtained using [[principal component analysis]] (PCA) on a database of depth-maps of faces, allowing only surface normals solutions which are found in a normal population.<ref>{{cite book| title=Model-Based Illumination Correction for Face Images in Uncontrolled Scenarios|date=September 2009|last1=Boom |first1= B.J. |last2=Spreeuwers|first2= L.J. |last3=Veldhuis|first3= R.N.J.| volume=5702| pages=33–40| doi=10.1007/978-3-642-03767-2 | issue=2009| series=Lecture Notes in Computer Science| editor1-last=Jiang| editor1-first=Xiaoyi| editor2-last=Petkov| editor-link2= Nicolai Petkov| editor2-first=Nicolai| isbn=978-3-642-03766-5| url=https://halshs.archives-ouvertes.fr/halshs-00420059/document| bibcode=2009LNCS.5702.....J| hdl=11693/26732| hdl-access=free}}</ref>
Line 111:
 
* [https://web.archive.org/web/20160525135133/http://michal.is/projects/phong-reflection-model-matlab/ Phong reflection model in Matlab]
* {{usurped|1=[https://web.archive.org/web/20180816064924/http://www.sunandblackcat.com/tipFullView.php?l=eng&topicid=30 Phong reflection model in GLSL]}}
 
[[Category:Computer graphics algorithms]]