Skip to content

Integrate SSAO into deferred Vulkan pipeline#1

Merged
jackthepunished merged 6 commits intomasterfrom
feature/ssao-checklist-fixes
Mar 21, 2026
Merged

Integrate SSAO into deferred Vulkan pipeline#1
jackthepunished merged 6 commits intomasterfrom
feature/ssao-checklist-fixes

Conversation

@jackthepunished
Copy link
Copy Markdown
Owner

@jackthepunished jackthepunished commented Mar 21, 2026

Summary

  • Remove duplicate SSAO execution and run it once in the dedicated pass stage.
  • Wire SSAO blur output into deferred lighting, including descriptor layout/binding updates and ambient modulation in vk_lighting.frag.
  • Stabilize SSAO internals (octa normal decode, depth reconstruction, noise upload, persistent samplers, and explicit texture state tracking) and clean small deferred pass leftovers.

Test plan

  • cmake --build build --target horizon_game
  • cmake --build build
  • Launch build/bin/horizon_game.exe for smoke verification
  • ctest --test-dir build --output-on-failure (74/76 pass; existing failures: ShaderCompiler reports syntax errors, LinearArena basic operations)

Summary by CodeRabbit

  • New Features

    • Screen Space Ambient Occlusion (SSAO) is now fully integrated into the deferred rendering pipeline.
    • Added configurable SSAO settings to control ambient occlusion intensity and quality.
  • Improvements

    • Enhanced ambient lighting calculations for more realistic shadowing effects.

Run SSAO only in the dedicated render stage to prevent redundant work and keep the deferred pass order deterministic.

Made-with: Cursor
Bind the SSAO blur texture in the GBuffer input set and apply it to ambient lighting so the SSAO pass affects final shading.

Made-with: Cursor
Decode octahedral normals explicitly and use consistent Vulkan clip-space reconstruction so SSAO sampling behaves deterministically.

Made-with: Cursor
Replace the placeholder noise upload with a real GPU texture upload path so SSAO sampling has valid per-pixel noise input.

Made-with: Cursor
Keep SSAO samplers alive across frames and track raw/blur texture resource states explicitly to avoid descriptor and layout validation hazards.

Made-with: Cursor
Remove stale implementation comments and redundant shadow UBO upload so the frame pass logic stays concise and predictable.

Made-with: Cursor
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 21, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5b72e98d-8a81-4329-86be-64ec8b6d751b

📥 Commits

Reviewing files that changed from the base of the PR and between a505934 and d0e2415.

📒 Files selected for processing (4)
  • assets/shaders/deferred/vk_lighting.frag
  • assets/shaders/ssao.frag
  • engine/renderer/deferred_renderer.cpp
  • engine/renderer/deferred_renderer.hpp

📝 Walkthrough

Walkthrough

The PR refactors the SSAO (Screen Space Ambient Occlusion) implementation to use GLSL 450 descriptor-set bindings and structured uniform blocks, adds octahedral normal decoding, modularizes kernel sampling parameters, integrates SSAO output into deferred lighting, and implements resource state tracking with explicit texture barriers in the renderer.

Changes

Cohort / File(s) Summary
SSAO Shader Modernization
assets/shaders/ssao.frag
Upgraded to GLSL 450, migrated from legacy uniforms to descriptor-set-based bindings and uniform blocks (CameraData, SSAOKernel, SSAOParams). Changed normal decoding from RGB sampling to octahedral .rg decoding. Refactored kernel sampling loop with dynamic kernel_size clamping (1..64), depth delta epsilon handling, and final occlusion power computation (pow(clamp(ao), u_params.power)). Removed standalone uniform declarations for matrices, noise scale, radius, bias, and kernel.
SSAO Lighting Integration
assets/shaders/deferred/vk_lighting.frag
Added SSAO texture sampler binding (set=1, binding=5) and integrated SSAO sampling into ambient lighting path, modulating the computed ambient term by SSAO red channel at v_TexCoord.
Deferred Renderer Implementation
engine/renderer/deferred_renderer.cpp
Implemented SSAO noise texture initialization via device.update_texture(), refactored sampler management into persistent noise_sampler and blur_sampler members, disabled blending for SSAO pipelines, introduced explicit resource state tracking (raw_state, blur_state) with texture barriers, changed parameter updates to use internal SSAOParams struct, and updated GBuffer descriptor set to bind SSAO blur texture at binding 5.
Deferred Renderer Interface
engine/renderer/deferred_renderer.hpp
Added public types SSAOConfig and SSAOPass, introduced execute_ssao_pass() method, added set_ssao_config() and get_ssao_config() configuration API, and added get_ssr_pass() accessor. Integrated SSAO pass as private member m_ssao.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 In descriptor sets, I hop with glee,
Octahedral normals dance wild and free,
SSAO's glow dims the shadows deep,
With power and bias, the rabbits leap!
State tracking true, no barrier's lost—
Deferred dreams rendered at minimal cost!

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/ssao-checklist-fixes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can generate a title for your PR based on the changes.

Add @coderabbitai placeholder anywhere in the title of your PR and CodeRabbit will replace it with a title based on the changes in the PR. You can change the placeholder by changing the reviews.auto_title_placeholder setting.

@jackthepunished jackthepunished merged commit 9fcf393 into master Mar 21, 2026
0 of 3 checks passed
@jackthepunished jackthepunished deleted the feature/ssao-checklist-fixes branch March 21, 2026 02:15
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots
B Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

1 participant