Jump to content

Computer Graphics: Difference between revisions

Line 119: Line 119:
==Shading==
==Shading==
{{main | Wikipedia:Shading}}
{{main | Wikipedia:Shading}}
===Flat Shading===
===Interpolation===
In flat shading, the color is computed for each face.


===Gourard Shading===
* Flat shading - color is computed for each face/triangle.
In Gourard shading, the color is computed in the vertex shader so it's computed only for each vertex.
* Gourard shading - color is computed for each vertex and interpolated.
* Phong shading - color is computed for each pixel with the normal vector interpolated from each vertex.


===Phong Shading===
===Lambert===
{{main | Wikipedia: Phong shading | Wikipedia: Phong reflection model}}
{{main | Wikipedia: Lambertian reflectance}}
See [https://www.scratchapixel.com/lessons/3d-basic-rendering/phong-shader-BRDF scratchapixel phong shader BRDF]
This is a way to model diffuse (matte) materials.
 
===Phong reflection model===
{{main | Wikipedia: Phong reflection model}}
See [https://www.scratchapixel.com/lessons/3d-basic-rendering/phong-shader-BRDF scratchapixel phong shader BRDF]
This is a way to model specular (shiny) materials.


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.   
Line 137: Line 142:
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} * (N \cdot L) * diffuseColor + k_{specular} * (R \cdot V)^n * specularColor</math>.


In Phong shading, the color is computed in the fragment shader where normals are interpolated between vertices from being passed by the vertex shader.
;Notes
* The diffuse and specular components need to be computed for every visible light source.
 
===Physically Based===
See [https://static1.squarespace.com/static/58586fa5ebbd1a60e7d76d3e/t/593a3afa46c3c4a376d779f6/1496988449807/s2012_pbs_disney_brdf_notes_v2.pdf pbs disney brdf notes] and the [http://www.pbr-book.org/ pbr-book] 
In frameworks and libraries, these are often refered to as ''standard materials''.


==More Terms==
==More Terms==