feat(renderer): add G-buffer pass and deferred lighting #944

Merged
SakulFlee merged 1 commit from feat/renderer-deferred into main 2026-10-26 18:34:37 +00:00
Collaborator

Summary

Phase 4b: the renderer now has a hybrid G-buffer/deferred path.

  • PBR materials build a three-target G-buffer pipeline next to their forward pipeline.
    • @location(0) albedo + AO (Rgba8Unorm)
    • @location(1) normal + roughness (Rgba16Float)
    • @location(2) metallic + emissive (Rgba16Float)
  • Opaque PBR models render into the G-buffer. Custom/forward-only opaque materials and all transparent materials stay on the forward path.
  • A fullscreen deferred lighting pass reconstructs world position from depth, rebuilds PBRData, and runs the same IBL, punctual-light and shadow functions used by forward PBR.
  • The frame graph decides per frame between:
    • shadow -> prepare-world -> sky -> gbuffer -> deferred-lighting -> [forward opaque] -> [transparent] -> tonemap
    • shadow -> prepare-world -> sky -> clear-depth -> forward opaque -> [transparent] -> tonemap
  • Depth is cleared by the G-buffer pass when deferred is active, or by a dedicated depth-clear pass when it is not.
  • The assembled deferred lighting shader is validated with naga; graph tests cover forward-only, deferred-only, hybrid and transparency-only combinations.

Tiled/clustered light culling is the next stacked PR. Until then the deferred pass loops the same light store as forward.

Verification

  • cargo fmt --all -- --check
  • cargo clippy for the touched crates and all three example templates with --all-targets -D warnings
  • cargo test for orbital_material_shader, orbital_shader_pbr, orbital_model, orbital_renderer, orbital_resources
  • 22 naga WGSL tests pass, including forward PBR, G-buffer PBR and deferred lighting
  • cargo check for the facade, app and all three example templates
  • GUI examples were not launched in this environment (no display/GPU)

Stacked on #943.

Refs #781.

## Summary Phase 4b: the renderer now has a hybrid G-buffer/deferred path. - PBR materials build a three-target G-buffer pipeline next to their forward pipeline. - `@location(0)` albedo + AO (`Rgba8Unorm`) - `@location(1)` normal + roughness (`Rgba16Float`) - `@location(2)` metallic + emissive (`Rgba16Float`) - Opaque PBR models render into the G-buffer. Custom/forward-only opaque materials and all transparent materials stay on the forward path. - A fullscreen deferred lighting pass reconstructs world position from depth, rebuilds `PBRData`, and runs the same IBL, punctual-light and shadow functions used by forward PBR. - The frame graph decides per frame between: - `shadow -> prepare-world -> sky -> gbuffer -> deferred-lighting -> [forward opaque] -> [transparent] -> tonemap` - `shadow -> prepare-world -> sky -> clear-depth -> forward opaque -> [transparent] -> tonemap` - Depth is cleared by the G-buffer pass when deferred is active, or by a dedicated depth-clear pass when it is not. - The assembled deferred lighting shader is validated with naga; graph tests cover forward-only, deferred-only, hybrid and transparency-only combinations. Tiled/clustered light culling is the next stacked PR. Until then the deferred pass loops the same light store as forward. ## Verification - `cargo fmt --all -- --check` - `cargo clippy` for the touched crates and all three example templates with `--all-targets -D warnings` - `cargo test` for `orbital_material_shader`, `orbital_shader_pbr`, `orbital_model`, `orbital_renderer`, `orbital_resources` - 22 naga WGSL tests pass, including forward PBR, G-buffer PBR and deferred lighting - `cargo check` for the facade, app and all three example templates - GUI examples were not launched in this environment (no display/GPU) Stacked on #943. Refs #781.
feat(renderer): add G-buffer pass and deferred lighting
All checks were successful
Lint / lint (pull_request) Successful in 1m8s
Templates / templates (pull_request) Successful in 4m34s
PR / test (pull_request) Successful in 7m38s
8169724dc2
PBR materials now build a three-target G-buffer pipeline in addition to their forward pipeline. Opaque PBR models render into albedo+AO, normal+roughness and metallic+emissive targets; the forward pass keeps custom and forward-only materials, and transparent materials stay sorted in the forward path.

