Skip to content

Commit 2656d01

Browse files
authored
Remove barycentrics from Visibility Buffer (#55)
Instead analytically recreate them in the material pass
1 parent d91de55 commit 2656d01

File tree

10 files changed

+247
-195
lines changed

10 files changed

+247
-195
lines changed

Source/Game-Lib/Game-Lib/Rendering/GameRenderer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ void GameRenderer::CreatePermanentResources()
498498
visibilityBufferDesc.debugName = "VisibilityBuffer";
499499
visibilityBufferDesc.dimensions = vec2(1.0f, 1.0f);
500500
visibilityBufferDesc.dimensionType = Renderer::ImageDimensionType::DIMENSION_SCALE_RENDERSIZE;
501-
visibilityBufferDesc.format = Renderer::ImageFormat::R32G32B32A32_UINT;
501+
visibilityBufferDesc.format = Renderer::ImageFormat::R32G32_UINT;
502502
visibilityBufferDesc.sampleCount = Renderer::SampleCount::SAMPLE_COUNT_1;
503503
visibilityBufferDesc.clearUInts = uvec4(0, 0, 0, 0);
504504

Source/Game-Lib/Game-Lib/Rendering/Material/MaterialRenderer.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,15 @@ void MaterialRenderer::AddPreEffectsPass(Renderer::RenderGraph* renderGraph, Ren
101101
commandList.BindDescriptorSet(Renderer::DescriptorSetSlot::MODEL, data.modelSet, frameIndex);
102102
commandList.BindDescriptorSet(Renderer::DescriptorSetSlot::PER_PASS, data.preEffectsSet, frameIndex);
103103

104-
uvec2 outputSize = _renderer->GetImageDimensions(resources.packedNormals, 0);
104+
vec2 outputSize = static_cast<vec2>(_renderer->GetImageDimensions(resources.packedNormals, 0));
105+
106+
struct Constants
107+
{
108+
vec4 renderInfo; // x = Render Width, y = Render Height, z = 1/Width, w = 1/Height
109+
};
110+
111+
Constants* constants = graphResources.FrameNew<Constants>();
112+
constants->renderInfo = vec4(outputSize, 1.0f / outputSize);
105113

106114
uvec2 dispatchSize = uvec2((outputSize.x + 7) / 8, (outputSize.y + 7) / 8);
107115
commandList.Dispatch(dispatchSize.x, dispatchSize.y, 1);
@@ -207,6 +215,7 @@ void MaterialRenderer::AddMaterialPass(Renderer::RenderGraph* renderGraph, Rende
207215

208216
struct Constants
209217
{
218+
vec4 renderInfo; // x = Render Width, y = Render Height, z = 1/Width, w = 1/Height
210219
uvec4 lightInfo; // x = Directional Light Count, Y = Point Light Count, Z = Cascade Count, W = Shadows Enabled
211220
vec4 fogColor;
212221
vec4 fogSettings; // x = Enabled, y = Begin Fog Blend Dist, z = End Fog Blend Dist, w = UNUSED
@@ -221,6 +230,9 @@ void MaterialRenderer::AddMaterialPass(Renderer::RenderGraph* renderGraph, Rende
221230

222231
Constants* constants = graphResources.FrameNew<Constants>();
223232

233+
vec2 outputSize = static_cast<vec2>(_renderer->GetImageDimensions(resources.sceneColor, 0));
234+
constants->renderInfo = vec4(outputSize, 1.0f / outputSize);
235+
224236
CVarSystem* cvarSystem = CVarSystem::Get();
225237
const u32 numCascades = static_cast<u32>(*cvarSystem->GetIntCVar(CVarCategory::Client | CVarCategory::Rendering, "shadowCascadeNum"));
226238
const u32 shadowEnabled = static_cast<u32>(*cvarSystem->GetIntCVar(CVarCategory::Client | CVarCategory::Rendering, "shadowEnabled"));

0 commit comments

Comments
 (0)