Skip to content

Commit

Permalink
feat: saturation slider for ssgi il
Browse files Browse the repository at this point in the history
  • Loading branch information
Pentalimbed committed Dec 11, 2024
1 parent d8ca792 commit 347b818
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ cbuffer SSGICB : register(b1)
float2 DepthFadeRange;
float DepthFadeScaleConst;

float BackfaceStrength;
float GISaturation;
float GIBounceFade;
float GIDistanceCompensation;
float GICompensationMaxDist;
Expand Down
4 changes: 2 additions & 2 deletions features/Screen Space GI/Shaders/ScreenSpaceGI/gi.cs.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ void CalculateGI(
if (dot(samplePos, normalSample) > 0)
normalSample = -normalSample;
float frontBackMult = -dot(normalSample, sampleHorizonVec);
frontBackMult = frontBackMult < 0 ? abs(frontBackMult) * BackfaceStrength : frontBackMult; // backface
frontBackMult = frontBackMult < 0 ? 0.0 : frontBackMult; // backface

if (frontBackMult > 0.f) {
float3 sampleHorizonVecWS = normalize(mul(FrameBuffer::CameraViewInverse[eyeIndex], half4(sampleHorizonVec, 0)).xyz);
Expand Down Expand Up @@ -246,7 +246,7 @@ void CalculateGI(
radianceY *= rcpNumSlices;
radianceY = lerp(radianceY, 0, depthFade);

radianceCoCg *= rcpNumSlices;
radianceCoCg *= rcpNumSlices * GISaturation;
#endif

o_ao = visibility;
Expand Down
14 changes: 4 additions & 10 deletions src/Features/ScreenSpaceGI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
GIRadius,
Thickness,
DepthFadeRange,
BackfaceStrength,
GISaturation,
EnableGIBounce,
GIBounceFade,
GIDistanceCompensation,
Expand Down Expand Up @@ -194,6 +194,8 @@ void ScreenSpaceGI::DrawSettings()
ImGui::Separator();
}

Util::PercentageSlider("IL Saturation", &settings.GISaturation);

recompileFlag |= ImGui::Checkbox("Ambient Bounce", &settings.EnableGIBounce);
if (auto _tt = Util::HoverTooltipWrapper())
ImGui::Text(
Expand All @@ -208,14 +210,6 @@ void ScreenSpaceGI::DrawSettings()
if (auto _tt = Util::HoverTooltipWrapper())
ImGui::Text("How much of this frame's ambient+IL get carried to the next frame as source.");
}

if (showAdvanced) {
ImGui::Separator();

Util::PercentageSlider("Backface Lighting Mix", &settings.BackfaceStrength);
if (auto _tt = Util::HoverTooltipWrapper())
ImGui::Text("How bright at the back of objects is compared to the front. A small value to make up for foliage translucency.");
}
}

///////////////////////////////
Expand Down Expand Up @@ -574,7 +568,7 @@ void ScreenSpaceGI::UpdateSB()
data.DepthFadeRange = settings.DepthFadeRange;
data.DepthFadeScaleConst = 1 / (settings.DepthFadeRange.y - settings.DepthFadeRange.x);

data.BackfaceStrength = settings.BackfaceStrength;
data.GISaturation = settings.GISaturation;
data.GIBounceFade = settings.GIBounceFade;
data.GIDistanceCompensation = settings.GIDistanceCompensation;
data.GICompensationMaxDist = settings.AORadius;
Expand Down
4 changes: 2 additions & 2 deletions src/Features/ScreenSpaceGI.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct ScreenSpaceGI : Feature
float Thickness = 75.f;
float2 DepthFadeRange = { 4e4, 5e4 };
// gi
float BackfaceStrength = 0.f;
float GISaturation = .9f;
bool EnableGIBounce = true;
float GIBounceFade = 1.f;
float GIDistanceCompensation = 0.f;
Expand Down Expand Up @@ -98,7 +98,7 @@ struct ScreenSpaceGI : Feature
float2 DepthFadeRange;
float DepthFadeScaleConst;

float BackfaceStrength; //
float GISaturation; //
float GIBounceFade;
float GIDistanceCompensation;
float GICompensationMaxDist;
Expand Down

0 comments on commit 347b818

Please sign in to comment.