The toon shader is part of a non-photorealistic rendering (NPR) solution that is provided in combination with the contour_filter.

There are some current limitations when using the toon shader. These are as follows:  

  • Volumes, motion blur, and DOF do not currently work with the toon shader.
  • toon edges can be jaggy if the pixel intensity is greater than 1.0 (for example, when incorrectly combining a Background shader with skydome camera visibility). This can be fixed by clamping the Camera (AA) samples.

The diagram and accompanying text below describe the shading components that form the toon shader. Note that the appearance of the base_tonemap (using a ramp) appears very different with skydome lighting (soft gradation) compared to that of say a directional light (hard gradation). Rollover the image below to view the effect of lighting on the base_tonemap ramp.

Skydome lighting. Rollover image for directional lighting.

1. Edge (requires Contour Filter)

The toon shader supports line_color and width_control. Both of these are useful for avoiding line clutter and changing the line stroke style. The edge detection also uses id, mask color, and texture UV discontinuity.

To view the toon edge, you must change the filter_type (sampling settings) to contour. Note that increasing the contour_filter_width (sampling settings) value will increase render times.

2. Stylized Highlight

An arbitrary texture that can be used to create a highlight. A light must be specified for the stylized highlight.

stylized_highlight requires subdivision with smooth_tangent enabled, otherwise, artifacts may be visible.

3. Specular/Base Tone Mapping

The toon shader uses cell shading via ramp nodes for both base and specular. While it is recommended to connect ramp shaders to the tonemap attributes, any shader can be connected.

4. Rim Lighting

Connect a ramp here to create a rim lighting effect. A light can be specified to create the rim lighting effect.

Toon Shader Visibility

The toon shader is visible in specular reflections (up to 3 bounces), transmission, and also works with displacement (ear uses geometric_normal, angle_threshold: 3).

Pixel Art Style

A pixel art style can be achieved by using negative Camera AA samples with the Toon shader.

Toon with base and specular_tonemap (directional lighting)


A cross hatching sketch style can be achieved by connecting an UberNoise.osl to toon.mask_color. 

UberNoise.osl -> toon.mask_color


The edge is detected when the mask color of neighboring pixels is different. The mask_color is assumed to have a texture connected to draw an arbitrary shape by detecting color differences. With this parameter, lines can be drawn anywhere (the filter draws lines where the color of the mask changes).

Stylistic effects achieved by connecting different shaders to mask_color

The Shade Modes of the Utility shader can be used to add more detail to the edge when connected to mask_color.

Utility shader -> mask_color


The color of the toon edge. The line style can be controlled with a texture here.


Connect a ramp node here to change the Edge Color based on the shading result of the Base.

The direct diffuse shading contribution is mapped into the UVs. So in the example below, the back of the sphere (which has the darkest direct diffuse) is blue and the part of the sphere hit directly by the directional light is green. This then becomes yellow as the exposure of the lighting is increased.

In the example below, the edge_color (yellow) is multiplied by the blue ramp color (connected to edge_tonemap) to give green.

Controls the transparency of the edge.


The maximum width of the contour lines is determined by the width parameter of the contour filter. The actual width is the multiplication of it and this parameter. The line style can be controlled by combining this with a texture.

To increase the edge_width_scale above 1, you will need to increase the contour filter width. However, this will increase render times.

You can avoid edge 'cluttering' in the center by connecting a facing_ratio shader to width_scale. 

The width_scale can be used to control the edge depending on the distance from the camera.

You may notice flickering in animations using width_scale values below 1. Enabling lock_sampling_pattern (sampling render settings) should fix this issue.


The color of the silhouette edge. The line style can be controlled with a texture here.



Connect a ramp node here to change the silhouette_color based on the shading result of the base.



Controls the transparency of the silhouette.



The maximum width of the silhouette contour lines is determined by the width parameter of the contour filter. The actual width is the multiplication of it and this parameter. The line style can be controlled by combining this with a texture.

