Skip to content

Commit

Permalink
refactor: move opt in for shaders to virtual feature function (doodlu…
Browse files Browse the repository at this point in the history
  • Loading branch information
FlayaN authored Oct 5, 2023
1 parent b105489 commit bbbe409
Show file tree
Hide file tree
Showing 15 changed files with 213 additions and 195 deletions.
3 changes: 3 additions & 0 deletions src/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ struct Feature

virtual std::string GetName() = 0;
virtual std::string GetShortName() = 0;
virtual std::string_view GetShaderDefineName() { return ""; }

virtual bool HasShaderDefine(RE::BSShader::Type) { return false; }

virtual void SetupResources() = 0;
virtual void Reset() = 0;
Expand Down
10 changes: 10 additions & 0 deletions src/Features/ExtendedMaterials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,14 @@ void ExtendedMaterials::Load(json& o_json)
void ExtendedMaterials::Save(json& o_json)
{
o_json[GetName()] = settings;
}

bool ExtendedMaterials::HasShaderDefine(RE::BSShader::Type shaderType)
{
switch (shaderType) {
case RE::BSShader::Type::Lighting:
return true;
default:
return false;
}
}
3 changes: 3 additions & 0 deletions src/Features/ExtendedMaterials.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ struct ExtendedMaterials : Feature

virtual inline std::string GetName() { return "Complex Parallax Materials"; }
virtual inline std::string GetShortName() { return "ComplexParallaxMaterials"; }
inline std::string_view GetShaderDefineName() override { return "COMPLEX_PARALLAX_MATERIALS"; }

bool HasShaderDefine(RE::BSShader::Type shaderType) override;

struct Settings
{
Expand Down
10 changes: 10 additions & 0 deletions src/Features/GrassCollision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,4 +335,14 @@ void GrassCollision::SetupResources()
void GrassCollision::Reset()
{
updatePerFrame = true;
}

bool GrassCollision::HasShaderDefine(RE::BSShader::Type shaderType)
{
switch (shaderType) {
case RE::BSShader::Type::Grass:
return true;
default:
return false;
}
}
3 changes: 3 additions & 0 deletions src/Features/GrassCollision.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ struct GrassCollision : Feature

virtual inline std::string GetName() { return "Grass Collision"; }
virtual inline std::string GetShortName() { return "GrassCollision"; }
inline std::string_view GetShaderDefineName() override { return "GRASS_COLLISION"; }

bool HasShaderDefine(RE::BSShader::Type shaderType) override;

struct Settings
{
Expand Down
11 changes: 11 additions & 0 deletions src/Features/LightLimitFix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -957,4 +957,15 @@ void LightLimitFix::UpdateLights()
context->CSSetShaderResources(0, ARRAYSIZE(null_srvs), null_srvs);
ID3D11UnorderedAccessView* null_uavs[3] = { nullptr };
context->CSSetUnorderedAccessViews(0, ARRAYSIZE(null_uavs), null_uavs, nullptr);
}

bool LightLimitFix::HasShaderDefine(RE::BSShader::Type shaderType)
{
switch (shaderType) {
case RE::BSShader::Type::Lighting:
case RE::BSShader::Type::Grass:
return true;
default:
return false;
}
}
3 changes: 3 additions & 0 deletions src/Features/LightLimitFix.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ struct LightLimitFix : Feature
}
virtual inline std::string GetName() { return "Light Limit Fix"; }
virtual inline std::string GetShortName() { return "LightLimitFix"; }
inline std::string_view GetShaderDefineName() override { return "LIGHT_LIMIT_FIX"; }

bool HasShaderDefine(RE::BSShader::Type shaderType) override;

struct LightData
{
Expand Down
10 changes: 10 additions & 0 deletions src/Features/RainWetnessEffects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,4 +346,14 @@ void RainWetnessEffects::Load(json& o_json)
void RainWetnessEffects::Save(json& o_json)
{
o_json[GetName()] = settings;
}

bool RainWetnessEffects::HasShaderDefine(RE::BSShader::Type shaderType)
{
switch (shaderType) {
case RE::BSShader::Type::Lighting:
return true;
default:
return false;
}
}
3 changes: 3 additions & 0 deletions src/Features/RainWetnessEffects.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ struct RainWetnessEffects : Feature

virtual inline std::string GetName() { return "Rain Wetness Effects"; }
virtual inline std::string GetShortName() { return "RainWetnessEffects"; }
inline std::string_view GetShaderDefineName() override { return "RAIN_WETNESS_EFFECTS"; }

bool HasShaderDefine(RE::BSShader::Type shaderType) override;

struct Settings
{
Expand Down
12 changes: 12 additions & 0 deletions src/Features/ScreenSpaceShadows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -509,4 +509,16 @@ void ScreenSpaceShadows::SetupResources()
void ScreenSpaceShadows::Reset()
{
renderedScreenCamera = false;
}

bool ScreenSpaceShadows::HasShaderDefine(RE::BSShader::Type shaderType)
{
switch (shaderType) {
case RE::BSShader::Type::Lighting:
case RE::BSShader::Type::Grass:
case RE::BSShader::Type::DistantTree:
return true;
default:
return false;
}
}
3 changes: 3 additions & 0 deletions src/Features/ScreenSpaceShadows.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ struct ScreenSpaceShadows : Feature

virtual inline std::string GetName() { return "Screen-Space Shadows"; }
virtual inline std::string GetShortName() { return "ScreenSpaceShadows"; }
inline std::string_view GetShaderDefineName() override { return "SCREEN_SPACE_SHADOWS"; }

bool HasShaderDefine(RE::BSShader::Type shaderType) override;

struct Settings
{
Expand Down
10 changes: 10 additions & 0 deletions src/Features/WaterBlending.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,14 @@ void WaterBlending::Load(json& o_json)
void WaterBlending::Save(json& o_json)
{
o_json[GetName()] = settings;
}

bool WaterBlending::HasShaderDefine(RE::BSShader::Type shaderType)
{
switch (shaderType) {
case RE::BSShader::Type::Water:
return true;
default:
return false;
}
}
3 changes: 3 additions & 0 deletions src/Features/WaterBlending.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ struct WaterBlending : Feature

virtual inline std::string GetName() { return "Water Blending"; }
virtual inline std::string GetShortName() { return "WaterBlending"; }
inline std::string_view GetShaderDefineName() override { return "WATER_BLENDING"; }

bool HasShaderDefine(RE::BSShader::Type shaderType) override;

struct Settings
{
Expand Down
4 changes: 0 additions & 4 deletions src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@
#include "State.h"

#include "Feature.h"
#include "Features/ExtendedMaterials.h"
#include "Features/LightLimitFix/ParticleLights.h"
#include "Features/RainWetnessEffects.h"
#include "Features/ScreenSpaceShadows.h"
#include "Features/WaterBlending.h"

#define SETTING_MENU_TOGGLEKEY "Toggle Key"
#define SETTING_MENU_SKIPKEY "Skip Compilation Key"
Expand Down
Loading

0 comments on commit bbbe409

Please sign in to comment.