FlatShading

FlatShading[]

is a three-dimensional graphics directive that specifies that faces of polygons and other filled graphics objects are to be drawn to reflect as a flat surface.

FlatShading[d]

uses the attenuation factor d for the diffuse light.

FlatShading[d,a]

uses the attenuation factor a for the ambient light.

Details

  • FlatShading is also known perface shading.
  • FlatShading is typically used to make individual faces and edges of polygons easily visible.
  • The final color of a face of a polygon is computed from the polygon surface normal and the luminosity of the color resulting from standard shading.
  • FlatShading[d,a] specifies that the diffuse light on a 3D surface should be attenuated by a factor d and the ambient light by a.
  • FlatShading[] is effectively equivalent to FlatShading[1,1].
  • The setting Lighting"Accent" uses a directional light and faithfully reproduces colors on the surface.
  • The basic shading models FlatShading, GouraudShading and PhongShading compared:

Examples

open allclose all

Basic Examples  (4)

Apply flat shading to the geodesic polyhedron:

Use flat shading to show a knot:

Show the faces used when rendering a plot:

Visualize a 3D model with hard edges between polygons:

Scope  (12)

Basic Uses  (5)

Apply flat shading to a graphics primitive:

Apply flat shading to a plot:

Apply flat shading to a chart:

Apply flat shading to a 3D object:

Summary box:

Specification  (4)

FlatShading with no arguments uses similar calculations for diffuse and ambient light as the default system shader:

Attenuate all light from the surface by a scaler value:

This is equivalent to specifying each attenuation factor explicitly:

Attenuate the diffuse light, setting the other attenuation factor to zero:

Attenuate the ambient light, setting the other attenuation factor to zero:

Lighting  (3)

FlatShading works with all types of lights:

Use colored lights:

The ambient percentage only applies if an AmbientLight is has been specified:

Applications  (4)

Basic Applications  (2)

The face colors are constant across the face of a polygon and based on the face normal:

Apply FlatShading on the Icosahedron:

The face color is based on the angle between the face normal and light vector:

The face is brightest when pointed toward the light:

The face is darkest when the face normal and light vector are orthogonal:

Visualizations  (2)

Create a low poly plot style:

Visualize the underlying plot mesh:

Properties & Relations  (3)

FlatShading ignores VertexNormals:

Specify FaceForm with FlatShading:

FlatShading is similar to PhongShading when no VertexNormals are available:

FlatShading does not include specular reflection:

Possible Issues  (2)

FlatShading works for graphics objects made of flat polygonal faces:

A discretization of the sphere:

Specular reflection does not affect FlatShading:

Use the default system shader with no VertexNormals specified to include specular lighting:

Wolfram Research (2022), FlatShading, Wolfram Language function, https://reference.wolfram.com/language/ref/FlatShading.html.

Text

Wolfram Research (2022), FlatShading, Wolfram Language function, https://reference.wolfram.com/language/ref/FlatShading.html.

CMS

Wolfram Language. 2022. "FlatShading." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/FlatShading.html.

APA

Wolfram Language. (2022). FlatShading. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/FlatShading.html

BibTeX

@misc{reference.wolfram_2024_flatshading, author="Wolfram Research", title="{FlatShading}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/FlatShading.html}", note=[Accessed: 22-December-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_flatshading, organization={Wolfram Research}, title={FlatShading}, year={2022}, url={https://reference.wolfram.com/language/ref/FlatShading.html}, note=[Accessed: 22-December-2024 ]}