Log inGet started
Package

toonBlocks.package

This package holds more than this page lists. See all of its files in its world.

README.md

Rim light (styleBlock, Light)

A hard toon rim light along the outer edges of things, found where depth drops away behind a surface, so it hugs characters, props and roof lines and never washes a flat floor.

Settings: width (4), strength (0.7), colour (#fff5e0), side (0), fresnel (0.5), followLight (0.5), tintByColour (0.3), fullLight (1), keepLightColour (0.5). Low quality looks for the edge with four taps instead of eight.

It is a chain block at rank 50: it builds on what the light block before it made (Toon bands, Toon ramp, Soft wrap light), so add it after one and it lands after it. A pixel is on an outer edge when a tap width reference pixels away lies clearly farther (by about 4% of the distance plus 5 cm) or on the sky. fresnel also asks the surface to turn away from the camera (its normal rebuilt from depth); side -1 rims only the side turned from the sun (a back light), +1 only the side facing it. The rim is light added on top: colour, taking tintByColour of the surface's own colour, at strength, and by followLight as bright as the light on the surface (0 the same rim in sun and shade, 1 bright in sun and faint in shade). keepLightColour is declared for the family but this pass does not use it: the rim's colour is colour alone.

What it gives up in motion

The rim is found again every frame from depth, so it sits on silhouettes and moves with them under any camera move, on moving and animated things too; it keeps its width in the picture at any distance. Thin parts (railings, wires, far branches) can flicker as their depth edge comes and goes at a pixel's width. With side set, which side is rimmed follows the sun's direction, which reaches the block about once a second, so under a moving sun the rimmed side changes in small steps.

How it treats content

  • Opaque things: rimmed on outer edges, including where a near part stands clearly in front of a farther one (an arm over a distant wall). A part only slightly in front (an arm against its own body) gets none. The far edge of a ground plane against the sky counts as an edge and gets a thin rim on the horizon; limit the block with a depth mask if that shows.
  • Transparent things (glass, water): they write no depth, so a pane or a water surface gets no rim of its own, and the rims of things behind are drawn through it, over the glass's colour.
  • Particles and smoke: no depth, so no rim of their own; rims of things behind thin smoke are drawn over the smoke.
  • Sky: never rimmed, but things against the sky are rimmed on that side, since the sky counts as farther than anything.
  • Fog: the rim is light added after fog, so a far silhouette in thick fog still gets a clear rim; lower followLight makes it fainter where the fogged light is low, a depth mask keeps it to the near ground.
  • Skinned characters: rimmed every frame, so the rim follows every pose and every silhouette of the body.
  • Foliage: every leaf edge against something clearly farther is rimmed, so a canopy against the sky can sparkle. Lower strength, narrow width, or keep foliage out with a group mask.
  • World text: flat words on a sign have no depth step and get no rim; the sign's outer edge does. Free-standing letters can be rimmed on their outer edges. Leave labels out by name: StyleKit.options({ exclude = { "labelName" } }).
  • Black stays black: the rim only adds light where light arrived (it is scaled by the light's presence) and it returns through sk_finish, so with every light off the frame is black.

Known limits

  • It runs on the whole frame after antialiasing, so offscreen captures, mirrors and render-to-texture cameras do not show it (#17427).
  • Per-object settings (a style channel or a game role) reach it through the shared object mask, at most eight distinct settings a scene. A per-object value cannot reach a geometry pass, so a per-object look that needs one draws passes of its own (#24549).
  • Its passes are queued again every frame, even when nothing changed (#24548).

The package README's Known limits lists the rest.