The Toon shader forces the silhouette width to always be wider than the inner edge width.

To increase the silhouette_width_scale above 1, you will need to increase the contour filter width. However, this will increase render times.



Changes the sorting priority of the edge.

All objects: 0 (left). Red sphere 1 (center). Rollover center image for red sphere 0, green sphere 1 . Blue plane: 1 (both spheres: 0)(right).

The edge line detected by the object/shader ID Difference is called silhouette. If this option is enabled, silhouette lines are drawn using silhouette_color, silhouette_width_scale, silhouette_opacity, and silhouette_tonemap. If this is disabled, silhouette lines inherit the setting for inner edge lines, in other words, they are drawn using edge_color, edge_width_scale, edge_opacity, and edge_tonemap.

Enabled. Rollover images for disabled (default).

The effect of silhouette is also evident on the edges of the pillars and steps (separate objects) in the interior scene below (rollover image).

Disabled (default). Rollover image for enabled.

Silhouette_edge distortion can be achieved by adding a cell_noise to the silhouette_edge, evident in this tutorial here.


By default, the contour color is affected by ray throughput. If a specific color is required for a reflected/refracted object, enable this and use a ray_switch shader.


When turned off, the edge detection is disabled (enabled by default). 

  • To view the toon_edge, you must change the filter_type (sampling settings) to contour.
  • Increasing the contour_filter_width (sampling settings) value will increase render times.

If enabled, edge detection uses the difference of IDs from neighboring pixels.

Enabled (default). Rollover image for disabled.

Curve, Point, and Shape IDs
ID Difference draws edges on curves, points, and shapes. Points also have a different ID for each point. A sphere is covered in particles (as spheres) that use the same toon shader. Emission_rolor = Utility shader with Color = Uniform ID (the ID used by the Toon shader). The particles have edges because each sphere is a point with a different ID. The large sphere is a shape, so the Toon shader uses the name as the ID (otherwise every primitive e.g. polygon would have an edge). For curves, every curve has a different ID, so ID Difference enabled vs disabled would look like the images below.


Detects the difference of shaders of neighboring samples. This is useful when multiple shaders are assigned to a single polymesh, for example.

Ensure that the angle_threshold is low enough, otherwise, you may not notice a difference.


If enabled, edge detection uses the difference of UVs from neighboring pixels.


When less than 180, the edge detection uses the difference of the angle between neighboring pixels.

Angle_threshold keyframed from 180 to 10


The normal used in the edge detection. Choose from: Shading Normal, Smoothed Normal, and Geometric Normal.

Smoothed Normal. Rollover image to view Geometric Normal.


The base color weight.

Surface Normal Direction

When rendering diffuse surfaces, it is very important that the normals of the geometry face in the right direction. In the example below, you can see the difference between normals that are facing inwards in the wrong direction (left side) versus those that are facing correctly in the outwards direction (right side).


The base_color sets how bright the surface is when lit directly with a white light source (intensity at 100%). It defines which percentage for each component of the RGB spectrum does not get absorbed when light scatters beneath the surface. Metal normally has a black or very dark base color, however, rusty metal's need some base color. A base_color map is usually required.

Diffuse file texture -> base_color


Connect a ramp node here to create a cell look (regarded as a tone map).

Directional lighting (rollover image for skydome lighting)

Note that the appearance of the base_tonemap (using a ramp) appears very different with a directional lighting (hard gradation, below center image) compared to that of a skydome light (soft gradation, below right image).

Adjusting light exposure will have an effect on the base_tonemap.

The base_tonemap has a multiplier effect on the base_color. The direct diffuse of the base_tonemap is mapped onto the UVs and then the ramp is evaluated.

Stylistic effects can be achieved when connecting different shaders to base_color or base_tonemap.

Shading Modes of Utility shader


The specular weight. Influences the brightness of the specular highlight. The base_weight is affected by the specular_weight. This is because the toon shader is not a physically based shader but is designed to conserve energy.

Note that the specular examples here all use tonemap.


