1
0
Fork 0
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:
Gefüllte Taubenbrust 2024-12-20 15:00:01 +01:00
parent 45289b6919
commit b3710a982e
10 changed files with 34 additions and 13 deletions

View file

@ -32,6 +32,8 @@ uniform float animationTimer;
uniform float xyPerspectiveBias0;
uniform float xyPerspectiveBias1;
uniform vec3 shadow_tint;
uniform float foliage_translucency;
uniform float specular_intensity;
varying float adj_shadow_strength;
varying float cosLight;
@ -533,12 +535,9 @@ void main(void)
col.rgb += reflection_color * pow(fresnel_factor, 2.0) * 0.5 * brightness_factor;
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));
// 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
col.rgb += water_reflect_color * brightness_factor;
#endif
@ -547,23 +546,26 @@ void main(void)
// Apply specular to blocks.
if (dot(v_LightDirection, vNormal) < 0.0) {
// 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 fresnel_exponent = 4.0;
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);
}
#endif
#if (MATERIAL_TYPE == TILE_MATERIAL_WAVING_PLANTS || MATERIAL_TYPE == TILE_MATERIAL_WAVING_LEAVES) && defined(ENABLE_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
// 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 ?),
// the fog will only be rendered correctly if the last operation before the
// clamp() is an addition. Else, the clamp() seems to be ignored.

View file

@ -8786,6 +8786,10 @@ child will follow movement and rotation of that bone.
but keeping original luma and being symmetrical in terms of saturation
(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.
* `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
* 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)

View file

@ -196,7 +196,6 @@ void Clouds::updateMesh()
const f32 rz = cloud_size / 2;
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);

View file

@ -414,6 +414,8 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
CachedPixelShaderSetting<float> m_vignette_dark_pixel{"vignette_dark"};
CachedPixelShaderSetting<float> m_vignette_bright_pixel{"vignette_bright"};
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 = {
"exposure_compensation",
@ -531,6 +533,9 @@ public:
m_vignette_bright_pixel.set(&vignette_params.bright, 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")) {
const ColorDecisionList& cdl_params = lighting.cdl;
core::vector3df slope = cdl_params.slope;

View file

@ -176,7 +176,6 @@ void MeshUpdateQueue::done(v3s16 pos)
void MeshUpdateQueue::fillDataFromMapBlocks(QueuedMeshUpdate *q)
{
auto mesh_grid = m_client->getMeshGrid();
MeshMakeData *data = new MeshMakeData(m_client->ndef(), MAP_BLOCKSIZE * mesh_grid.cell_size);
q->data = data;

View file

@ -56,9 +56,9 @@ struct Vignette {
*
*/
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 power{1.25, 1.0, 0.9};
core::vector3df power{1.0, 1.0, 1.0};
};
/** Describes ambient light settings for a player
@ -71,6 +71,8 @@ struct Lighting
float shadow_intensity {0.0f};
float saturation {1.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
// for Nitrogen at 532nm (green), 2e25 molecules/m3 in atmosphere
core::vector3df volumetric_beta_r0{ 3.3362176e-01, 8.75378289198826e-01, 1.95342379700656 };

View file

@ -1817,7 +1817,7 @@ void Client::handleCommand_SetLighting(NetworkPacket *pkt)
>> lighting.bloom_radius;
if (pkt->getRemainingBytes() >= 4)
*pkt >> lighting.artificial_light_color;
if (pkt->getRemainingBytes() >= 60)
if (pkt->getRemainingBytes() >= 68)
*pkt >> lighting.volumetric_beta_r0;
*pkt >> lighting.vignette.dark
>> lighting.vignette.bright
@ -1825,5 +1825,7 @@ void Client::handleCommand_SetLighting(NetworkPacket *pkt)
*pkt >> lighting.cdl.slope;
*pkt >> lighting.cdl.offset;
*pkt >> lighting.cdl.power;
*pkt >> lighting.foliage_translucency;
*pkt >> lighting.specular_intensity;
}
}

View file

@ -58,7 +58,7 @@
Rename TOCLIENT_DEATHSCREEN to TOCLIENT_DEATHSCREEN_LEGACY
Rename TOSERVER_RESPAWN to TOSERVER_RESPAWN_LEGACY
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]
*/

View file

@ -2623,6 +2623,8 @@ int ObjectRef::l_set_lighting(lua_State *L)
lua_pop(L, 1); // shadows
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");
if (lua_istable(L, -1)) {
@ -2700,6 +2702,10 @@ int ObjectRef::l_get_lighting(lua_State *L)
lua_newtable(L); // result
push_ARGB8(L, lighting.artificial_light_color);
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_pushnumber(L, lighting.shadow_intensity);
lua_setfield(L, -2, "intensity");

View file

@ -1926,6 +1926,8 @@ void Server::SendSetLighting(session_t peer_id, const Lighting & lighting)
pkt << lighting.cdl.slope;
pkt << lighting.cdl.offset;
pkt << lighting.cdl.power;
pkt << lighting.foliage_translucency;
pkt << lighting.specular_intensity;
Send(&pkt);
}