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 @@ -21,6 +21,6 @@ namespace CloudShadows
{
float3 cloudSampleDir = GetCloudShadowSampleDir(worldPosition, SharedData::DirLightDirection.xyz).xyz;
float cloudCubeSample = CloudShadowsTexture.SampleLevel(textureSampler, cloudSampleDir, 0).x;
return 1.0 - saturate(cloudCubeSample);
return lerp(1.0, 1.0 - cloudCubeSample, SharedData::cloudShadowsSettings.Opacity);
}
}
2 changes: 1 addition & 1 deletion features/Cloud Shadows/Shaders/Features/CloudShadows.ini
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[Info]
Version = 1-1-1
Version = 1-2-0
5 changes: 1 addition & 4 deletions package/Shaders/Common/ShadowSampling.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,8 @@ namespace ShadowSampling
#endif

#if defined(CLOUD_SHADOWS)
if (!SharedData::InMapMenu) {
if (!SharedData::InMapMenu)
worldShadow *= CloudShadows::GetCloudShadowMult(positionWS, LinearSampler);
if (worldShadow == 0.0)
return worldShadow;
}
#endif

return worldShadow;
Expand Down
7 changes: 7 additions & 0 deletions package/Shaders/Common/SharedData.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ namespace SharedData
uint2 pad0;
};

struct CloudShadowsSettings
{
float Opacity;
float3 pad0;
};

cbuffer FeatureData : register(b6)
{
GrassLightingSettings grassLightingSettings;
Expand All @@ -139,6 +145,7 @@ namespace SharedData
LightLimitFixSettings lightLimitFixSettings;
WetnessEffectsSettings wetnessEffectsSettings;
SkylightingSettings skylightingSettings;
CloudShadowsSettings cloudShadowsSettings;
};

Texture2D<float4> DepthTexture : register(t17);
Expand Down
4 changes: 3 additions & 1 deletion src/FeatureBuffer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "FeatureBuffer.h"

#include "Features/CloudShadows.h"
#include "Features/DynamicCubemaps.h"
#include "Features/ExtendedMaterials.h"
#include "Features/GrassLighting.h"
Expand Down Expand Up @@ -35,5 +36,6 @@ std::pair<unsigned char*, size_t> GetFeatureBufferData(bool a_inWorld)
globals::features::terrainShadows->GetCommonBufferData(),
globals::features::lightLimitFix->GetCommonBufferData(),
globals::features::wetnessEffects->GetCommonBufferData(),
globals::features::skylighting->GetCommonBufferData(a_inWorld));
globals::features::skylighting->GetCommonBufferData(a_inWorld),
globals::features::cloudShadows->settings);
}
28 changes: 28 additions & 0 deletions src/Features/CloudShadows.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
#include "CloudShadows.h"

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
CloudShadows::Settings,
Opacity)

void CloudShadows::DrawSettings()
{
ImGui::SliderFloat("Opacity", &settings.Opacity, 0.0f, 1.0f, "%.1f");
if (auto _tt = Util::HoverTooltipWrapper()) {
ImGui::Text(
"Higher values make cloud shadows darker.");
}
}

void CloudShadows::LoadSettings(json& o_json)
{
settings = o_json;
}

void CloudShadows::SaveSettings(json& o_json)
{
o_json = settings;
}

void CloudShadows::RestoreDefaultSettings()
{
settings = {};
}

void CloudShadows::CheckResourcesSide(int side)
{
static Util::FrameChecker frame_checker[6];
Expand Down
15 changes: 15 additions & 0 deletions src/Features/CloudShadows.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ struct CloudShadows : Feature
return &singleton;
}

struct alignas(16) Settings
{
float Opacity = 0.8f;
float pad[3];
};

Settings settings;

virtual inline std::string GetName() override { return "Cloud Shadows"; }
virtual inline std::string GetShortName() override { return "CloudShadows"; }
virtual inline std::string_view GetShaderDefineName() override { return "CLOUD_SHADOWS"; }
Expand All @@ -26,6 +34,13 @@ struct CloudShadows : Feature

virtual void SetupResources() override;

virtual void DrawSettings() override;

virtual void LoadSettings(json& o_json) override;
virtual void SaveSettings(json& o_json) override;

virtual void RestoreDefaultSettings() override;

void CheckResourcesSide(int side);
void ModifySky(RE::BSRenderPass* Pass);

Expand Down