The color the specular reflection will be modulated with. Use this color to 'tint' the specular highlight. You should only use colored specular for certain metals, whereas non-metallic surfaces usually have a monochromatic specular color. Non-metallic surfaces normally do not have a colored specular.


Controls the glossiness of the specular reflections. The lower the value, the sharper the reflection. In the limit, a value of 0 will give you a perfectly sharp mirror reflection, while 1.0 will create reflections that are close to a diffuse reflection. You should connect a map here to get variation in the specular highlight.

Note that Toon Edge will not appear in reflected surfaces unless Specular Roughness is 0.

Toon shader assigned to floor plane


Anisotropy reflects and transmits light with a directional bias and causes materials to appear rougher or glossier in certain directions. The default value for Anisotropy is 0, which means 'isotropic.' As you move the control towards 1.0, the surface is made more anisotropic in the U axis.


The rotation value changes the orientation of the anisotropic reflectance in UV space. At 0.0, there is no rotation, while at 1.0 the effect is rotated by 180 degrees. For a surface with brushed metal, this controls the angle at which the material was brushed. For metallic surfaces, the anisotropic highlight should stretch out in a direction perpendicular to the brushing direction.


Connect a ramp node here to create a cell look (regarded as a tone map).

specular_tonemap with increasing specular_roughness


Specify the name of the key light to be used for the stylized highlight. You can specify multiple lights using a semicolon-delimited string as "lightShape1;lightShape2". The supported light types are distant, point, spot, and photometric.

  • mesh and skydome lights are not supported since they can create blurred results.
  • stylized_highlight does not work with curves. This will be fixed in a future release.
  • stylized_highlight requires subdivision with smooth_tangent enabled, otherwise, artifacts may be visible.

  • The Toon shader relies on UV maps to compute a smooth tangent, without one you might get discontinuities at polygon edges, or patch edges for subdivs. If you assign UVs, the discontinuities will only be visible where the UV map has a seam. You can also attach a tangent source directly to the toon.tangent, but hiding the UV seams may be simpler.

Rollover image to view without Stylized Highlight


An arbitrary texture (or RGB type node) can be used to create a stylized highlight on an object. If nothing is connected, the stylized_highlight is disabled.

Gradient ramp used to control reflected Highlight Color (directional light). Rollover image to view without it.

Using a solid color gives a circularly shaped highlight.

When using a texture connected to the Stylized Highlight Color, the following must be taken into account.

In the example below, the windowed texture used as the Highlight Color on the right teapot renders correctly because there is sufficient space around the image.


The size of the stylized highlight.

Stylized highlight AOV.

Specify the name of the light to be used here. Rim lighting is affected by the shadow of this light. The supported light types are: distant, point, spot, and photometric.

  • Mesh and skydome lights are not supported since they can create blurred results.
  • Multiple lights are not supported with rim_lighting.

The color of the rim light. Connect a ramp here to get a rim lighting effect. 

Rollover image to view effect of ramp on rim_light_color


If the rim_light_color is, for example, a constant white color, we get the result as in the left image below. If a ramp is connected, this can be used for controlling the overall width of the ramp as in the right image.

Adding colored ramps to rim_light_color can be useful for a wide variety of lighting scenarios. For example, lighting interior scenes, adding rim lighting to a planet, or lighting a character/sculpture.

Color ramp > rim_light_color (point_light). Rollover image.
Directional light. Rollover to view effect of ramp on planet.
Black and white ramp (white position animated).
Rollover image to view rim_light_color (directional light).

Tints the color of the rim light using the base color of the surface.

rim_light_color: white


This option is implemented so that users do not need to connect a ramp node to use Rim Lighting.



Rim light AOV.

The transmission allows light to scatter through the surface, for materials such as glass or water.

Note that you must also disable Opaque for the mesh that has been assigned the Toon shader.

If you can only see black where there should be transparency, you may not have a high enough refraction ray depth value (found in the Ray Depth section of the Render Settings). The default value is two.


