Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Shading
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
===Shading techniques=== During shading a [[surface normal]] is often needed for lighting computation. The normals can be precomputed and stored for each vertex of the model. ====Flat shading==== [[File:Shading1.jpg|thumb|Flat shading a [[Texture mapping|textured]] [[cuboid]]]] [[File:Flat Shading applied to seashell graphics complex in Mathematica.svg|alt=graphics complex of a seashell with flat shading modeled in Mathematica|thumb|Graphics complex of a seashell with flat shading modeled in Mathematica]] Here, the lighting is evaluated only once for each polygon (usually for the first vertex in the polygon, but sometimes for the [[centroid]] for triangle meshes), based on the polygon's surface normal and on the assumption that all polygons are flat. The computed color is used for the whole polygon, making the corners look sharp. This is usually used when more advanced shading techniques are too computationally expensive. [[Specular]] highlights are rendered poorly with flat shading: If there happens to be a large specular component at the representative vertex, that brightness is drawn uniformly over the entire face. If a specular highlight doesn't fall on the representative point, it is missed entirely. Consequently, the specular reflection component is usually not included in flat shading computation. ====Smooth shading==== In contrast to flat shading where the colors change discontinuously at polygon borders, with smooth shading the color changes from pixel to pixel, resulting in a smooth color transition between two adjacent polygons. Usually, values are first calculated in the vertices and [[bilinear interpolation]] is used to calculate the values of pixels between the vertices of the polygons. Types of smooth shading include [[Gouraud shading]]<ref>{{cite journal|last=Gouraud|first=Henri|title=Continuous shading of curved surfaces|journal=IEEE Transactions on Computers|year=1971|volume=C-20|issue=6|pages=623β629|doi=10.1109/T-C.1971.223313|s2cid=123827991 }}</ref> and [[Phong shading]].<ref>B. T. Phong, [https://users.cs.northwestern.edu/~ago820/cs395/Papers/Phong_1975.pdf Illumination for computer generated pictures], ''Communications of ACM'' 18 (1975), no. 6, 311β317. ([[PDF]])</ref> =====Gouraud shading===== # Determine the normal at each polygon vertex. # Apply an [[illumination model]] to each vertex to calculate the light intensity from the vertex normal. # Interpolate the vertex intensities using [[bilinear interpolation]] over the surface polygon. Problems: * Due to lighting being computed only at vertices, the inaccuracies (especially of specular highlights on large triangles) can become too apparent. * T-junctions with adjoining polygons can sometimes result in visual anomalies. In general, T-junctions should be avoided. =====Phong shading===== Phong shading is similar to Gouraud shading, except that instead of interpolating the light intensities the normals are interpolated between the vertices and the lighting is evaluated per-pixel. Thus, the specular highlights are computed much more precisely than in the Gouraud shading model. # Compute a normal N for each vertex of the polygon. # Using [[bilinear interpolation]] compute a normal, N<sub>i</sub> for each pixel. (Normal has to be renormalized each time.) # Apply an [[illumination model]] to each pixel to calculate the light intensity from N<sub>i</sub>. ====Deferred shading==== [[Deferred shading]] is a shading technique by which computation of shading is deferred to later stage by rendering in two passes, potentially increasing performance by not discarding expensively shaded pixels. The first pass only captures surface parameters (such as depth, normals and material parameters), the second one performs the actual shading and computes the final colors.<ref name="urlForward Rendering vs. Deferred Rendering">{{cite web |url=https://gamedevelopment.tutsplus.com/articles/forward-rendering-vs-deferred-rendering--gamedev-12342 |title=Forward Rendering vs. Deferred Rendering |format= |accessdate=}}</ref><ref name="urlLearnOpenGL - Deferred Shading">{{cite web |url=https://learnopengl.com/Advanced-Lighting/Deferred-Shading |title=LearnOpenGL - Deferred Shading |format= |accessdate=}}</ref><ref name="akenine">{{cite book |last1=Akenine-MΓΆller |first1=Tomas |last2=Haines |first2=Eric |last3=Hoffman |first3=Naty |title=Real-Time Rendering |date=2018 |publisher=CRC Press |isbn=978-1-1386-2700-0 |edition=Fourth}}</ref>{{rp|884}} =====Other approaches===== Both [[Gouraud shading]] and [[Phong shading]] can be implemented using [[bilinear interpolation]]. Bishop and Weimer <ref>Gary Bishop and David M. Weimer. 1986. Fast Phong shading. ''SIGGRAPH Comput. Graph''. 20, 4 (August 1986), 103β106.</ref> proposed to use a [[Taylor series]] expansion of the resulting expression from applying an [[illumination model]] and bilinear interpolation of the normals. Hence, second-degree [[polynomial interpolation]] was used. This type of biquadratic interpolation was further elaborated by Barrera et al.,<ref>T. Barrera, A. Hast, E. Bengtsson. [http://www.cb.uu.se/~aht/articles/a03.pdf Fast Near Phong-Quality Software Shading]. ''WSCG'06'', pp. 109β116. 2006</ref> where one second-order polynomial was used to interpolate the diffuse light of the [[Phong reflection model]] and another second-order polynomial was used for the specular light. Spherical linear interpolation ([[Slerp]]) was used by Kuij and Blake<ref>Kuijk, A. A. M. and E. H. Blake, [http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.109.2663&rep=rep1&type=pdf Faster Phong shading via angular interpolation]. ''Computer Graphics Forum'' 8(4):315β324. 1989 ([[PDF]])</ref> for computing both the normal over the polygon, as well as the vector in the direction to the light source. A similar approach was proposed by Hast,<ref>A. Hast. [http://www.cb.uu.se/~aht/articles/quat.pdf Shading by Quaternion Interpolation]. ''WSCG'05''. pp. 53β56. 2005.</ref> which uses [[quaternion]] interpolation of the normals with the advantage that the normal will always have unit length and the computationally heavy normalization is avoided. ====Flat vs. smooth shading==== {| class="wikitable" |- ! Flat !! Smooth |- | Uses the same color for every pixel in a face β usually the color of the first vertex || Smooth shading uses linear interpolation of either colors or normals between vertices |- | Edges appear more pronounced than they would on a real object because in reality almost all edges are somewhat round || The edges disappear with this technique |- | Same color for any point of the face || Each point of the face has its own color |- | Individual faces are visualized || underlying surface are visualized |- | Not suitable for smooth objects || Suitable for any objects |- | Less computationally expensive || More computationally expensive |}
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)