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.
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 per‐face 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 all close allBasic Examples (4)
Apply flat shading to the geodesic polyhedron:
Graphics3D[{FlatShading[], GeodesicPolyhedron[5]}]Use flat shading to show a knot:
Graphics3D[{FlatShading[], KnotData["SolomonSeal", "ImageData"]}]Show the faces used when rendering a plot:
Plot3D[Sin[x + y ^ 2], {x, -3, 3}, {y, -2, 2}, PlotStyle -> FlatShading[], Mesh -> None, PlotPoints -> 5]Visualize a 3D model with hard edges between polygons:
model = ExampleData[{"Geometry3D", "Galleon"}, "GraphicsComplex"];
Graphics3D[{FlatShading[], model}]Scope (12)
Basic Uses (5)
Apply flat shading to a graphics primitive:
Graphics3D[{FlatShading[], #}]& /@ {Sphere[], CapsuleShape[], Cone[]}SphericalPlot3D[1 + 2 Cos[2 θ], {θ, 0, Pi}, {ϕ, 0, 2 Pi}, Axes -> False, PlotStyle -> FlatShading[], Mesh -> None]Apply flat shading to a chart:
BarChart3D[Range[5], ChartElements -> [image], ChartStyle -> FlatShading[]]Apply flat shading to a 3D object:
Graphics3D[{FlatShading[], ExampleData[{"Geometry3D", "Beethoven"}, "GraphicsComplex"]}]FlatShading[]Specification (4)
FlatShading with no arguments uses similar calculations for diffuse and ambient light as the default system shader:
Graphics3D[{FlatShading[], Sphere[]}]Attenuate all light from the surface by a scaler value:
Graphics3D[{FlatShading[#], Sphere[]}]& /@ {0, 0.5, 1.0}This is equivalent to specifying each attenuation factor explicitly:
Graphics3D[{FlatShading[{#, #}], Sphere[]}]& /@ {0, 0.5, 1.0}Attenuate the diffuse light, setting the other attenuation factor to zero:
Graphics3D[{FlatShading[{#}], Sphere[]}]& /@ {0, 0.5, 1.0}Attenuate the ambient light, setting the other attenuation factor to zero:
Graphics3D[{FlatShading[{0, #}], Sphere[]}]& /@ {0, 0.5, 1.0}Lighting (3)
FlatShading works with all types of lights:
lights = {AmbientLight[LightGray], PointLight[White, ImageScaled[{1, 1, 2}]], DirectionalLight[White, ImageScaled[{1, 1, 2}]], SpotLight[White, {{1, -1, 1}, {0, 0, 0}}, Pi / 4]};
Graphics3D[{FlatShading[], Sphere[]}, Lighting -> {#}]& /@ lightsGraphics3D[{FlatShading[], Sphere[]}, Lighting -> {DirectionalLight[RGBColor[1, 0, 0], ImageScaled[{1, -0.5, 1}]], DirectionalLight[RGBColor[0, 1, 0], ImageScaled[{-1, -0.5, 1}]], DirectionalLight[RGBColor[0, 0, 1], ImageScaled[{0, 1, 1}]], AmbientLight[GrayLevel[0.2]]}]The ambient percentage only applies if an AmbientLight is has been specified:
Graphics3D[{FlatShading[{1, #}], Sphere[]}, Lighting -> AmbientLight[LightGray]]& /@ {0.0, 1.0}Applications (4)
Basic Applications (2)
The face colors are constant across the face of a polygon and based on the face normal:
flatshading[p_] := Graphics3D[{FlatShading[], p, Arrow[...]& /@ p[[1]]}]flatshading[Polygon[{{{0, 0, 0}, {2, 0, 0}, {1, 2, 0}}}]]Apply FlatShading on the Icosahedron:
flatshading[Polygon[{{{0., 0., 0.9510565162951536}, {0.2628655560595668, 0.8090169943749475,
0.42532540417601994}, {-0.6881909602355868, 0.5, 0.42532540417601994}},
{{0., 0., 0.9510565162951536}, {-0.6881909602355868, 0.5, 0.42532540417601994},
{-0 ...
{-0.2628655560595668, 0.8090169943749475, -0.42532540417601994}},
{{-0.2628655560595668, -0.8090169943749475, -0.42532540417601994},
{-0.6881909602355868, -0.5, 0.42532540417601994}, {-0.85065080835204, 0.,
-0.42532540417601994}}}]]The face color is based on the angle between the face normal and light vector:
lightAngle[p : Polygon[v_], θ_] :=
Block[{c = Mean[v], n = Normalize[Cross[v[[2]] - v[[1]], v[[3]] - v[[1]]]], l},
l = RotationMatrix[θ, {n, {1, 0, 0}}].n;Graphics3D[{FlatShading[], p, Thick, RGBColor[0., 2/3, 1.], Arrowheads[0.1], Arrow[{c, c + n}], RGBColor[1., 3/4, 0.], Arrow[{c, c + l}]}, Lighting -> DirectionalLight[White, c + l]]]polygon = Polygon[{{0, 0, 0}, {1.6, 0, 0}, {0.8, 1.6, 0}}];
lightAngle[polygon, #]& /@ {0.2, 0.6, 1.0}The face is brightest when pointed toward the light:
lightAngle[polygon, 0]The face is darkest when the face normal and light vector are orthogonal:
lightAngle[polygon, Pi / 2]Visualizations (2)
SphericalPlot3D[1 + 2 Cos[2 θ], {θ, 0, Pi}, {ϕ, 0, 2 Pi}, PlotPoints -> 5, Mesh -> None, PlotStyle -> FlatShading[]]Visualize the underlying plot mesh:
ParametricPlot3D[{1.16 ^ v Cos[v] (1 + Cos[u]), -1.16 ^ v Sin[v] (1 + Cos[u]), -2 1.16 ^ v (1 + Sin[u])}, {u, 0, 2 Pi}, {v, -15, 6}, Mesh -> None, PlotRange -> All, PlotStyle -> FlatShading[]]Properties & Relations (3)
FlatShading ignores VertexNormals:
model = GraphicsComplex[{...}, Polygon[...], VertexNormals -> {...}];
Graphics3D[{#, model}]& /@ {Null, FlatShading[]}Specify FaceForm with FlatShading:
Graphics3D[{FaceForm[#], FlatShading[], Icosahedron[]}]& /@ {Red, Green, Blue}FlatShading is similar to PhongShading when no VertexNormals are available:
Graphics3D[{#, ResourceData["Beethoven"]}, Boxed -> False]& /@ {PhongShading[], FlatShading[]}FlatShading does not include specular reflection:
Graphics3D[{#, Specularity[White, 1], ResourceData["Beethoven"]}, Boxed -> False]& /@ {PhongShading[], FlatShading[]}Possible Issues (2)
FlatShading works for graphics objects made of flat polygonal faces:
Graphics3D[{FlatShading[], Sphere[]}]A discretization of the sphere:
Graphics3D[{FlatShading[], DiscretizeGraphics[Sphere[]]}]Specular reflection does not affect FlatShading:
model = ExampleData[{"Geometry3D", "Cow"}, "GraphicsComplex"];Graphics3D[{FlatShading[], Specularity[White, 10], model}]Use the default system shader with no VertexNormals specified to include specular lighting:
Graphics3D[{Specularity[White, 10], EdgeForm[], DeleteCases[model, Rule[VertexNormals, _]]}]History
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_2026_flatshading, author="Wolfram Research", title="{FlatShading}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/FlatShading.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_flatshading, organization={Wolfram Research}, title={FlatShading}, year={2022}, url={https://reference.wolfram.com/language/ref/FlatShading.html}, note=[Accessed: 12-June-2026]}