Add a fullscreen deferred lighting pipeline that reconstructs world position and PBR data from the G-buffer, then runs the same IBL, punctual-light and shadow functions as the forward shader. The frame graph schedules shadow, sky, G-buffer, deferred lighting, forward opaque and transparent passes conditionally, with a depth-clear pass when no deferred material is present.

Validate the assembled deferred shader with naga and cover the new graph combinations.

Smart test results

Result: PASS

Scope: full workspace

Reason: workspace-level change: Cargo.lock

Elapsed: 6m 30s

Workflow run

Overall: 448 tests, 438 passed, 0 failed, 10 skipped

Nextest: 437 tests, 437 passed, 0 failed, 0 skipped
Doctests: 11 tests, 1 passed, 0 failed, 10 skipped

Outcome charts are split between nextest and doctests. The timing chart covers nextest only.

Crate Nextest Passed Failed Skipped Doctests Time
orbital 1 1 0 0 - 0.77s
orbital_2d 29 29 0 0 0/1 0.21s
orbital_app 10 10 0 0 0/1 0.08s
orbital_camera 4 4 0 0 - 0.03s
orbital_core 2 2 0 0 - 0.01s
orbital_debug_render 0 0 0 0 0/1 0.00s
orbital_debug_ui 45 45 0 0 0/1 0.40s
orbital_ecs 114 114 0 0 0/2 0.96s
orbital_ecs_bridge 39 39 0 0 - 0.33s
orbital_file_manager 5 5 0 0 - 0.09s
orbital_iced 25 25 0 0 - 0.26s
orbital_importer_gltf 13 13 0 0 - 0.20s
orbital_input 11 11 0 0 - 0.09s
orbital_light 6 6 0 0 - 0.04s
orbital_macros 0 0 0 0 0/1 0.00s
orbital_material_shader 2 2 0 0 - 0.01s
orbital_math 4 4 0 0 - 0.03s
orbital_procgeo 2 2 0 0 - 0.02s
orbital_render_graph 6 6 0 0 - 0.04s
orbital_renderer 7 7 0 0 - 0.05s
orbital_resources 22 22 0 0 - 0.36s
orbital_shader_core 0 0 0 0 1/1 0.00s
orbital_shader_pbr 4 4 0 0 - 0.03s
orbital_shader_preprocessor 12 12 0 0 - 0.10s
orbital_shadow 3 3 0 0 - 0.03s
orbital_text 14 14 0 0 0/1 0.55s
orbital_texture 11 11 0 0 - 0.10s
orbital_touch_ui 1 1 0 0 0/1 0.01s
orbital_ui 32 32 0 0 0/1 0.30s
orbital_world_environment 13 13 0 0 - 0.12s
pie showData
    title Nextest outcomes
    "Passed" : 437
pie showData
    title Doctest outcomes
    "Passed" : 1
    "Skipped" : 10
xychart-beta
    title "Slowest crates (nextest seconds)"
    x-axis ["orbital_ecs", "orbital", "orbital_text", "orbital_debug_ui", "orbital_resources", "orbital_ecs_bridge", "orbital_ui", "orbital_iced"]
    y-axis "Seconds" 0 --> 1
    bar [0.96, 0.77, 0.55, 0.40, 0.36, 0.33, 0.30, 0.26]
