Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: save screen space shadows enable setting #110

Merged
merged 1 commit into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ cbuffer PerFrame : register(b0)
float NearHardness;
float BlurRadius;
float BlurDropoff;
bool Enabled;
};

float GetDepth(float2 uv)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ cbuffer PerFrame : register(b0)
float NearHardness;
float BlurRadius;
float BlurDropoff;
bool Enabled;
};

bool IsSaturated(float value) { return value == saturate(value); }
Expand Down
9 changes: 5 additions & 4 deletions src/Features/ScreenSpaceShadows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
NearThickness,
NearHardness,
BlurRadius,
BlurDropoff)
BlurDropoff,
Enabled)

void ScreenSpaceShadows::DrawSettings()
{
if (ImGui::TreeNodeEx("General", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::Checkbox("Enable Screen-Space Shadows", &enabled);
ImGui::Checkbox("Enable Screen-Space Shadows", &settings.Enabled);
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip();
ImGui::PushTextWrapPos(ImGui::GetFontSize() * 35.0f);
Expand Down Expand Up @@ -298,7 +299,7 @@ void ScreenSpaceShadows::ModifyLighting(const RE::BSShader*, const uint32_t)
if (shadowState->GetRuntimeData().cubeMapRenderTarget == RE::RENDER_TARGETS_CUBEMAP::kREFLECTIONS) {
enableSSS = false;

} else if (!renderedScreenCamera && enabled) {
} else if (!renderedScreenCamera && settings.Enabled) {
renderedScreenCamera = true;

// Backup the game state
Expand Down Expand Up @@ -448,7 +449,7 @@ void ScreenSpaceShadows::ModifyLighting(const RE::BSShader*, const uint32_t)
}

PerPass data{};
data.EnableSSS = enableSSS && shadowState->GetRuntimeData().rasterStateCullMode <= 1 && enabled;
data.EnableSSS = enableSSS && shadowState->GetRuntimeData().rasterStateCullMode <= 1 && settings.Enabled;
perPass->Update(data);

if (renderedScreenCamera) {
Expand Down
3 changes: 1 addition & 2 deletions src/Features/ScreenSpaceShadows.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct ScreenSpaceShadows : Feature
float NearHardness = 32.0f;
float BlurRadius = 0.5f;
float BlurDropoff = 0.005f;
bool Enabled = true;
};

struct alignas(16) PerPass
Expand All @@ -50,8 +51,6 @@ struct ScreenSpaceShadows : Feature

ConstantBuffer* perPass = nullptr;

bool enabled = true;

ID3D11SamplerState* computeSampler = nullptr;

Texture2D* screenSpaceShadowsTexture = nullptr;
Expand Down