feat(renderer): add sorted transparency and PBR alpha modes #942

Merged
SakulFlee merged 1 commit from feat/renderer-transparency into main 2026-10-26 17:15:09 +00:00
Collaborator

Summary

Stacked on #941. Adds sorted transparent rendering and PBR alpha modes, exercising the material render state from the previous PR.

  • PBR samples alpha from the albedo texture and multiplies by alpha_factor.
  • Opaque: alpha ignored for compositing; depth write on.
  • Mask(cutoff): fragment discard below the cutoff; still opaque queue and depth write.
  • Blend: transparent queue, ALPHA_BLENDING, depth write off, no opaque shadow casting.
  • glTF importer maps OPAQUE / MASK / BLEND and base-color alpha.
  • Renderer adds a transparent graph pass after the opaque model pass:
    • loads color and depth,
    • sorts per-object draws back-to-front using the camera position,
    • draws only RenderQueue::Transparent materials.
  • Camera snapshots now expose world position; models expose an average instance center for sorting.
  • Shadow casting skips models with no shadow-casting materials. Alpha-masked shadow sampling is not implemented yet; mask materials still cast a full opaque shadow.

Verification

  • cargo fmt --all -- --check
  • cargo clippy -p orbital_camera -p orbital_model -p orbital_renderer -p orbital_shader_pbr -p orbital_importer_gltf -p orbital_procgeo -p orbital_app -- -D warnings
  • cargo test -p orbital_camera -p orbital_model -p orbital_renderer -p orbital_shader_pbr -p orbital_importer_gltf -p orbital_procgeo -p orbital_app --no-fail-fast
  • cargo test -p orbital_resources --test wgsl_shaders --no-fail-fast
  • PBR factor-buffer and alpha-mode unit tests pass.
  • All three examples compile.
  • GUI examples were not launched in this environment (no display/GPU).

Refs #872, #781.

## Summary Stacked on #941. Adds sorted transparent rendering and PBR alpha modes, exercising the material render state from the previous PR. - PBR samples alpha from the albedo texture and multiplies by `alpha_factor`. - `Opaque`: alpha ignored for compositing; depth write on. - `Mask(cutoff)`: fragment discard below the cutoff; still opaque queue and depth write. - `Blend`: transparent queue, `ALPHA_BLENDING`, depth write off, no opaque shadow casting. - glTF importer maps `OPAQUE` / `MASK` / `BLEND` and base-color alpha. - Renderer adds a `transparent` graph pass after the opaque model pass: - loads color and depth, - sorts per-object draws back-to-front using the camera position, - draws only `RenderQueue::Transparent` materials. - Camera snapshots now expose world position; models expose an average instance center for sorting. - Shadow casting skips models with no shadow-casting materials. Alpha-masked shadow sampling is not implemented yet; mask materials still cast a full opaque shadow. ## Verification - `cargo fmt --all -- --check` - `cargo clippy -p orbital_camera -p orbital_model -p orbital_renderer -p orbital_shader_pbr -p orbital_importer_gltf -p orbital_procgeo -p orbital_app -- -D warnings` - `cargo test -p orbital_camera -p orbital_model -p orbital_renderer -p orbital_shader_pbr -p orbital_importer_gltf -p orbital_procgeo -p orbital_app --no-fail-fast` - `cargo test -p orbital_resources --test wgsl_shaders --no-fail-fast` - PBR factor-buffer and alpha-mode unit tests pass. - All three examples compile. - GUI examples were not launched in this environment (no display/GPU). Refs #872, #781.
feat(renderer): add sorted transparency and PBR alpha modes
All checks were successful
Lint / lint (pull_request) Successful in 1m56s
PR / test (pull_request) Successful in 4m45s
b54f67fab7
PBR materials now read alpha from the albedo texture and support Opaque, Mask and Blend modes. Mask discards below the descriptor cutoff; Blend selects the transparent queue, alpha blending and depth-write off. The glTF importer maps glTF alpha modes and base-color alpha.

The renderer schedules a transparent pass after opaque geometry, sorts per-object draws back-to-front using the camera position, loads depth without writing it, and skips blended materials in the shadow caster list. Camera and model snapshots now expose position/instance center for sorting.

Smart test results

Result: PASS

Scope: orbital_camera, orbital_importer_gltf, orbital_model, orbital_procgeo, orbital_renderer, orbital_shader_pbr

Reason: directly changed crates

Elapsed: 3m 6s

Workflow run

Overall: 27 tests, 27 passed, 0 failed, 0 skipped

Nextest: 27 tests, 27 passed, 0 failed, 0 skipped
Doctests: no tests reported

Crate Nextest Passed Failed Skipped Doctests Time
orbital_camera 4 4 0 0 - 0.05s
orbital_importer_gltf 13 13 0 0 - 0.20s
orbital_procgeo 2 2 0 0 - 0.02s
orbital_renderer 5 5 0 0 - 0.05s
orbital_shader_pbr 3 3 0 0 - 0.02s
pie showData
    title Nextest outcomes
    "Passed" : 27
xychart-beta
    title "Slowest crates (nextest seconds)"
    x-axis ["orbital_importer_gltf", "orbital_renderer", "orbital_camera", "orbital_shader_pbr", "orbital_procgeo"]
    y-axis "Seconds" 0 --> 1
    bar [0.20, 0.05, 0.05, 0.02, 0.02]
<!-- orbital-ci-test-results --> ## Smart test results **Result:** PASS **Scope:** orbital_camera, orbital_importer_gltf, orbital_model, orbital_procgeo, orbital_renderer, orbital_shader_pbr **Reason:** directly changed crates **Elapsed:** 3m 6s [Workflow run](https://forgejo.sakul-flee.de/SakulFlee/Orbital/actions/runs/664) **Overall:** 27 tests, 27 passed, 0 failed, 0 skipped **Nextest:** 27 tests, 27 passed, 0 failed, 0 skipped **Doctests:** no tests reported | Crate | Nextest | Passed | Failed | Skipped | Doctests | Time | | --- | ---: | ---: | ---: | ---: | ---: | ---: | | orbital_camera | 4 | 4 | 0 | 0 | - | 0.05s | | orbital_importer_gltf | 13 | 13 | 0 | 0 | - | 0.20s | | orbital_procgeo | 2 | 2 | 0 | 0 | - | 0.02s | | orbital_renderer | 5 | 5 | 0 | 0 | - | 0.05s | | orbital_shader_pbr | 3 | 3 | 0 | 0 | - | 0.02s | ```mermaid pie showData title Nextest outcomes "Passed" : 27 ``` ```mermaid xychart-beta title "Slowest crates (nextest seconds)" x-axis ["orbital_importer_gltf", "orbital_renderer", "orbital_camera", "orbital_shader_pbr", "orbital_procgeo"] y-axis "Seconds" 0 --> 1 bar [0.20, 0.05, 0.05, 0.02, 0.02] ```
SakulFlee changed target branch from feat/renderer-material-v2 to main 2026-10-26 17:13:26 +00:00
SakulFlee deleted branch feat/renderer-transparency 2026-10-26 17:15:09 +00:00
Sign in to join this conversation.
No description provided.