mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Fixes and Lua control
This commit is contained in:
parent
45289b6919
commit
b3710a982e
10 changed files with 34 additions and 13 deletions
|
@ -32,6 +32,8 @@ uniform float animationTimer;
|
||||||
uniform float xyPerspectiveBias0;
|
uniform float xyPerspectiveBias0;
|
||||||
uniform float xyPerspectiveBias1;
|
uniform float xyPerspectiveBias1;
|
||||||
uniform vec3 shadow_tint;
|
uniform vec3 shadow_tint;
|
||||||
|
uniform float foliage_translucency;
|
||||||
|
uniform float specular_intensity;
|
||||||
|
|
||||||
varying float adj_shadow_strength;
|
varying float adj_shadow_strength;
|
||||||
varying float cosLight;
|
varying float cosLight;
|
||||||
|
@ -533,12 +535,9 @@ void main(void)
|
||||||
col.rgb += reflection_color * pow(fresnel_factor, 2.0) * 0.5 * brightness_factor;
|
col.rgb += reflection_color * pow(fresnel_factor, 2.0) * 0.5 * brightness_factor;
|
||||||
|
|
||||||
vec3 water_reflect_color =
|
vec3 water_reflect_color =
|
||||||
6.0 * sunTint * dayLight * fresnel_factor * f_adj_shadow_strength * max(1.0 - shadow_uncorrected, 0.0) *
|
2.0 * specular_intensity * sunTint * dayLight * fresnel_factor * max(1.0 - shadow_uncorrected, 0.0) *
|
||||||
mtsmoothstep(0.85, 0.9, pow(clamp(dot(reflect_ray, viewVec), 0.0, 1.0), 32.0));
|
mtsmoothstep(0.85, 0.9, pow(clamp(dot(reflect_ray, viewVec), 0.0, 1.0), 32.0));
|
||||||
|
|
||||||
// We clip the reflection color if it gets too bright
|
|
||||||
water_reflect_color *= min(2.0 / max(water_reflect_color.r, max(water_reflect_color.g, water_reflect_color.b)), 1.0);
|
|
||||||
|
|
||||||
// Sun reflection
|
// Sun reflection
|
||||||
col.rgb += water_reflect_color * brightness_factor;
|
col.rgb += water_reflect_color * brightness_factor;
|
||||||
#endif
|
#endif
|
||||||
|
@ -547,23 +546,26 @@ void main(void)
|
||||||
// Apply specular to blocks.
|
// Apply specular to blocks.
|
||||||
if (dot(v_LightDirection, vNormal) < 0.0) {
|
if (dot(v_LightDirection, vNormal) < 0.0) {
|
||||||
// This intensity is a placeholder and should be replaced by proper specular maps.
|
// This intensity is a placeholder and should be replaced by proper specular maps.
|
||||||
float intensity = 4.0 * min(1.0, length(varColor.rgb * base.rgb));
|
float intensity = specular_intensity * min(1.0, length(varColor.rgb * base.rgb));
|
||||||
const float specular_exponent = 5.0;
|
const float specular_exponent = 5.0;
|
||||||
const float fresnel_exponent = 4.0;
|
const float fresnel_exponent = 4.0;
|
||||||
|
|
||||||
col.rgb +=
|
col.rgb +=
|
||||||
sunTint * intensity * dayLight * (1.0 - nightRatio) * (1.0 - shadow_uncorrected) * f_adj_shadow_strength *
|
sunTint * intensity * dayLight * (1.0 - nightRatio) * (1.0 - shadow_uncorrected) *
|
||||||
pow(max(dot(reflect_ray, viewVec), 0.0), fresnel_exponent) * pow(1.0 - abs(dot(viewVec, fNormal)), specular_exponent);
|
pow(max(dot(reflect_ray, viewVec), 0.0), fresnel_exponent) * pow(1.0 - abs(dot(viewVec, fNormal)), specular_exponent);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (MATERIAL_TYPE == TILE_MATERIAL_WAVING_PLANTS || MATERIAL_TYPE == TILE_MATERIAL_WAVING_LEAVES) && defined(ENABLE_TRANSLUCENT_FOLIAGE)
|
#if (MATERIAL_TYPE == TILE_MATERIAL_WAVING_PLANTS || MATERIAL_TYPE == TILE_MATERIAL_WAVING_LEAVES) && defined(ENABLE_TRANSLUCENT_FOLIAGE)
|
||||||
// Simulate translucent foliage.
|
// Simulate translucent foliage.
|
||||||
col.rgb += 4.0 * sunTint * dayLight * base.rgb * normalize(base.rgb * varColor.rgb * varColor.rgb) * f_adj_shadow_strength * pow(max(-dot(v_LightDirection, viewVec), 0.0), 4.0) * max(1.0 - shadow_uncorrected, 0.0);
|
col.rgb += foliage_translucency * sunTint * dayLight * base.rgb * normalize(base.rgb * varColor.rgb * varColor.rgb) * pow(max(-dot(v_LightDirection, viewVec), 0.0), 4.0) * max(1.0 - shadow_uncorrected, 0.0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// We clip the color if it gets too bright
|
||||||
|
col *= min(2.0 / base.a / max(col.r, max(col.g, col.b)), 1.0);
|
||||||
|
|
||||||
// Due to a bug in some (older ?) graphics stacks (possibly in the glsl compiler ?),
|
// Due to a bug in some (older ?) graphics stacks (possibly in the glsl compiler ?),
|
||||||
// the fog will only be rendered correctly if the last operation before the
|
// the fog will only be rendered correctly if the last operation before the
|
||||||
// clamp() is an addition. Else, the clamp() seems to be ignored.
|
// clamp() is an addition. Else, the clamp() seems to be ignored.
|
||||||
|
|
|
@ -8786,6 +8786,10 @@ child will follow movement and rotation of that bone.
|
||||||
but keeping original luma and being symmetrical in terms of saturation
|
but keeping original luma and being symmetrical in terms of saturation
|
||||||
(eg. -1 and 1 is the same saturation and luma, but different hues)
|
(eg. -1 and 1 is the same saturation and luma, but different hues)
|
||||||
* This value has no effect on clients who have shaders or post-processing disabled.
|
* This value has no effect on clients who have shaders or post-processing disabled.
|
||||||
|
* `foliage_translucency` controls the intensity of the foliage translucency effect (default: `2.0`).
|
||||||
|
* This has no effect when dynamic shadows are disabled and on clients who have the "Translucent foliage" effect disabled.
|
||||||
|
* `specular_intensity` controls the intensity of specular highlights on nodes and liquids (default: `2.0`).
|
||||||
|
* This has no effect when dynamic shadows are disabled and on clients who have the "Translucent foliage" effect disabled.
|
||||||
* `shadows` is a table that controls ambient shadows
|
* `shadows` is a table that controls ambient shadows
|
||||||
* This has no effect on clients who have the "Dynamic Shadows" effect disabled.
|
* This has no effect on clients who have the "Dynamic Shadows" effect disabled.
|
||||||
* `intensity` sets the intensity of the shadows from 0 (no shadows, default) to 1 (blackness)
|
* `intensity` sets the intensity of the shadows from 0 (no shadows, default) to 1 (blackness)
|
||||||
|
|
|
@ -196,7 +196,6 @@ void Clouds::updateMesh()
|
||||||
const f32 rz = cloud_size / 2;
|
const f32 rz = cloud_size / 2;
|
||||||
|
|
||||||
bool soft_clouds_enabled = g_settings->getBool("soft_clouds");
|
bool soft_clouds_enabled = g_settings->getBool("soft_clouds");
|
||||||
bool shaded_clouds_enabled = soft_clouds_enabled && g_settings->getBool("enable_dynamic_shadows") && g_settings->getBool("enable_3d_clouds");
|
|
||||||
|
|
||||||
v3f pos(p0.X, m_params.height * BS, p0.Y);
|
v3f pos(p0.X, m_params.height * BS, p0.Y);
|
||||||
|
|
||||||
|
|
|
@ -414,6 +414,8 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
|
||||||
CachedPixelShaderSetting<float> m_vignette_dark_pixel{"vignette_dark"};
|
CachedPixelShaderSetting<float> m_vignette_dark_pixel{"vignette_dark"};
|
||||||
CachedPixelShaderSetting<float> m_vignette_bright_pixel{"vignette_bright"};
|
CachedPixelShaderSetting<float> m_vignette_bright_pixel{"vignette_bright"};
|
||||||
CachedPixelShaderSetting<float> m_vignette_power_pixel{"vignette_power"};
|
CachedPixelShaderSetting<float> m_vignette_power_pixel{"vignette_power"};
|
||||||
|
CachedPixelShaderSetting<float> m_foliage_translucency_pixel{ "foliage_translucency" };
|
||||||
|
CachedPixelShaderSetting<float> m_specular_intensity_pixel{ "specular_intensity" };
|
||||||
|
|
||||||
static constexpr std::array<const char*, 1> SETTING_CALLBACKS = {
|
static constexpr std::array<const char*, 1> SETTING_CALLBACKS = {
|
||||||
"exposure_compensation",
|
"exposure_compensation",
|
||||||
|
@ -531,6 +533,9 @@ public:
|
||||||
m_vignette_bright_pixel.set(&vignette_params.bright, services);
|
m_vignette_bright_pixel.set(&vignette_params.bright, services);
|
||||||
m_vignette_power_pixel.set(&vignette_params.power, services);
|
m_vignette_power_pixel.set(&vignette_params.power, services);
|
||||||
|
|
||||||
|
m_foliage_translucency_pixel.set(&lighting.foliage_translucency, services);
|
||||||
|
m_specular_intensity_pixel.set(&lighting.specular_intensity, services);
|
||||||
|
|
||||||
if (g_settings->getBool("enable_color_grading")) {
|
if (g_settings->getBool("enable_color_grading")) {
|
||||||
const ColorDecisionList& cdl_params = lighting.cdl;
|
const ColorDecisionList& cdl_params = lighting.cdl;
|
||||||
core::vector3df slope = cdl_params.slope;
|
core::vector3df slope = cdl_params.slope;
|
||||||
|
|
|
@ -176,7 +176,6 @@ void MeshUpdateQueue::done(v3s16 pos)
|
||||||
void MeshUpdateQueue::fillDataFromMapBlocks(QueuedMeshUpdate *q)
|
void MeshUpdateQueue::fillDataFromMapBlocks(QueuedMeshUpdate *q)
|
||||||
{
|
{
|
||||||
auto mesh_grid = m_client->getMeshGrid();
|
auto mesh_grid = m_client->getMeshGrid();
|
||||||
|
|
||||||
MeshMakeData *data = new MeshMakeData(m_client->ndef(), MAP_BLOCKSIZE * mesh_grid.cell_size);
|
MeshMakeData *data = new MeshMakeData(m_client->ndef(), MAP_BLOCKSIZE * mesh_grid.cell_size);
|
||||||
q->data = data;
|
q->data = data;
|
||||||
|
|
||||||
|
|
|
@ -56,9 +56,9 @@ struct Vignette {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct ColorDecisionList {
|
struct ColorDecisionList {
|
||||||
core::vector3df slope{1.2, 1.0, 0.8};
|
core::vector3df slope{1.0, 1.0, 1.0};
|
||||||
core::vector3df offset{0.0, 0.0, 0.0};
|
core::vector3df offset{0.0, 0.0, 0.0};
|
||||||
core::vector3df power{1.25, 1.0, 0.9};
|
core::vector3df power{1.0, 1.0, 1.0};
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Describes ambient light settings for a player
|
/** Describes ambient light settings for a player
|
||||||
|
@ -71,6 +71,8 @@ struct Lighting
|
||||||
float shadow_intensity {0.0f};
|
float shadow_intensity {0.0f};
|
||||||
float saturation {1.0f};
|
float saturation {1.0f};
|
||||||
float volumetric_light_strength {0.0f};
|
float volumetric_light_strength {0.0f};
|
||||||
|
float foliage_translucency{1.5f};
|
||||||
|
float specular_intensity{1.5f};
|
||||||
// These factors are calculated based on expected value of scattering factor of 1e-5
|
// These factors are calculated based on expected value of scattering factor of 1e-5
|
||||||
// for Nitrogen at 532nm (green), 2e25 molecules/m3 in atmosphere
|
// for Nitrogen at 532nm (green), 2e25 molecules/m3 in atmosphere
|
||||||
core::vector3df volumetric_beta_r0{ 3.3362176e-01, 8.75378289198826e-01, 1.95342379700656 };
|
core::vector3df volumetric_beta_r0{ 3.3362176e-01, 8.75378289198826e-01, 1.95342379700656 };
|
||||||
|
|
|
@ -1817,7 +1817,7 @@ void Client::handleCommand_SetLighting(NetworkPacket *pkt)
|
||||||
>> lighting.bloom_radius;
|
>> lighting.bloom_radius;
|
||||||
if (pkt->getRemainingBytes() >= 4)
|
if (pkt->getRemainingBytes() >= 4)
|
||||||
*pkt >> lighting.artificial_light_color;
|
*pkt >> lighting.artificial_light_color;
|
||||||
if (pkt->getRemainingBytes() >= 60)
|
if (pkt->getRemainingBytes() >= 68)
|
||||||
*pkt >> lighting.volumetric_beta_r0;
|
*pkt >> lighting.volumetric_beta_r0;
|
||||||
*pkt >> lighting.vignette.dark
|
*pkt >> lighting.vignette.dark
|
||||||
>> lighting.vignette.bright
|
>> lighting.vignette.bright
|
||||||
|
@ -1825,5 +1825,7 @@ void Client::handleCommand_SetLighting(NetworkPacket *pkt)
|
||||||
*pkt >> lighting.cdl.slope;
|
*pkt >> lighting.cdl.slope;
|
||||||
*pkt >> lighting.cdl.offset;
|
*pkt >> lighting.cdl.offset;
|
||||||
*pkt >> lighting.cdl.power;
|
*pkt >> lighting.cdl.power;
|
||||||
|
*pkt >> lighting.foliage_translucency;
|
||||||
|
*pkt >> lighting.specular_intensity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
Rename TOCLIENT_DEATHSCREEN to TOCLIENT_DEATHSCREEN_LEGACY
|
Rename TOCLIENT_DEATHSCREEN to TOCLIENT_DEATHSCREEN_LEGACY
|
||||||
Rename TOSERVER_RESPAWN to TOSERVER_RESPAWN_LEGACY
|
Rename TOSERVER_RESPAWN to TOSERVER_RESPAWN_LEGACY
|
||||||
Support float animation frame numbers in TOCLIENT_LOCAL_PLAYER_ANIMATIONS
|
Support float animation frame numbers in TOCLIENT_LOCAL_PLAYER_ANIMATIONS
|
||||||
Add beta_r0, vignette and cdl parameters to Lighting packets
|
Add beta_r0, vignette, specular intensity, foliage translucency and cdl parameters to Lighting packets
|
||||||
[scheduled bump for 5.10.0]
|
[scheduled bump for 5.10.0]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -2623,6 +2623,8 @@ int ObjectRef::l_set_lighting(lua_State *L)
|
||||||
lua_pop(L, 1); // shadows
|
lua_pop(L, 1); // shadows
|
||||||
|
|
||||||
getfloatfield(L, -1, "saturation", lighting.saturation);
|
getfloatfield(L, -1, "saturation", lighting.saturation);
|
||||||
|
getfloatfield(L, -1, "foliage_translucency", lighting.foliage_translucency);
|
||||||
|
getfloatfield(L, -1, "specular_intensity", lighting.specular_intensity);
|
||||||
|
|
||||||
lua_getfield(L, 2, "exposure");
|
lua_getfield(L, 2, "exposure");
|
||||||
if (lua_istable(L, -1)) {
|
if (lua_istable(L, -1)) {
|
||||||
|
@ -2700,6 +2702,10 @@ int ObjectRef::l_get_lighting(lua_State *L)
|
||||||
lua_newtable(L); // result
|
lua_newtable(L); // result
|
||||||
push_ARGB8(L, lighting.artificial_light_color);
|
push_ARGB8(L, lighting.artificial_light_color);
|
||||||
lua_setfield(L, -2, "artificial_light");
|
lua_setfield(L, -2, "artificial_light");
|
||||||
|
lua_pushnumber(L, lighting.foliage_translucency);
|
||||||
|
lua_setfield(L, -2, "foliage_translucency");
|
||||||
|
lua_pushnumber(L, lighting.specular_intensity);
|
||||||
|
lua_setfield(L, -2, "specular_intensity");
|
||||||
lua_newtable(L); // "shadows"
|
lua_newtable(L); // "shadows"
|
||||||
lua_pushnumber(L, lighting.shadow_intensity);
|
lua_pushnumber(L, lighting.shadow_intensity);
|
||||||
lua_setfield(L, -2, "intensity");
|
lua_setfield(L, -2, "intensity");
|
||||||
|
|
|
@ -1926,6 +1926,8 @@ void Server::SendSetLighting(session_t peer_id, const Lighting & lighting)
|
||||||
pkt << lighting.cdl.slope;
|
pkt << lighting.cdl.slope;
|
||||||
pkt << lighting.cdl.offset;
|
pkt << lighting.cdl.offset;
|
||||||
pkt << lighting.cdl.power;
|
pkt << lighting.cdl.power;
|
||||||
|
pkt << lighting.foliage_translucency;
|
||||||
|
pkt << lighting.specular_intensity;
|
||||||
|
|
||||||
Send(&pkt);
|
Send(&pkt);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue