Skip to content
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 @@ -90,7 +90,8 @@ float3 GetSamplingVector(uint3 ThreadID, in RWTexture2DArray<float4> OutputTextu
}

#if defined(REFLECTIONS)
color.rgb = lerp(color.rgb, Color::IrradianceToLinear(ReflectionsTexture.SampleLevel(LinearSampler, uv, 0.0).rgb), saturate(mipLevel / 7.0));
float fallbackWeight = saturate(mipLevel / 7.0) * SharedData::cubemapCreatorSettings.ReflectionFallbackAmount;
color.rgb = lerp(color.rgb, Color::IrradianceToLinear(ReflectionsTexture.SampleLevel(LinearSampler, uv, 0.0).rgb), fallbackWeight);
#else
color.rgb = lerp(color.rgb, color.rgb * DefaultCubemap.SampleLevel(LinearSampler, uv, 0.0).xyz, saturate(mipLevel / 7.0));
#endif
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Info]
Version = 2-3-1
Version = 2-3-2

[Nexus]
autoupload = false
6 changes: 5 additions & 1 deletion package/Shaders/Common/SharedData.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,13 @@ namespace SharedData
struct CubemapCreatorSettings
{
uint Enabled;
float3 pad0;
uint EnabledSSR;
float2 pad0;

float4 CubemapColor;

float ReflectionFallbackAmount;
float3 pad1;
};

struct TerraOccSettings
Expand Down
12 changes: 11 additions & 1 deletion src/Features/DynamicCubemaps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ constexpr auto MIPLEVELS = 8;
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
DynamicCubemaps::Settings,
EnabledSSR,
EnabledCreator);
EnabledCreator,
ReflectionFallbackAmount);

std::vector<std::pair<std::string_view, std::string_view>> DynamicCubemaps::GetShaderDefineOptions()
{
Expand All @@ -26,6 +27,14 @@ std::vector<std::pair<std::string_view, std::string_view>> DynamicCubemaps::GetS

void DynamicCubemaps::DrawSettings()
{
if (ImGui::TreeNodeEx("Native Cubemap Fallback", ImGuiTreeNodeFlags_DefaultOpen)) {
ImGui::SliderFloat("Fallback Amount", &settings.ReflectionFallbackAmount, kReflectionFallbackMin, kReflectionFallbackMax, "%.2f", ImGuiSliderFlags_AlwaysClamp);
if (auto _tt = Util::HoverTooltipWrapper()) {
ImGui::Text("Controls how much the game's reflection cubemap fills missing dynamic reflection directions.");
}
ImGui::TreePop();
}

if (ImGui::TreeNodeEx("Screen Space Reflections", ImGuiTreeNodeFlags_DefaultOpen)) {
recompileFlag |= ImGui::Checkbox("Enable Screen Space Reflections", reinterpret_cast<bool*>(&settings.EnabledSSR));
if (auto _tt = Util::HoverTooltipWrapper()) {
Expand Down Expand Up @@ -131,6 +140,7 @@ void DynamicCubemaps::DrawSettings()
void DynamicCubemaps::LoadSettings(json& o_json)
{
settings = o_json;
settings.ReflectionFallbackAmount = std::clamp(settings.ReflectionFallbackAmount, kReflectionFallbackMin, kReflectionFallbackMax);
if (REL::Module::IsVR()) {
Util::LoadGameSettings(iniVRCubeMapSettings);
}
Expand Down
7 changes: 7 additions & 0 deletions src/Features/DynamicCubemaps.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ class MenuOpenCloseEventHandler : public RE::BSTEventSink<RE::MenuOpenCloseEvent
struct DynamicCubemaps : Feature
{
public:
static constexpr float kReflectionFallbackMin = 0.0f;
static constexpr float kReflectionFallbackMax = 1.0f;
static constexpr float kReflectionFallbackDefault = 0.5f;

const std::string defaultDynamicCubeMapSavePath = "Data\\textures\\DynamicCubemaps";

// Specular irradiance
Expand Down Expand Up @@ -116,7 +120,10 @@ struct DynamicCubemaps : Feature
uint EnabledSSR = true;
uint pad0[2];
float4 CubemapColor{ 1.0f, 1.0f, 1.0f, 0.0f };
float ReflectionFallbackAmount = kReflectionFallbackDefault;
float pad1[3];
};
STATIC_ASSERT_ALIGNAS_16(Settings);

Settings settings;
bool enabledAtBoot = false;
Expand Down
Loading