Skip to content

Commit

Permalink
GUI overhaul WIP and reduced FSR lod bias for shadows.
Browse files Browse the repository at this point in the history
  • Loading branch information
JuanDiegoMontoya committed Jul 3, 2024
1 parent 251fdc6 commit 9776c07
Show file tree
Hide file tree
Showing 5 changed files with 503 additions and 252 deletions.
27 changes: 19 additions & 8 deletions data/config/defaultLayout.ini
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ DockId=0x0000000C,0
Pos=0,24
Size=335,271
Collapsed=0
DockId=0x0000000D,0
DockId=0x0000000D,1

[Window][###lights_window]
Pos=0,24
Expand Down Expand Up @@ -70,15 +70,15 @@ DockId=0x00000009,0

[Window][Dear ImGui Demo]
Pos=337,24
Size=1233,1056
Size=1233,758
Collapsed=0
DockId=0x0000000F,0
DockId=0x0000000F,1

[Window][ Shadow]
Pos=1572,561
Size=348,202
Pos=1572,381
Size=348,382
Collapsed=0
DockId=0x0000000A,1
DockId=0x0000000A,0

[Window][ Viewer##viewer_window]
Pos=0,297
Expand All @@ -105,6 +105,17 @@ Collapsed=0
DockId=0x0000000E,2

[Window][Scene Graph##scene_graph_window]
Pos=0,24
Size=335,271
Collapsed=0
DockId=0x0000000D,0

[Window][FPS Window]
Pos=342,48
Size=149,44
Collapsed=0

[Window][###component_editor_window]
Pos=0,297
Size=335,404
Collapsed=0
Expand All @@ -114,8 +125,8 @@ DockId=0x0000000E,0
DockSpace ID=0x4BBE4C7A Window=0x4647B76E Pos=0,24 Size=1920,1056 Split=X Selected=0xE87781F4
DockNode ID=0x00000005 Parent=0x4BBE4C7A SizeRef=335,1056 Split=Y Selected=0x6A2E32C2
DockNode ID=0x0000000B Parent=0x00000005 SizeRef=213,677 Split=Y Selected=0x6A2E32C2
DockNode ID=0x0000000D Parent=0x0000000B SizeRef=335,271 Selected=0x30110D95
DockNode ID=0x0000000E Parent=0x0000000B SizeRef=335,404 Selected=0x25BC1AD3
DockNode ID=0x0000000D Parent=0x0000000B SizeRef=335,271 Selected=0xA95BCB0F
DockNode ID=0x0000000E Parent=0x0000000B SizeRef=335,404 Selected=0x67C27239
DockNode ID=0x0000000C Parent=0x00000005 SizeRef=213,377 Selected=0x213C89B5
DockNode ID=0x00000006 Parent=0x4BBE4C7A SizeRef=1583,1056 Split=X
DockNode ID=0x00000001 Parent=0x00000006 SizeRef=1233,1056 Split=Y Selected=0x91EB2F4F
Expand Down
12 changes: 9 additions & 3 deletions src/FrogRenderer2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ FrogRenderer2::FrogRenderer2(const Application::CreateInfo& createInfo)

debugGpuAabbsBuffer = Fvog::Buffer(*device_, {sizeof(Fvog::DrawIndirectCommand) + sizeof(Debug::Aabb) * 100'000}, "Debug GPU AABBs");

debugGpuRectsBuffer = Fvog::Buffer(*device_, {sizeof(Fvog::DrawIndirectCommand) + sizeof(Debug::Rect) * 100'000}, "Deug GPU Rects");
debugGpuRectsBuffer = Fvog::Buffer(*device_, {sizeof(Fvog::DrawIndirectCommand) + sizeof(Debug::Rect) * 100'000}, "Debug GPU Rects");

device_->ImmediateSubmit(
[this](VkCommandBuffer commandBuffer)
Expand Down Expand Up @@ -545,7 +545,8 @@ void FrogRenderer2::OnRender([[maybe_unused]] double dt, VkCommandBuffer command

auto ctx = Fvog::Context(*device_, commandBuffer);

const float fsr2LodBias = fsr2Enable ? log2(float(renderInternalWidth) / float(renderOutputWidth)) - 1.0f : 0.0f;
const auto baseBias = fsr2Enable ? log2(float(renderInternalWidth) / float(renderOutputWidth)) - 1.0f : 0.0f;
const float fsr2LodBias = std::round(baseBias * 100) / 100;

{
ZoneScopedN("Update GPU Buffers");
Expand All @@ -564,7 +565,10 @@ void FrogRenderer2::OnRender([[maybe_unused]] double dt, VkCommandBuffer command

// VSM lod bias corresponds to upscaling lod bias, otherwise shadows become blocky as the upscaling ratio increases.
auto actualVsmUniforms = vsmUniforms;
actualVsmUniforms.lodBias += fsr2LodBias;
if (fsr2Enable)
{
actualVsmUniforms.lodBias += fsr2LodBias + 1.0f; // +1 to cancel "AA" factor and avoid too much negative bias (this should bring shadow detail to approx. pixel-scale)
}
vsmContext.UpdateUniforms(commandBuffer, actualVsmUniforms);
ctx.Barrier();
}
Expand Down Expand Up @@ -730,6 +734,8 @@ void FrogRenderer2::OnRender([[maybe_unused]] double dt, VkCommandBuffer command
}
ctx.EndRendering();

ctx.Barrier();

// VSMs
{
const auto debugMarker = ctx.MakeScopedDebugMarker("Virtual Shadow Maps");
Expand Down
15 changes: 11 additions & 4 deletions src/FrogRenderer2.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "shaders/Resources.h.glsl"
#include "shaders/ShadeDeferredPbr.h.glsl"

#include <variant>

// TODO: these structs should come from shared headers rather than copying them
FVOG_DECLARE_ARGUMENTS(VisbufferPushConstants)
{
Expand Down Expand Up @@ -154,15 +156,13 @@ class FrogRenderer2 final : public Application
void GuiDrawDockspace(VkCommandBuffer commandBuffer);
void GuiDrawFsrWindow(VkCommandBuffer commandBuffer);
void GuiDrawDebugWindow(VkCommandBuffer commandBuffer);
void GuiDrawBloomWindow(VkCommandBuffer commandBuffer);
void GuiDrawAutoExposureWindow(VkCommandBuffer commandBuffer);
void GuiDrawCameraWindow(VkCommandBuffer commandBuffer);
void GuiDrawShadowWindow(VkCommandBuffer commandBuffer);
void GuiDrawViewer(VkCommandBuffer commandBuffer);
void GuiDrawMaterialsArray(VkCommandBuffer commandBuffer);
void GuiDrawPerfWindow(VkCommandBuffer commandBuffer);
void GuiDrawSceneGraph(VkCommandBuffer commandBuffer);
void GuiDrawSceneGraphHelper(Utility::Node* node);
void GuiDrawComponentEditor(VkCommandBuffer commandBuffer);

void CullMeshletsForView(VkCommandBuffer commandBuffer, const ViewParams& view, Fvog::Buffer& visibleMeshletIds, std::string_view name = "Cull Meshlet Pass");
void MakeStaticSceneBuffers(VkCommandBuffer commandBuffer);
Expand Down Expand Up @@ -665,5 +665,12 @@ class FrogRenderer2 final : public Application
ScrollingBuffer<double> accumTimes;
double accumTime = 0;

bool showGui = true;
// GUI
bool showGui = true;
bool showFpsInfo = true;
bool showSceneInfo = false;
struct CameraSelected{};
struct AtmosphereSelected{};
using SelectedThingyType = std::variant<std::monostate, CameraSelected, AtmosphereSelected, Utility::Node*>;
SelectedThingyType selectedThingy = std::monostate{};
};
Loading

0 comments on commit 9776c07

Please sign in to comment.