1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Make bloom parameters server-controlled (#15231)

This commit is contained in:
grorp 2024-10-09 15:08:03 +02:00 committed by GitHub
parent 13f533d490
commit 6ac4447134
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 95 additions and 66 deletions

View file

@ -405,11 +405,8 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
float m_user_exposure_compensation;
bool m_bloom_enabled;
CachedPixelShaderSetting<float> m_bloom_intensity_pixel{"bloomIntensity"};
float m_bloom_intensity;
CachedPixelShaderSetting<float> m_bloom_strength_pixel{"bloomStrength"};
float m_bloom_strength;
CachedPixelShaderSetting<float> m_bloom_radius_pixel{"bloomRadius"};
float m_bloom_radius;
CachedPixelShaderSetting<float> m_saturation_pixel{"saturation"};
bool m_volumetric_light_enabled;
CachedPixelShaderSetting<float, 3>
@ -421,11 +418,8 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
CachedPixelShaderSetting<float>
m_volumetric_light_strength_pixel{"volumetricLightStrength"};
static constexpr std::array<const char*, 4> SETTING_CALLBACKS = {
static constexpr std::array<const char*, 1> SETTING_CALLBACKS = {
"exposure_compensation",
"bloom_intensity",
"bloom_strength_factor",
"bloom_radius"
};
public:
@ -433,12 +427,6 @@ public:
{
if (name == "exposure_compensation")
m_user_exposure_compensation = g_settings->getFloat("exposure_compensation", -1.0f, 1.0f);
if (name == "bloom_intensity")
m_bloom_intensity = g_settings->getFloat("bloom_intensity", 0.01f, 1.0f);
if (name == "bloom_strength_factor")
m_bloom_strength = RenderingEngine::BASE_BLOOM_STRENGTH * g_settings->getFloat("bloom_strength_factor", 0.1f, 10.0f);
if (name == "bloom_radius")
m_bloom_radius = g_settings->getFloat("bloom_radius", 0.1f, 8.0f);
}
static void settingsCallback(const std::string &name, void *userdata)
@ -457,9 +445,6 @@ public:
m_user_exposure_compensation = g_settings->getFloat("exposure_compensation", -1.0f, 1.0f);
m_bloom_enabled = g_settings->getBool("enable_bloom");
m_bloom_intensity = g_settings->getFloat("bloom_intensity", 0.01f, 1.0f);
m_bloom_strength = RenderingEngine::BASE_BLOOM_STRENGTH * g_settings->getFloat("bloom_strength_factor", 0.1f, 10.0f);
m_bloom_radius = g_settings->getFloat("bloom_radius", 0.1f, 8.0f);
m_volumetric_light_enabled = g_settings->getBool("enable_volumetric_lighting") && m_bloom_enabled;
}
@ -511,7 +496,9 @@ public:
m_texel_size0_vertex.set(m_texel_size0, services);
m_texel_size0_pixel.set(m_texel_size0, services);
const AutoExposure &exposure_params = m_client->getEnv().getLocalPlayer()->getLighting().exposure;
const auto &lighting = m_client->getEnv().getLocalPlayer()->getLighting();
const AutoExposure &exposure_params = lighting.exposure;
std::array<float, 7> exposure_buffer = {
std::pow(2.0f, exposure_params.luminance_min),
std::pow(2.0f, exposure_params.luminance_max),
@ -524,12 +511,14 @@ public:
m_exposure_params_pixel.set(exposure_buffer.data(), services);
if (m_bloom_enabled) {
m_bloom_intensity_pixel.set(&m_bloom_intensity, services);
m_bloom_radius_pixel.set(&m_bloom_radius, services);
m_bloom_strength_pixel.set(&m_bloom_strength, services);
float intensity = std::max(lighting.bloom_intensity, 0.0f);
m_bloom_intensity_pixel.set(&intensity, services);
float strength_factor = std::max(lighting.bloom_strength_factor, 0.0f);
m_bloom_strength_pixel.set(&strength_factor, services);
float radius = std::max(lighting.bloom_radius, 0.0f);
m_bloom_radius_pixel.set(&radius, services);
}
const auto &lighting = m_client->getEnv().getLocalPlayer()->getLighting();
float saturation = lighting.saturation;
m_saturation_pixel.set(&saturation, services);