After the contour contrast shaders have decided where contours should be drawn, contour shaders decide on the contour color and width (and optionally motion, normal, material tag, and label).
A material gets a simple contour of constant color and width if it references the contour_shader_simple contour shader.
"contour_shader_simple" ( color "color", scalar "width")
This shader only puts contours at the silhouette of objects - even if the contour contrast function has decided that there might also be contours internally on objects.
"contour_shader_silhouette" ( color "color", scalar "width")
This shader takes the maximum (in each color band) of the two material colors on each side of the contour.
"contour_shader_maxcolor" ( scalar "width")
This shader draws contours whose width depends on the curvature (the difference in surface orientation). If φ is the angle between two surface normals, the width is computed by the formula ½(W−w)(1−cosφ)+w, where w is the parameter min_width and W is the parameter max_width. So if two normals are in nearly opposite directions, there is a contour of width close to max_width between them. When the angle between them decreases, the width of the contour decreases down to nearly min_width. (The width will never reach min_width completely, since the contour contrast function will not create any contours where the surface curvature is less than ndelta degrees, and ndelta can not be set to zero without getting contours in the interior of all objects.
At the edge of an object, where the depth difference is large, the maximum contour width is used. The minimum width would theoretically occur at 0 degrees and the maximum width at 180 degrees.
"contour_shader_curvature" ( color "color", scalar "min_width", scalar "max_width")
With the contour_shader_widthfromcolor contour shader, a material gets contours whose thickness depends on material color. The thickness depends on the maximum m of the red, green, and blue color bands. (m is clamped to 1 if it is larger than 1.) The width is computed as (W−w)(1−m)+w, where w is the parameter min_width and W is the parameter max_width. When the color is bright no contour is visible, and when the color gets darker the contour gets wide. The minimum width is used at bright colors and the maximum width is used at black.
"contour_shader_widthfromcolor" ( color "color", scalar "min_width", scalar "max_width")
For example, to get black contours that are thick where the material is in shadow and thin where the material is brightly illuminated, specify
contour "contour_shader_widthfromcolor" ( "color" 0 0 0 1, # solid black "min_width" 0.5, # min width "max_width" 1.5 # max width )
Note that for semitransparent materials, the material color is not just the color of the object material under the given illumination; the color of the objects behind the material is also taken into account.
This shader draws a contour whose color matches the color of the object being contoured, only with a different brightness (usually much darker).
"contour_shader_factorcolor" ( scalar "factor", scalar "width")
For example, to get contours that are half the material color and two percent wide, specify:
contour "contour_shader_factorcolor" ( "factor" 0.5, # factor of material color "width" 2.0 # contour width (in %) )
Like the previous shader, this shader takes the color of objects behind semitransparent materials into account.
Contours are drawn whose color and width are linearly interpolated between two values as specified with the near and far parameter sets. If a contour point is more distant than far_z, the contour gets color far_color and width far_width. If a point is nearer than near_z, the contour gets color near_color and width near_width. If the depth is in between, the color and width are linearly interpolated.
"contour_shader_depthfade" ( scalar "near_z", color "near_color", scalar "near_width", scalar "far_z", color "far_color", scalar "far_width")
For example, to get contours that are interpolated between two percent wide red at depth -10 and half a percent wide blue at depth -25, specify
contour "contour_shader_depthfade" ( "near_z" -10, "near_color" 1 0 0 1, "near_width" 2, "far_z" -25, "far_color" 0 0 1 1, "far_width" 0.5 )
This shader draws contours with a color and width that depends linearly on the frame number. Two frame numbers, colors, and widths are specified. If the frame number is less than the first frame number, the first color and width is used. If the frame number is higher than the last frame number, the last color and width are used. If the frame number is in between, a linear interpolation of the two colors and widths are used.
"contour_shader_framefade" ( integer "frame1", color "color1", scalar "width1", integer "frame2", color "color2", scalar "width2")
In the following example, the contour will be fully opaque white before frame 3, and then disappear gradually until frame 10. After frame 10 the contour is completely transparent.
contour "contour_shader_framefade" ( "frame1" 3, "color1" 1 1 1 1, "width1" 1, "frame2" 10, "color2" 0 0 0 0, "width2" 0.2 )
Contours are drawn whose width depends on the angle φ between the surface normal and the direction to a light source. The width is computed by the formula ½(W−w)(1−cosφ)+w, where w is a parameter min_width and W is a parameter max_width. Therefore the thickness increases gradually from min_width when the surface is directly facing the light direction to max_width when the surface is facing exactly opposite the light direction.
"contour_shader_widthfromlight" ( color "color", scalar "min_width", scalar "max_width", light "light")
For example, consider the case where the name of the light source is light_0. To get black contours that are two percent wide where the surface is facing away from the light source, decreasing down to zero width where the surface is facing the light source directly, specify:
contour "contour_shader_widthfromlight" ( "color" 0 0 0 1, # contour color "min_width" 0.0, # min width (%) "max_width" 2.0, # max width (%) "light" "light_0" # light name )
This shader is a variation of the previous one. It accepts a direction directly, instead of a light that implicitly provides the direction.
"contour_shader_widthfromlightdir" ( color "color", scalar "min_width", scalar "max_width", vector "light_dir")
With this contour shader, the width of a contour will change depending on how many levels of materials are on top of it. If the material is on top, its contour will be of a width specified by a parameter. For each material on top of it, its width will decrease by a factor that is also controllable with a parameter.
"contour_shader_layerthinner" ( color "color", scalar "width", scalar "factor")
For example, to get red contours that are 2 percent wide when the material is on top, 1 percent wide when the material is behind one other (semitransparent) material, 0.5 percent wide when the material is behind two materials, and so on, use the following:
contour "contour_shader_layerthinner" ( "color" 1 0 0 1, # contour color "width" 2.0, # width at top layer (%) "factor" 0.5 # factor pr. layer )
This is a combination of the depthfade, layerthinner, and widthfromlight contour shaders. The width of the contour fades into the background (from near_width to far_width), and the color fades from near_color to far_color. The contour width and color changes with a ramp function between distances near_z and far_z. For each layer the ray has passed through, a factor is multiplied on to the width. If no factor is specified, the width will not depend on the layer. If a light source is specified, the width also depends on the surface normal relative to the light source direction.
"contour_shader_combi" ( scalar "near_z", color "near_color", scalar "near_width", scalar "far_z", color "far_color", scalar "far_width", scalar "factor", light "light", scalar "light_min_factor")
For example, for contours that are interpolated between two percent wide red at depth -12 and one percent wide blue at depth -18, and get half as wide for each layer of material above this material, and where the width also depends on the direction to the light source named mylight, specify
contour "contour_shader_combi" ( # interpolate from "near_z" -12, # this depth, "near_color" 1 0 0 1, # color (red), "near_width" 2, # and width (in %) # to "far_z" -18, # this depth "far_color" 0 0 1 1, # color (blue) "far_width" 1, # and width (in %). # optional: "factor" 0.5, # factor pr. layer "light" "mylight", # light name "light_min_factor" 0.5 )
Copyright (©) 1986-2009 by mental images GmbH