<!-- orbital-ci-test-results --> ## Smart test results **Result:** PASS **Scope:** full workspace **Reason:** workspace-level change: Cargo.lock **Elapsed:** 6m 30s [Workflow run](https://forgejo.sakul-flee.de/SakulFlee/Orbital/actions/runs/672) **Overall:** 448 tests, 438 passed, 0 failed, 10 skipped **Nextest:** 437 tests, 437 passed, 0 failed, 0 skipped **Doctests:** 11 tests, 1 passed, 0 failed, 10 skipped _Outcome charts are split between nextest and doctests. The timing chart covers nextest only._ | Crate | Nextest | Passed | Failed | Skipped | Doctests | Time | | --- | ---: | ---: | ---: | ---: | ---: | ---: | | orbital | 1 | 1 | 0 | 0 | - | 0.77s | | orbital_2d | 29 | 29 | 0 | 0 | 0/1 | 0.21s | | orbital_app | 10 | 10 | 0 | 0 | 0/1 | 0.08s | | orbital_camera | 4 | 4 | 0 | 0 | - | 0.03s | | orbital_core | 2 | 2 | 0 | 0 | - | 0.01s | | orbital_debug_render | 0 | 0 | 0 | 0 | 0/1 | 0.00s | | orbital_debug_ui | 45 | 45 | 0 | 0 | 0/1 | 0.40s | | orbital_ecs | 114 | 114 | 0 | 0 | 0/2 | 0.96s | | orbital_ecs_bridge | 39 | 39 | 0 | 0 | - | 0.33s | | orbital_file_manager | 5 | 5 | 0 | 0 | - | 0.09s | | orbital_iced | 25 | 25 | 0 | 0 | - | 0.26s | | orbital_importer_gltf | 13 | 13 | 0 | 0 | - | 0.20s | | orbital_input | 11 | 11 | 0 | 0 | - | 0.09s | | orbital_light | 6 | 6 | 0 | 0 | - | 0.04s | | orbital_macros | 0 | 0 | 0 | 0 | 0/1 | 0.00s | | orbital_material_shader | 2 | 2 | 0 | 0 | - | 0.01s | | orbital_math | 4 | 4 | 0 | 0 | - | 0.03s | | orbital_procgeo | 2 | 2 | 0 | 0 | - | 0.02s | | orbital_render_graph | 6 | 6 | 0 | 0 | - | 0.04s | | orbital_renderer | 7 | 7 | 0 | 0 | - | 0.05s | | orbital_resources | 22 | 22 | 0 | 0 | - | 0.36s | | orbital_shader_core | 0 | 0 | 0 | 0 | 1/1 | 0.00s | | orbital_shader_pbr | 4 | 4 | 0 | 0 | - | 0.03s | | orbital_shader_preprocessor | 12 | 12 | 0 | 0 | - | 0.10s | | orbital_shadow | 3 | 3 | 0 | 0 | - | 0.03s | | orbital_text | 14 | 14 | 0 | 0 | 0/1 | 0.55s | | orbital_texture | 11 | 11 | 0 | 0 | - | 0.10s | | orbital_touch_ui | 1 | 1 | 0 | 0 | 0/1 | 0.01s | | orbital_ui | 32 | 32 | 0 | 0 | 0/1 | 0.30s | | orbital_world_environment | 13 | 13 | 0 | 0 | - | 0.12s | ```mermaid pie showData title Nextest outcomes "Passed" : 437 ``` ```mermaid pie showData title Doctest outcomes "Passed" : 1 "Skipped" : 10 ``` ```mermaid xychart-beta title "Slowest crates (nextest seconds)" x-axis ["orbital_ecs", "orbital", "orbital_text", "orbital_debug_ui", "orbital_resources", "orbital_ecs_bridge", "orbital_ui", "orbital_iced"] y-axis "Seconds" 0 --> 1 bar [0.96, 0.77, 0.55, 0.40, 0.36, 0.33, 0.30, 0.26] ```
SakulFlee changed target branch from feat/renderer-phase-4 to main 2026-10-26 18:33:47 +00:00
SakulFlee deleted branch feat/renderer-deferred 2026-10-26 18:34:40 +00:00
Sign in to join this conversation.
No description provided.