Transmission_color multiplies the refracted result by a color.


Adds some additional blurriness of a refraction computed with an isotropic microfacet BTDFThe range goes from 0 (no roughness) to 1.


The directional bias, or anisotropy, of the scattering. The default value of zero gives isotropic scattering so that light is scattered evenly in all directions. Positive values bias the scattering effect forwards, in the direction of the light, while negative values bias the scattering backward, toward the light.


The rotation value changes the orientation of the anisotropic reflectance in UV space. At 0.0, there is no rotation, while at 1.0 the effect is rotated by 180 degrees. For a surface with brushed metal, this controls the angle at which the material was brushed. For metallic surfaces, the anisotropic highlight should stretch out in a direction perpendicular to the brushing direction.


An energy-conserving sheen layer that can be used to approximate microfiber, cloth-like surfaces such as velvet and satin of varying roughness. Sheen is layered onto the diffuse component and its weight is determined with this attribute. Sheen can be thought of as the density or the combination of the density and length of the fibers.


The color of the fibers. Tints the color of the sheen contribution.


This modulates how much the microfibers diverge from the surface normal direction.


Controls the amount of emitted light. It can create noise, especially if the source of indirect illumination is very small (e.g. light bulb geometry).

Note that a mesh_light may work better in a situation where you need an object to emit light that casts realistic ray-traced shadows.

Bulb with emissive shader assigned to it (rollover image)

Increasing the number of diffuse samples will help to reduce any noise in dark, indirectly lit areas of a scene when using emission.


The emitted light color.

Texture map representing hot lava connected to emission_color


The IOR parameter (Index of Refraction) defines the material's fresnel reflectivity and is by default the angular function used. Effectively the IOR will define the balance between reflections on surfaces facing the viewer and on surface edges. You can see the reflection intensity remains unchanged, but the reflection intensity on the front side changes a lot.

The Edge parameter is also affected by IOR.

IOR: 1. Rollover image to view 1.52 (default). Transmission: 1.


Connect a normal map here (usually exported from Mudbox or ZBrush).

Normal mapping works by replacing the interpolated surface normal by the one evaluated from an RGB texture, where each channel (Red, Green, Blue) corresponds to the X, Y and Z coordinates of the surface normal. It can be faster than bump mapping since bump mapping requires evaluating the shader underneath at least three times.


The tangent map. Together with the shading normal, it defines the tangent coordinate system that the input vector applies to. If available from your sculpting tool, you should connect here the tangent map that the normal map relies on. If 0, the shader attempts the following actions to build the frame:

  1. Look for vector user data named "tangent" and "bitangent."
  2. Use the UV derivatives.
  3. Build its own local frame.

The shader works in tangent space only. If your tangent map was exported in either world or object space, you could instead use the more generic space_transform shader.


The amount of diffuse light received from indirect sources only. 

Indirect_diffuse: 0 (default) creates a more two-dimensional looking toon shading effect.


The amount of specularity received from indirect sources only. Values other than 1.0 will cause the materials to not preserve energy, and global illumination may not converge.


Choose the component(s) affected by bump: diffusespecular, or both.


The toon shader is energy conserving by default. If this is disabled, the Toon shader simply adds base, specular, and transmission. Care should be taken when disabling this option as it will affect indirect illumination with the toon shader.


Edge detection can be controlled using a STRING type user data called Toon ID. Otherwise, the detected edges will be driven by the object's own name as a toon-specific ID. This allows for grouping of objects, where Toon ID specifies which objects belong together regarding edge detection.


An optional aov_prefix that will be prepended to the toon AOVs' names. For instance, if aov_prefix is "toon_", the toon diffuse AOV will be written out to "toon_diffuse". This can be used when you need to access both the toon AOVs and the core's LPE AOVs.

Pepe model by Daniel M. Lara (Pepeland). Mery model by Jose Manuel Garcia, Cubebot by Christophe Desse.

  • No labels
Privacy settings / Do not sell my personal information / Privacy/Cookies