is a three-dimensional graphics directive specifying that surfaces that follow are to be drawn to emulate two-dimensional flat objects.
ToonShading[col]
uses the color col as base color.
ToonShading[{dcol,bcol,hcol}]
uses the dark color dcol, the base color bcol and highlight color hcol.
ToonShading[{w1,w2,w3}{dcol,bcol,hcol}]
uses the colors dcol, bcol and hcol weighted by the wi.
ToonShading["scheme"]
uses the specified discrete color scheme in ColorData.
ToonShading
is a three-dimensional graphics directive specifying that surfaces that follow are to be drawn to emulate two-dimensional flat objects.
ToonShading[col]
uses the color col as base color.
ToonShading[{dcol,bcol,hcol}]
uses the dark color dcol, the base color bcol and highlight color hcol.
ToonShading[{w1,w2,w3}{dcol,bcol,hcol}]
uses the colors dcol, bcol and hcol weighted by the wi.
ToonShading["scheme"]
uses the specified discrete color scheme in ColorData.
Details
- ToonShading is also known as cel shading.
- ToonShading is typically used to achieve the cartoonish or hand-drawn appearance of three-dimensional objects.
- The final colors when using toon shading are computed from the luminosity of the color resulting from standard shading, and then quantized into discrete colors.
- ToonShading[{w1,w2,w3}{dcol,bcol,hcol}] specifies that luminosity on the surface should be linearly quantized to the colors dcol, bcol and hcol with weights w1, w2 and w3. A higher weight wi indicates that more of a corresponding color should be used.
- Colors can be defined by RGBColor, Hue or any other color specification. Any number of colors can be used.
- ToonShading[] is effectively equivalent to ToonShading[{GrayLevel[0.2],GrayLevel[0.7],GrayLevel[1.]}].
- ToonShading[col] uses dark, base and highlight colors obtained by blending col with Black, Gray and White.
- In ToonShading[{dcol,bcol,hcol}], the colors dcol, bcol and hcol are weighted uniformly.
- ToonShading["scheme"] is equivalent to ToonShading[ColorData["scheme","ColorList"]].
- The setting Lighting"Accent" uses a directional light and faithfully reproduces colors on the surface.
Examples
open all close allBasic Examples (4)
Apply toon shading to the unit sphere with an accent light:
Graphics3D[{ToonShading[], Sphere[]}, Lighting -> "Accent"]Use a colored toon shading to show a knot:
Graphics3D[{ToonShading[Red], KnotData["SolomonSeal", "ImageData"]}, Lighting -> "Accent"]Plot3D[Sin[x + y ^ 2], {x, -3, 3}, {y, -2, 2}, PlotPoints -> 80, PlotStyle -> ToonShading[], Mesh -> None]Graphics3D[{ToonShading[], ExampleData[{"Geometry3D", "Galleon"}, "GraphicsComplex"]}, Boxed -> False]Scope (14)
Basic Uses (5)
Apply toon shading to a graphics primitive:
Graphics3D[{ToonShading[], #}, Lighting -> "Accent"]& /@ {Sphere[], CapsuleShape[], Cone[]}SphericalPlot3D[1 + 2Cos[2θ], {θ, 0, Pi}, {ϕ, 0, 2Pi}, Axes -> False, PlotStyle -> ToonShading[], PlotPoints -> 40, Lighting -> "Accent"]Apply toon shading to a chart:
BarChart3D[Range[5], ChartElements -> [image], ChartStyle -> ToonShading[]]Apply toon shading to a 3D object:
Graphics3D[{ToonShading[], ExampleData[{"Geometry3D", "Beethoven"}, "GraphicsComplex"]}]ToonShading[]Specification (6)
ToonShading with no arguments uses three gray tones:
Graphics3D[{ToonShading[], Sphere[]}, Lighting -> "Accent"]Graphics3D[{ToonShading[#], Sphere[]}, Lighting -> "Accent"]& /@ {Red, Green, Blue}Graphics3D[{ToonShading[#], Sphere[]}, Lighting -> "Accent"]& /@ {{StandardGray, LightGray}, {Red, Pink, LightRed}, {Purple, Blue, Green, Yellow, Orange, Red}}Specify the weight of each color:
Graphics3D[{ToonShading[# -> {DarkGray, Gray, LightGray}], Sphere[]}, Lighting -> "Accent"]& /@ {{1, 0.1, 0.1}, {1, 1, 1}, {0.1, 1, 0.1}}Use a predefined color scheme from ColorData:
Graphics3D[{ToonShading[#], Sphere[]}, Lighting -> "Accent"]& /@ {"SunsetColors", "BlueGreenYellow", "DeepSeaColors"}Use LightDarkSwitched to specify different colors for light and dark modes:
graphic = Graphics3D[{ToonShading[LightDarkSwitched[StandardRed, StandardBlue]], Sphere[]}, Lighting -> "Accent"];{LightModePane[graphic], DarkModePane[graphic]}Lighting (3)
ToonShading works with all types of lights:
lights = {{"Ambient", LightGray}, {"Point", White, ImageScaled[{1, 1, 2}]}, {"Directional", White, ImageScaled[{1, 1, 2}]}, {"Spot", White, {{1, -1, 1}, {0, 0, 0}}, Pi / 4}};
Graphics3D[{ToonShading[], Sphere[]}, Lighting -> {#}]& /@ lightsGraphics3D[{ToonShading[], Sphere[]}, Lighting -> {{"Directional", Red, ImageScaled[{1, -0.5, 1}]}, {"Directional", Green, ImageScaled[{-1, -0.5, 1}]}, {"Directional", Blue, ImageScaled[{0, 1, 1}]}, {"Ambient", GrayLevel[0.2]}}]Use "Accent" lighting to faithfully reproduce colors on the surface:
Graphics3D[{ToonShading[], Sphere[]}, Lighting -> #] & /@ {"Accent", Automatic}Properties & Relations (3)
Specify FaceForm with ToonShading:
Graphics3D[{FaceForm[#], ToonShading[], Sphere[]}, Lighting -> "Accent"]& /@ {Red, Green, Blue}Approximate the default system shader with ToonShading:
seq = GrayLevel /@ Range[0, 1, 1 / 50]Graphics3D[{ToonShading[seq], Sphere[]}]Approximate GoochShading with ToonShading:
seq = Blend[{LABColor[0.25, 0.4, -0.65], LABColor[0.55, 0.65, 0.65], LABColor[0.9, 0.05, 0.4]}, #]& /@ Range[0, 1, 1 / 60]Graphics3D[{ToonShading[seq], Sphere[]}, Lighting -> "Accent"]Possible Issues (2)
The default light scheme uses several colored light sources:
Graphics3D[{ToonShading[], Sphere[]}]Use a single directional light to get the standard toon shading effect:
Graphics3D[{ToonShading[], Sphere[]}, Lighting -> {{"Directional", White, ImageScaled[{1, 1, 2}]}}]Surfaces are displayed in a darker color:
Graphics3D[{Red, ToonShading[], Sphere[]}, Lighting -> "Accent"]Automatically get a balanced three-tone color scheme:
Graphics3D[{ToonShading[Red], Sphere[]}, Lighting -> "Accent"]Interactive Examples (4)
Adjust the weights of the base colors:
Manipulate[Graphics3D[{ToonShading[{w1, w2, w3} -> {DarkGray, Gray, LightGray}], Sphere[]}, Lighting -> "Accent"], {{w1, 0.5, "Dark"}, 0, 1}, {{w2, 0.5, "Base"}, 0, 1}, {{w3, 0.05, "Highlight"}, 0, 1}]Transition between toon shading and smooth shading:
Manipulate[
Graphics3D[{ToonShading[GrayLevel /@ Range[0, 1, 1 / (n - 1)]], Sphere[]}, Lighting -> "Accent"], {{n, 4, "Smoothness"}, 2, 100, 1}]Explore gradient color schemes from ColorData:
Manipulate[Graphics3D[{ToonShading[gradient], Sphere[]}, Lighting -> "Accent"], {{gradient, "SolarColors", "Gradient"}, ColorData["Gradients"]}]Explore indexed color schemes from ColorData:
Manipulate[Graphics3D[{ToonShading[index], Sphere[]}, Lighting -> "Accent"], {{index, 23, "Index"}, ColorData["Indexed"]}]Related Guides
History
Text
Wolfram Research (2020), ToonShading, Wolfram Language function, https://reference.wolfram.com/language/ref/ToonShading.html.
CMS
Wolfram Language. 2020. "ToonShading." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/ToonShading.html.
APA
Wolfram Language. (2020). ToonShading. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ToonShading.html
BibTeX
@misc{reference.wolfram_2026_toonshading, author="Wolfram Research", title="{ToonShading}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/ToonShading.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_toonshading, organization={Wolfram Research}, title={ToonShading}, year={2020}, url={https://reference.wolfram.com/language/ref/ToonShading.html}, note=[Accessed: 12-June-2026]}