ToonShading

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 allclose all

Basic Examples  (4)

Apply toon shading to the unit sphere with an accent light:

Use a colored toon shading to show a knot:

Style a surface in a plot:

Draw a cartoon sailing ship:

Scope  (13)

Basic Uses  (5)

Apply toon shading to a graphics primitive:

Apply toon shading to a plot:

Apply toon shading to a chart:

Apply toon shading to a 3D object:

Summary box:

Specification  (5)

ToonShading with no arguments uses three gray tones:

Use colorized toon shading:

Use a custom color sequence:

Specify the weight of each color:

Use a predefined color scheme from ColorData:

Lighting  (3)

ToonShading works with all types of lights:

Use colored lights:

Use "Accent" lighting to faithfully reproduce colors on the surface:

Properties & Relations  (3)

Specify FaceForm with ToonShading:

Approximate the default system shader with ToonShading:

Approximate GoochShading with ToonShading:

Possible Issues  (2)

The default light scheme uses several colored light sources:

Use a single directional light to get the standard toon shading effect:

Surfaces are displayed in a darker color:

Automatically get a balanced three-tone color scheme:

Interactive Examples  (4)

Adjust the weights of the base colors:

Transition between toon shading and smooth shading:

Explore gradient color schemes from ColorData:

Explore indexed color schemes from ColorData:

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

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_2024_toonshading, author="Wolfram Research", title="{ToonShading}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/ToonShading.html}", note=[Accessed: 05-October-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_toonshading, organization={Wolfram Research}, title={ToonShading}, year={2020}, url={https://reference.wolfram.com/language/ref/ToonShading.html}, note=[Accessed: 05-October-2024 ]}