mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-15 18:57:08 +00:00
Make bloom parameters server-controlled (#15231)
This commit is contained in:
parent
13f533d490
commit
6ac4447134
12 changed files with 95 additions and 66 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -41,7 +41,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
|
||||
RenderingEngine *RenderingEngine::s_singleton = nullptr;
|
||||
const video::SColor RenderingEngine::MENU_SKY_COLOR = video::SColor(255, 140, 186, 250);
|
||||
const float RenderingEngine::BASE_BLOOM_STRENGTH = 1.0f;
|
||||
|
||||
/* Helper classes */
|
||||
|
||||
|
|
|
@ -81,7 +81,6 @@ class RenderingEngine
|
|||
{
|
||||
public:
|
||||
static const video::SColor MENU_SKY_COLOR;
|
||||
static const float BASE_BLOOM_STRENGTH;
|
||||
|
||||
RenderingEngine(IEventReceiver *eventReceiver);
|
||||
~RenderingEngine();
|
||||
|
|
|
@ -332,9 +332,6 @@ void set_default_settings()
|
|||
settings->setDefault("antialiasing", "none");
|
||||
settings->setDefault("enable_bloom", "false");
|
||||
settings->setDefault("enable_bloom_debug", "false");
|
||||
settings->setDefault("bloom_strength_factor", "1.0");
|
||||
settings->setDefault("bloom_intensity", "0.05");
|
||||
settings->setDefault("bloom_radius", "1");
|
||||
settings->setDefault("enable_volumetric_lighting", "false");
|
||||
settings->setDefault("enable_water_reflections", "false");
|
||||
settings->setDefault("enable_translucent_foliage", "false");
|
||||
|
|
|
@ -57,4 +57,7 @@ struct Lighting
|
|||
float saturation {1.0f};
|
||||
float volumetric_light_strength {0.0f};
|
||||
video::SColor shadow_tint {255, 0, 0, 0};
|
||||
float bloom_intensity {0.05f};
|
||||
float bloom_strength_factor {1.0f};
|
||||
float bloom_radius {1.0f};
|
||||
};
|
||||
|
|
|
@ -1819,4 +1819,9 @@ void Client::handleCommand_SetLighting(NetworkPacket *pkt)
|
|||
*pkt >> lighting.volumetric_light_strength;
|
||||
if (pkt->getRemainingBytes() >= 4)
|
||||
*pkt >> lighting.shadow_tint;
|
||||
if (pkt->getRemainingBytes() >= 12) {
|
||||
*pkt >> lighting.bloom_intensity
|
||||
>> lighting.bloom_strength_factor
|
||||
>> lighting.bloom_radius;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2649,6 +2649,14 @@ int ObjectRef::l_set_lighting(lua_State *L)
|
|||
lighting.volumetric_light_strength = rangelim(lighting.volumetric_light_strength, 0.0f, 1.0f);
|
||||
}
|
||||
lua_pop(L, 1); // volumetric_light
|
||||
|
||||
lua_getfield(L, 2, "bloom");
|
||||
if (lua_istable(L, -1)) {
|
||||
lighting.bloom_intensity = getfloatfield_default(L, -1, "intensity", lighting.bloom_intensity);
|
||||
lighting.bloom_strength_factor = getfloatfield_default(L, -1, "strength_factor", lighting.bloom_strength_factor);
|
||||
lighting.bloom_radius = getfloatfield_default(L, -1, "radius", lighting.bloom_radius);
|
||||
}
|
||||
lua_pop(L, 1); // bloom
|
||||
}
|
||||
|
||||
getServer(L)->setLighting(player, lighting);
|
||||
|
@ -2693,6 +2701,14 @@ int ObjectRef::l_get_lighting(lua_State *L)
|
|||
lua_pushnumber(L, lighting.volumetric_light_strength);
|
||||
lua_setfield(L, -2, "strength");
|
||||
lua_setfield(L, -2, "volumetric_light");
|
||||
lua_newtable(L); // "bloom"
|
||||
lua_pushnumber(L, lighting.bloom_intensity);
|
||||
lua_setfield(L, -2, "intensity");
|
||||
lua_pushnumber(L, lighting.bloom_strength_factor);
|
||||
lua_setfield(L, -2, "strength_factor");
|
||||
lua_pushnumber(L, lighting.bloom_radius);
|
||||
lua_setfield(L, -2, "radius");
|
||||
lua_setfield(L, -2, "bloom");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1919,6 +1919,8 @@ void Server::SendSetLighting(session_t peer_id, const Lighting &lighting)
|
|||
<< lighting.exposure.center_weight_power;
|
||||
|
||||
pkt << lighting.volumetric_light_strength << lighting.shadow_tint;
|
||||
pkt << lighting.bloom_intensity << lighting.bloom_strength_factor <<
|
||||
lighting.bloom_radius;
|
||||
|
||||
Send(&pkt);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue