refactor(srp): move urp shadow and prepass core blocks into renderer

This commit is contained in:
2026-04-21 16:43:56 +08:00
parent eb5b51ddb1
commit 1cb23cd178
10 changed files with 289 additions and 22 deletions

View File

@@ -0,0 +1,75 @@
# SRP URP Renderer Core Shadow Prepass Plan
Date: 2026-04-21
## Goal
Continue aligning the current managed rendering stack with Unity-style SRP + URP ownership:
- `UniversalRenderer` owns the default shadow and depth-prepass core blocks
- `ScriptableRendererFeature` injects or explicitly overrides stage existence through planning hooks
- standalone stage fallback remains secondary instead of being the primary owner of URP core blocks
This stage does not add deferred rendering.
## Current Problems
The current code still has three architectural gaps:
1. `UniversalRenderer` explicitly owns final output, but shadow and depth-prepass core blocks are still not renderer-owned managed defaults.
2. `ScriptableRenderer.FinalizeCameraFramePlan()` infers standalone stages from the queued pass list without respecting explicit shadow/depth planning decisions, so a feature-level `ClearShadowCasterStage()` can be silently undone later.
3. `UniversalRendererData` still exposes native standalone pass keys for `ShadowCaster` and `DepthOnly`, so the managed renderer core is not yet the obvious primary ownership seam.
## Scope
### 1. Make shadow / depth stage planning explicit
Required work:
- expose explicit standalone-stage planning state to managed code
- skip inferred shadow/depth stage requests when the renderer or a feature has already configured those stages explicitly
- preserve the existing inferred path only for renderers that still rely on implicit standalone-stage discovery
### 2. Move default shadow / depth core passes into `UniversalRenderer`
Required work:
- add default managed `DrawObjectsPass` instances for:
- `ShadowCaster`
- `DepthOnly`
- make `UniversalRenderer` decide whether those blocks exist
- keep shadow stage tied to actual shadow-plan availability
- keep depth prepass opt-in instead of enabling it unconditionally
### 3. Reduce native fallback ownership in URP data
Required work:
- stop treating native standalone asset keys as the primary URP shadow/depth implementation path
- make `UniversalRendererData` describe the renderer-owned default blocks instead
- keep fallback compatibility only where it is still useful during transition
## Out Of Scope
- deferred renderer
- GBuffer
- editor-side renderer configuration UX
- moving every shadow implementation detail out of native code
- multiple URP renderer variants in this stage
## Done Criteria
1. `UniversalRenderer` owns default managed shadow and depth-prepass block composition.
2. Feature-level explicit shadow/depth stage planning is no longer overwritten by generic queue inference.
3. URP shadow/depth defaults no longer depend on `UniversalRendererData.GetCameraFrameStandalonePassAssetKey(...)` as the main ownership seam.
4. Old `XCEditor` builds in Debug.
5. Old editor smoke passes for at least about 10 seconds and a fresh `SceneReady` appears in `editor/bin/Debug/editor.log`.
## Follow-Up
After this stage closes, the next SRP stage can move higher toward Unity-style renderer composition:
- renderer variants / multiple renderer assets
- managed shadow block enrichment
- managed prepass expansion
- eventually, SRP-facing C# pipeline composition with clearer URP package layering