Log inGet started
Package

toonHighlight.styleBlock

README.md

Toon highlight (styleBlock, Light)

A stylized hard highlight: a cut-out glint of sunlight on the round parts and bevelled edges of lit things, on the side that faces the viewer; none on the middle of flat faces, in cast shadow or on the side turned from the sun. For cartoon shine and anime highlights.

Settings: size (0.55), fromView (0.5), bendFrom (0.0015), softness (0.03), strength (0.85), colour (#fffff7), tintByColour (0.15), curvedOnly (1), curveReach (5), litAbove (0.65), fullLight (1), keepLightColour (0.5).

It is a chain block at rank 60: it builds on what the light blocks before it made and lands after a rim light (rank 50). It needs a sun: with no directional light in the scene it draws nothing.

Where the glint goes:

  • Where the shape bends. Depth is read across opposite pairs of taps curveReach pixels and three times that far from the pixel, on the same object. The reciprocal of depth runs exactly straight across any flat surface on screen, at any angle and distance, so only a real bend registers (the threshold is bendFrom): round parts, and the edges of boxes, steps and rims. The middle of a flat face never lights up whole, and fine grain (tiles, grout, planks, the noise in far depth) does not count as shape, which keeps glints from twinkling as the camera moves.
  • Which way it faces. The normals rebuilt from depth on the same object are averaged over the same two rings, so fine detail cancels and a form's own turn is left: on a box's edge the average leans between the two faces (a bevel), on a limb it follows the round. A glint shows where that averaged normal faces the highlight's own light: the sun pulled toward the camera by fromView. At 0 it is the physical mirror point, which under a low or back sun lies on few surfaces the camera can see (a stage lit from behind gets almost nothing); at the default 0.5 it sits on the lit side of a form, facing the viewer, the way a drawn highlight does.
  • Whether the sun reaches it. The surface (or its bevel) has to turn toward the sun, and the light that arrived must not be far below what an open surface at that angle gets (litAbove), which keeps glints out of cast shadow while a low sun's glancing light still carries one.

The glint replaces the colour by strength with colour (taking tintByColour of the surface's colour and keepLightColour of the light's), never darker than what was there.

On the Toon recipe stage at the defaults it draws white glints along the stage's front edge, the stone basin's rim, the crates and the television and on the character's lit side, alone and on top of toonBands. Before 1.0.3 it placed the glint at the exact mirror point and judged roundness from shading, so on that stage (sun low and behind) it drew almost nothing.

What it gives up in motion

A glint slides over a round surface and along an edge as the camera or the sun moves, as a real one does; it is found again every frame, so it stays on its object and follows moving and animated things. The sun's direction reaches the block about once a second, so under a moving sun the glint moves in small steps. An edge's glint is curveReach pixels wide in the picture at any distance, so far edges carry a glint as wide as near ones; lower curveReach for finer edge glints.

How it treats content

  • Opaque things: round parts and edges that face the sun get a hard glint on their viewer-facing side; the middle of flat floors, walls and panels, and things in shadow, get none.
  • Transparent things (glass, water): they write no depth, so glass and water get no highlight of their own from this block (their own material's reflections stay as they are), and rounded things behind a pane can show their highlight through it.
  • Particles and smoke: no depth, so no highlight of their own; bright smoke over a sunlit rounded thing can lift it past litAbove and widen where the blob shows.
  • Sky: never touched.
  • Fog: the glint is laid after fog at full brightness, so far rounded things in thick fog can still catch a bright highlight; fog that dims the light below litAbove turns it off. A depth mask keeps it to the near ground.
  • Skinned characters: heads, shoulders and limbs catch the glint on their lit, viewer-facing side, and it moves over them with every pose.
  • Foliage: grass blades and leaves are real bent shape, so a sunlit patch of foliage catches many small glints that move with it; keep foliage out with a group mask if that is too busy.
  • World text: flat labels get none.
  • Black stays black: it draws only where the sun reaches a lit surface and 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.