Skip to content

Draw the skybox in a deferred subpass (fixes #162) - #222

Merged
BenjaFriend merged 2 commits into
mainfrom
feature/skybox-subpass
Oct 29, 2026
Merged

BenjaFriend merged 2 commits into
mainfrom
feature/skybox-subpass

Conversation

@BenjaFriend

Copy link
Copy Markdown
Member

Fixes #162.

What this does

  • Cubemap is a normal resource now. Cubemap::Create("Textures/Skybox/Garden"_hs) loads posx/negx/posy/negy/posz/negz (png, jpg, jpeg, tga or bmp) from one folder into a cube image with 6 layers. It replaces the old class that took ten arguments and was not used. All faces must be square and the same size; if not, it logs an error and makes no GPU objects. It makes no GPU objects under --null-render.
  • New SkyboxSubpass. It draws one full screen triangle with no vertex buffer and no depth test. The fragment shader makes a view ray from inverse(projection * view rotation) and samples the cube map. It runs in the deferred pipeline before GeometrySubpass, and it rebuilds its pipeline when the swap chain is resized.
  • deferred.frag discards pixels that have no geometry (G-buffer position.a == 0), so the sky shows through. Without a skybox, those pixels show the black clear color, which looks the same as before.
  • Turning it on: the CUBEMAP pipeline flag adds the skybox to the deferred pipeline, and Engine.cpp sets it. The new [Graphics] Skybox value in EngineConf.ini selects the folder (default Textures/Skybox/Garden). Leave it empty for no skybox.
  • Smaller changes:
    • Added vkCmdDraw to VulkanFunctions.inl.
    • The RenderPipeline descriptor pool now allows swap images × subpasses sets. Before, GeometrySubpass used all of them.
    • Removed UboSkyboxVS.
    • Recompiled skybox.vert/frag.spv and deferred_frag.spv.
    • Credited the Humus Garden skybox (CC BY 3.0) in THIRD_PARTY_NOTICES.md.

Testing

  • Builds with Clang (Debug). All 73 CTest tests pass. check_comment_style.py passes.
  • Sandbox --null-render --unattended --frames 120 --seed 1 exits 0.
  • A windowed GPU run of 120 frames (non-shipping build) exits 0 and logs that the skybox was added. The validation layers were not installed on the test machine, so this run did not use them.
  • Not checked: what it looks like on screen (screen capture did not work under Wayland). Please check which way up the sky is, whether the faces are in the correct places, and the brightness. The sky does not go through the scene's tonemap or gamma.

Not in this PR

  • .hdr and equirectangular cube maps for IBL. Converting them needs its own render or compute pass. This fits with the reflections work.

🤖 Generated with Claude Code

BenjaFriend and others added 2 commits October 25, 2026 09:47
Cubemap is now a resource loaded from one folder with posx..negz faces,
in place of the old ten-argument class that was not used. SkyboxSubpass
draws a full screen triangle before the deferred composite, and the
composite discards pixels that have no geometry. The [Graphics] Skybox
config value selects the folder.

Fixes #162

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	Assets/Shaders/Deferred/deferred_frag.spv
#	Assets/Shaders/skybox/skybox.frag.spv
#	Assets/Shaders/skybox/skybox.vert.spv
#	FlingEngine/Graphics/src/VulkanApp.cpp
@BenjaFriend
BenjaFriend merged commit a6076ab into main Oct 29, 2026
12 checks passed
@BenjaFriend
BenjaFriend deleted the feature/skybox-subpass branch October 29, 2026 01:55
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.

Fix skybox Cubemaps

1 participant