Phase 5 updates

Phase 5 · Slice 17 ·

2D shadows and normal maps

  • ShadowCaster2D casts: its outline (a shape path; a sprite renderer's bounds, where Unity's editor takes the sprite's own outline; or, as Unity falls back, its renderer's bounds or a unit square, stored as the path) reaches the renderer each frame with its target sorting layers and casting option (castsShadows and selfShadows map onto it as Unity's do).
  • The 2D lit shading dims a light by its shadow intensity where a caster's outline crosses the segment from the light to the pixel; a renderer's own caster shadows it only with self shadows. Shadows are hard-edged.
  • Normal maps: a light with normal map quality on is placed its normal map distance in front of the sprite's plane and scaled by saturate(N · L), as URP's normals lighting does; N comes from the sprite's _NormalMap secondary texture or its material's _NormalMap (flat facing the camera without one).
  • Sprites carry secondary textures (SecondarySpriteTexture, Sprite.Create with them, GetSecondaryTextures), imported from a texture's sprite settings.
  • The lights_2d scenario grows: light shadow settings, a caster's defaults, square path and casting options, secondary textures, and in its Unity scene a self-shadowing caster, a light with normal maps on and a sprite whose texture brings its normal map. 41 scenarios pass in both runs.
  • GPU tests cover shadowed and unshadowed pixels, self shadows and flat-normal falloff; an MCP e2e test covers a caster darkening the sprite behind it.
  • Not yet: soft shadows, sprite outlines as shadow shapes, Sprite (cookie) lights, volumetric light and shadows.
  • Next: agent avoidance and off-mesh links, or Sprite (cookie) lights and soft shadows.