t1k:unity:rendering:shadow-optimization
| Field | Value |
|---|---|
| Module | rendering |
| Version | 5.39.1 |
| Effort | high |
| Tools | — |
Keywords: optimization, rendering, shadows
How to invoke
Section titled “How to invoke”/t1k:unity:rendering:shadow-optimizationUnity Shadow Optimization Skill
Section titled “Unity Shadow Optimization Skill”Triggers
Section titled “Triggers”- shadow, shadow map, shadow resolution, cascade, soft shadows
- light probe, light probe group, probe placement
- baked indirect, mixed lighting, lightmap bake
- shadow acne, shadow bias, shadow distance
- ShadowCastingMode, shadow casting
URP Shadow Settings Reference
Section titled “URP Shadow Settings Reference”Key YAML Fields (UniversalRP.asset)
Section titled “Key YAML Fields (UniversalRP.asset)”m_MainLightShadowmapResolution: 1024 # 256/512/1024/2048/4096m_ShadowDistance: 30 # Max shadow render distance (meters)m_ShadowCascadeCount: 2 # 1-4 cascadesm_Cascade2Split: 0.3 # % of distance for near cascadem_SoftShadowsSupported: 1 # 0=off, 1=onm_SoftShadowQuality: 2 # 0=Low, 1=Medium, 2=Highm_ShadowDepthBias: 2 # Reduce shadow acne (1-3)m_ShadowNormalBias: 2 # Reduce shadow acne (1-3)Recommended Settings by Arena Size
Section titled “Recommended Settings by Arena Size”| Arena | Resolution | Distance | Cascades | Split |
|---|---|---|---|---|
| Small (20×20) | 512 | 20 | 1 | — |
| Medium (40×40) | 1024 | 30 | 2 | 0.3 |
| Large (80×80) | 2048 | 50 | 3 | 0.1/0.3 |
| Open world | 4096 | 100+ | 4 | 0.067/0.2/0.467 |
See also. This table is keyed by arena size;
t1k:unity:optimize:assets’sbudgets.urp.shadowmapRes/budgets.urp.cascadesare keyed by device tier instead (sourced fromt1k-unity-mobile-core/SKILL.md) — a different axis, not a duplicate of this one.
Cascade Strategy
Section titled “Cascade Strategy”- 1 cascade: Uniform texel density — ok for small arenas
- 2 cascades: Near cascade (30% distance) gets 4× texel density — best for fixed-camera arenas
- 3-4 cascades: Needed for large worlds with close-up + distant shadows
Per-Entity Shadow Control
Section titled “Per-Entity Shadow Control”ShadowCastingMode Options
Section titled “ShadowCastingMode Options”renderer.shadowCastingMode = ShadowCastingMode.Off; // No shadowrenderer.shadowCastingMode = ShadowCastingMode.On; // Normal shadowrenderer.shadowCastingMode = ShadowCastingMode.TwoSided; // Both faces castrenderer.shadowCastingMode = ShadowCastingMode.ShadowsOnly; // Invisible, shadow onlyShadow Policy Table
Section titled “Shadow Policy Table”| Entity Type | Shadow | Reason |
|---|---|---|
| Units (characters) | ON | Visual grounding |
| Trees/obstacles | ON | Environment grounding |
| Boundary walls | ON | Arena structure |
| Terrain | Receive only | Ground plane |
| Arrows/projectiles | OFF | Too fast, invisible |
| AOE/VFX (transparent) | OFF | No meaningful shadow |
| Particles | OFF | Performance waste |
| UI elements | OFF | 2D overlay |
Light Probes for DOTS
Section titled “Light Probes for DOTS”Placement Pattern (Grid)
Section titled “Placement Pattern (Grid)”const float probeSpacing = 2f; // 2m gridconst float groundOffset = 0.5f; // Near groundconst float upperHeight = 3f; // Captures tree canopy shadows
// 2-layer grid: ground + upperfor (z) for (x) { positions.Add(new Vector3(px, groundOffset, pz)); positions.Add(new Vector3(px, upperHeight, pz));}Probe Count Estimation
Section titled “Probe Count Estimation”(ArenaWidth/spacing + 1) × (ArenaDepth/spacing + 1) × 2 layers- 40×40 arena, 2m spacing → 21×21×2 = 882 probes
DOTS Compatibility
Section titled “DOTS Compatibility”- Entities Graphics auto-samples light probes — NO extra components needed
- Probes must be in main scene (not SubScene)
- Zero runtime cost — probes are baked SH coefficients
Mixed Lighting (Baked Indirect)
Section titled “Mixed Lighting (Baked Indirect)”- Directional Light →
lightmapBakeType = LightmapBakeType.Mixed - URP Asset →
m_MixedLightingSupported: 1(default) - Static flags on all arena objects (
isStatic = true) - Window → Rendering → Lighting → “Generate Lighting” (manual bake)
How It Works
Section titled “How It Works”- Realtime shadows for ALL objects (static + dynamic)
- Baked indirect bounce for static geometry only
- Units auto-sample light probes for ambient variation
Hard rules
Section titled “Hard rules”- Shadowmask NOT supported by Entities Graphics — use Baked Indirect only
- SubScene = 1 lightmap per SubScene — ok for single SubScene
- Auto-generate lighting DISABLED with Entities Graphics installed — must bake manually
- GPU Resident Drawer “OnDemand” shadow bug — use “EveryFrame” mode if shadows flicker (note: invisible entities are more likely ChunkWorldRenderBounds NaN corruption — see #9)
- Bias too low → shadow acne (striping). Bias too high → peter-panning (shadows detach)
- Shadow distance > arena diagonal wastes texels on empty space
- Soft shadows add ~0.1ms GPU cost — negligible on modern GPUs
- Forward+ has no GBuffer pass — affects impostor baking, not shadows
→ See references/shadow-safety-guide.md for Safe vs Unsafe shadow change table, CRITICAL lighting corruption gotchas, and Rendering Debugger workflow.
Visual change notice
Section titled “Visual change notice”A visible change made with this skill (UI, sprites, 3D, shaders, VFX, animation, lighting, scene layout; audio excluded) follows core rule visual-change-discord-notice:
- Capture OLD before the first edit and NEW after the last (screen:
ScreenCapturein Play mode pert1k-unity-editor-cli, windowed or Xvfb only because rendering is needed; 3D, shader, VFX: same-scene frame grab; 2D asset: the file). - Return the paths and a draft Discord post to the orchestrator, which posts; the PR links the post or carries
visual-notice-waiver: <reason>. Logic only: “no visible change”. No capture: “screenshots pending:”, never a fake image.