Skip to content

feat(render): Screen-space decal system decoupled from forward/deferred pipelines#76

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/design-decal-system
Draft

feat(render): Screen-space decal system decoupled from forward/deferred pipelines#76
Copilot wants to merge 2 commits intomainfrom
copilot/design-decal-system

Conversation

Copy link

Copilot AI commented Mar 8, 2026

Adds a screen-space decal system designed to be pipeline-agnostic — it works after any opaque pass (forward, deferred, MSAA) by reading only a depth buffer and a color render target.

Architecture

render/core — pipeline-agnostic layer

  • DecalFeatureProcessor — manages up to 16 DecalInstance objects; uploads a DecalPassInfo UBO (DECAL_PASS_INFO) to the render graph each frame via Render()
  • DecalInstance — stores per-decal OBB (world-to-local matrix), RGBA tint color, and blend factor

render/adaptor — pipeline-specific layer

  • DecalPass (extends FullScreenPass) — color and depth resource names are injected at construction, so the pass can be wired to any opaque pass's outputs without modification
  • DecalComponent — actor component; creates/destroys DecalInstance via the feature processor, updates the OBB matrix on transform change

Shader (assets/shaders/decal.hlsl)

Full-screen triangle → sample depth → reconstruct world position via InvViewProj → per-decal OBB test (unit-cube in local space) → alpha-blend with painter's algorithm:

float4 localPos = mul(Decals[i].WorldToDecal, float4(worldPos, 1.0));
if (all(abs(localPos.xyz) <= 0.5)) {
    float blend = Decals[i].DecalColor.a * Decals[i].Params.x;
    outColor = lerp(outColor, float4(Decals[i].DecalColor.rgb, 1.0), blend);
}

Pipeline integration (DefaultForwardPipeline)

DecalPass is inserted between the forward pass and post-processing. It uses LoadOp::LOAD + alpha blending to composite onto ForwardColor in-place — no extra buffer, no change to post-processing. When no DecalFeatureProcessor is registered, DecalPass::Setup() is a no-op.

Supporting changes

  • SceneViewInfo / HLSL ViewInfo extended with InvViewProj (precomputed in SceneView::Update()) — useful for any depth-reconstruction effect beyond decals
  • decal.tech: alpha blending, no depth write, no face culling
  • DecalFeatureProcessor and DecalComponent registered in RenderModule

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…ipelines

Co-authored-by: bluesky013 <35895395+bluesky013@users.noreply.github.com>
Copilot AI changed the title [WIP] Design decal system with decoupled forward and deferred rendering feat(render): Screen-space decal system decoupled from forward/deferred pipelines Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants