Skip to content

Commit

Permalink
volumetric: cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
vlj committed Mar 3, 2024
1 parent 862dd6a commit 875250d
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 16 deletions.
2 changes: 1 addition & 1 deletion data/base/shaders/vk/pointlights.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ vec4 volumetricLights(
vec3 transMittance = vec3(1);


#define STEPS 64
#define STEPS (WZ_VOLUMETRIC_LIGHTING_ENABLED * 16)
for (int i = 0; i < STEPS; i++)
{

Expand Down
2 changes: 1 addition & 1 deletion data/base/shaders/vk/tcmask_instanced.frag
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ void main()
fragColour.a = 0.66 + 0.66 * graphicsCycle;
}

if (WZ_VOLUMETRIC_LIGHTING_ENABLED == 1) {
if (WZ_VOLUMETRIC_LIGHTING_ENABLED != 0) {
vec2 clipSpaceCoord = gl_FragCoord.xy / vec2(viewportWidth, viewportHeight);
vec4 volumetric = volumetricLights(clipSpaceCoord, cameraPos.xyz, fragPos, diffuse.xyz);
fragColour.xyz = toneMap(fragColour.xyz * volumetric.a + volumetric.xyz);
Expand Down
11 changes: 10 additions & 1 deletion lib/ivis_opengl/gfx_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@
using nonstd::optional;
using nonstd::nullopt;


enum class VOLUMETRIC_LIGHT_LEVEL
{
disabled,
low,
medium,
high,
};

namespace gfx_api
{
// Must be implemented by backend (ex. SDL)
Expand Down Expand Up @@ -326,7 +335,7 @@ namespace gfx_api
uint32_t shadowFilterSize = 5;
uint32_t shadowCascadesCount = WZ_MAX_SHADOW_CASCADES;
bool isPointLightPerPixelEnabled = false;
bool isVolumetricLightingEnabled = false;
VOLUMETRIC_LIGHT_LEVEL isVolumetricLightingEnabled = VOLUMETRIC_LIGHT_LEVEL::disabled;

bool operator==(const lighting_constants& rhs) const
{
Expand Down
2 changes: 1 addition & 1 deletion lib/ivis_opengl/gfx_api_vk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1774,7 +1774,7 @@ VkPSO::VkPSO(vk::Device _dev,
appendSpecializationConstant_uint32(4, static_cast<uint32_t>(root->shadowConstants.isPointLightPerPixelEnabled));
hasSpecializationConstant_PointLightConstants = true;
}
if (shaderInfo.specializationConstant_4_pointLightEnabled)
if (shaderInfo.specializationConstant_5_volumetricEnabled)
{
appendSpecializationConstant_uint32(5, static_cast<uint32_t>(root->shadowConstants.isVolumetricLightingEnabled));
hasSpecializationConstant_VolumetricLightingConstants = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/ivis_opengl/piestate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void pie_FreeShaders()
//static float fogEnd;

// Run from screen.c on init.
bool pie_LoadShaders(uint32_t shadowFilterSize, bool pointLightEnabled, bool volumetricEnabled)
bool pie_LoadShaders(uint32_t shadowFilterSize, bool pointLightEnabled, VOLUMETRIC_LIGHT_LEVEL volumetricEnabled)
{
// note: actual loading of shaders now occurs in gfx_api

Expand Down
2 changes: 1 addition & 1 deletion lib/ivis_opengl/piestate.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const Vector3f& getDefaultSunPosition();

int pie_GetMaxAntialiasing();

bool pie_LoadShaders(uint32_t shadowFilterSize, bool pointLightEnabled, bool volumetricEnabled);
bool pie_LoadShaders(uint32_t shadowFilterSize, bool pointLightEnabled, VOLUMETRIC_LIGHT_LEVEL volumetricEnabled);
void pie_FreeShaders();

namespace pie_internal
Expand Down
6 changes: 3 additions & 3 deletions src/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,8 +619,8 @@ bool loadConfig()
}

{
auto value = iniGetBoolOpt("volumetricLighting");
war_setVolumetricLighting(value.value_or(false));
auto value = iniGetIntegerOpt("volumetricLighting");
war_setVolumetricLighting(static_cast<VOLUMETRIC_LIGHT_LEVEL>(value.value_or(0)));
}

ActivityManager::instance().endLoadingSettings();
Expand Down Expand Up @@ -784,7 +784,7 @@ bool saveConfig()
iniSetInteger("shadowFilterSize", (int)war_getShadowFilterSize());
iniSetInteger("shadowMapResolution", (int)war_getShadowMapResolution());
iniSetBool("pointLightsPerpixel", war_getPointLightPerPixelLighting());
iniSetBool("volumetricLighting", war_getVolumetricLighting());
iniSetInteger("volumetricLighting", static_cast<int>(war_getVolumetricLighting()));
iniSetInteger("configVersion", CURRCONFVERSION);

// write out ini file changes
Expand Down
13 changes: 11 additions & 2 deletions src/frontend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,14 @@ char const* graphicsOptionsLightingString()

char const* graphicsOptionsVolumetricLightingString()
{
return war_getVolumetricLighting() ? _("On") : _("Off");
switch (war_getVolumetricLighting())
{
case VOLUMETRIC_LIGHT_LEVEL::low: return _("Low");
case VOLUMETRIC_LIGHT_LEVEL::medium: return _("Medium");
case VOLUMETRIC_LIGHT_LEVEL::high: return _("High");
}

return _("Disabled");
}

Check failure on line 872 in src/frontend.cpp

View workflow job for this annotation

GitHub Actions / Fedora :LATEST [GCC]

enumeration value 'disabled' not handled in switch [-Werror=switch]

Check failure on line 872 in src/frontend.cpp

View workflow job for this annotation

GitHub Actions / Arch :LATEST [Clang]

enumeration value 'disabled' not handled in switch [-Werror,-Wswitch]

Check failure on line 872 in src/frontend.cpp

View workflow job for this annotation

GitHub Actions / Arch :LATEST [GCC]

enumeration value ‘disabled’ not handled in switch [-Werror=switch]

Check failure on line 872 in src/frontend.cpp

View workflow job for this annotation

GitHub Actions / Fedora :LATEST [GCC -m32]

enumeration value 'disabled' not handled in switch [-Werror=switch]

Check failure on line 872 in src/frontend.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04 [Clang]

enumeration value 'disabled' not handled in switch [-Werror,-Wswitch]

Check failure on line 872 in src/frontend.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 20.04 [Clang]

enumeration value 'disabled' not handled in switch [-Werror,-Wswitch]

Check failure on line 872 in src/frontend.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04 [GCC]

enumeration value 'disabled' not handled in switch [-Werror=switch]

Check warning on line 872 in src/frontend.cpp

View workflow job for this annotation

GitHub Actions / wasm32

enumeration value 'disabled' not handled in switch [-Wswitch]

Check failure on line 872 in src/frontend.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 20.04 [GCC]

enumeration value 'disabled' not handled in switch [-Werror=switch]

Check failure on line 872 in src/frontend.cpp

View workflow job for this annotation

GitHub Actions / Alpine :LATEST [GCC]

enumeration value 'disabled' not handled in switch [-Werror=switch]

Check failure on line 872 in src/frontend.cpp

View workflow job for this annotation

GitHub Actions / arm64 [LLVM_MINGW]

enumeration value 'disabled' not handled in switch [-Werror,-Wswitch]

Check failure on line 872 in src/frontend.cpp

View workflow job for this annotation

GitHub Actions / x86 [LLVM_MINGW]

enumeration value 'disabled' not handled in switch [-Werror,-Wswitch]

Check failure on line 872 in src/frontend.cpp

View workflow job for this annotation

GitHub Actions / x64 [LLVM_MINGW]

enumeration value 'disabled' not handled in switch [-Werror,-Wswitch]
char const *graphicsOptionsFogString()
Expand Down Expand Up @@ -1309,7 +1316,9 @@ bool runGraphicsOptionsMenu()
case FRONTEND_VOLUMETRIC_LIGHTING:
case FRONTEND_VOLUMETRIC_LIGHTING_R:
{
war_setVolumetricLighting(!war_getVolumetricLighting());
auto previousValue = static_cast<int>(war_getVolumetricLighting());
auto newValue = previousValue + 1 % 4;
war_setVolumetricLighting(static_cast<VOLUMETRIC_LIGHT_LEVEL>(newValue));
widgSetString(psWScreen, FRONTEND_VOLUMETRIC_LIGHTING_R, graphicsOptionsVolumetricLightingString());
break;
}
Expand Down
6 changes: 3 additions & 3 deletions src/warzoneconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct WARZONE_GLOBALS
uint32_t shadowFilterSize = 5;
uint32_t shadowMapResolution = 0; // this defaults to 0, which causes the gfx backend to figure out a recommended default based on the system properties
bool pointLightLighting = false;
bool volumetricLighting = false;
VOLUMETRIC_LIGHT_LEVEL volumetricLighting = VOLUMETRIC_LIGHT_LEVEL::disabled;
// groups UI
bool groupsMenuEnabled = true;

Expand Down Expand Up @@ -657,7 +657,7 @@ bool war_getPointLightPerPixelLighting()
return warGlobs.pointLightLighting;
}

bool war_getVolumetricLighting()
VOLUMETRIC_LIGHT_LEVEL war_getVolumetricLighting()
{
return warGlobs.volumetricLighting;
}
Expand All @@ -667,7 +667,7 @@ void war_setPointLightPerPixelLighting(bool perPixelEnabled)
warGlobs.pointLightLighting = perPixelEnabled;
}

void war_setVolumetricLighting(bool volumetricEnabled)
void war_setVolumetricLighting(VOLUMETRIC_LIGHT_LEVEL volumetricEnabled)
{
warGlobs.volumetricLighting = volumetricEnabled;
}
Expand Down
6 changes: 4 additions & 2 deletions src/warzoneconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ enum class JS_BACKEND
num_backends // Must be last!
};

enum class VOLUMETRIC_LIGHT_LEVEL;

bool js_backend_from_str(const char *str, JS_BACKEND &output_backend);
std::string to_string(JS_BACKEND backend);

Expand Down Expand Up @@ -165,8 +167,8 @@ void war_setShadowMapResolution(uint32_t resolution);
bool war_getPointLightPerPixelLighting();
void war_setPointLightPerPixelLighting(bool perPixelEnabled);

bool war_getVolumetricLighting();
void war_setVolumetricLighting(bool enabled);
VOLUMETRIC_LIGHT_LEVEL war_getVolumetricLighting();
void war_setVolumetricLighting(VOLUMETRIC_LIGHT_LEVEL enabled);

bool war_getGroupsMenuEnabled();
void war_setGroupsMenuEnabled(bool enabled);
Expand Down

0 comments on commit 875250d

Please sign in to comment.