mirror of
https://github.com/minetest/minetest.git
synced 2024-07-04 15:05:27 +02:00
Update loaded mapblocks meshes if luminance was set, added doc
This commit is contained in:
parent
02d0c826fe
commit
17a75185e1
@ -9,6 +9,7 @@ uniform float fogShadingParameter;
|
|||||||
uniform highp vec3 cameraOffset;
|
uniform highp vec3 cameraOffset;
|
||||||
uniform float animationTimer;
|
uniform float animationTimer;
|
||||||
|
|
||||||
|
uniform float ambientLight;
|
||||||
uniform vec3 ambientColor;
|
uniform vec3 ambientColor;
|
||||||
#ifdef ENABLE_DYNAMIC_SHADOWS
|
#ifdef ENABLE_DYNAMIC_SHADOWS
|
||||||
// shadow texture
|
// shadow texture
|
||||||
@ -377,7 +378,9 @@ void main(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
color = base.rgb;
|
color = base.rgb;
|
||||||
vec4 col = vec4(color.rgb * varColor.rgb * ambientColor.rgb, 1.0);
|
vec4 col = vec4(color.rgb * varColor.rgb, 1.0);
|
||||||
|
|
||||||
|
col.rgb += ambientLight * ambientColor.rgb;
|
||||||
|
|
||||||
#ifdef ENABLE_DYNAMIC_SHADOWS
|
#ifdef ENABLE_DYNAMIC_SHADOWS
|
||||||
if (f_shadow_strength > 0.0) {
|
if (f_shadow_strength > 0.0) {
|
||||||
|
@ -9,6 +9,7 @@ uniform float fogShadingParameter;
|
|||||||
uniform highp vec3 cameraOffset;
|
uniform highp vec3 cameraOffset;
|
||||||
uniform float animationTimer;
|
uniform float animationTimer;
|
||||||
|
|
||||||
|
uniform float ambientLight;
|
||||||
uniform vec3 ambientColor;
|
uniform vec3 ambientColor;
|
||||||
#ifdef ENABLE_DYNAMIC_SHADOWS
|
#ifdef ENABLE_DYNAMIC_SHADOWS
|
||||||
// shadow texture
|
// shadow texture
|
||||||
@ -380,7 +381,8 @@ void main(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
color = base.rgb;
|
color = base.rgb;
|
||||||
vec4 col = vec4(color.rgb * varColor.rgb * ambientColor.rgb, 1.0);
|
vec4 col = vec4(color.rgb * varColor.rgb, 1.0);
|
||||||
|
col.rgb += ambientLight * ambientColor.rgb;
|
||||||
col.rgb *= vIDiff;
|
col.rgb *= vIDiff;
|
||||||
|
|
||||||
#ifdef ENABLE_DYNAMIC_SHADOWS
|
#ifdef ENABLE_DYNAMIC_SHADOWS
|
||||||
|
@ -8395,6 +8395,9 @@ child will follow movement and rotation of that bone.
|
|||||||
* `set_lighting(light_definition)`: sets lighting for the player
|
* `set_lighting(light_definition)`: sets lighting for the player
|
||||||
* Passing no arguments resets lighting to its default values.
|
* Passing no arguments resets lighting to its default values.
|
||||||
* `light_definition` is a table with the following optional fields:
|
* `light_definition` is a table with the following optional fields:
|
||||||
|
* `ambient_light` is a table controlling amount and color of ambient light (global lighting)
|
||||||
|
* `luminance` sets the amount of ambient light in range (0... LIGHT_SUN) like `light_source` has (default: `0`)
|
||||||
|
* `color` sets the color of ambient light (ColorSpec) (default: `{a = 0, r = 0, g = 0, b = 0}`)
|
||||||
* `saturation` sets the saturation (vividness; default: `1.0`).
|
* `saturation` sets the saturation (vividness; default: `1.0`).
|
||||||
* values > 1 increase the saturation
|
* values > 1 increase the saturation
|
||||||
* values in [0,1] decrease the saturation
|
* values in [0,1] decrease the saturation
|
||||||
|
@ -623,6 +623,14 @@ void ClientMap::updateDrawList()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Force update meshes of all loaded mapblocks
|
||||||
|
if (m_update_mapblocks_meshes) {
|
||||||
|
m_update_mapblocks_meshes = false;
|
||||||
|
|
||||||
|
for (auto &p : m_drawlist)
|
||||||
|
m_client->addUpdateMeshTask(p.first, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
g_profiler->avg("MapBlocks occlusion culled [#]", blocks_occlusion_culled);
|
g_profiler->avg("MapBlocks occlusion culled [#]", blocks_occlusion_culled);
|
||||||
g_profiler->avg("MapBlocks frustum culled [#]", blocks_frustum_culled);
|
g_profiler->avg("MapBlocks frustum culled [#]", blocks_frustum_culled);
|
||||||
g_profiler->avg("MapBlocks drawn [#]", m_drawlist.size());
|
g_profiler->avg("MapBlocks drawn [#]", m_drawlist.size());
|
||||||
|
@ -112,6 +112,8 @@ class ClientMap : public Map, public scene::ISceneNode
|
|||||||
f32 getWantedRange() const { return m_control.wanted_range; }
|
f32 getWantedRange() const { return m_control.wanted_range; }
|
||||||
f32 getCameraFov() const { return m_camera_fov; }
|
f32 getCameraFov() const { return m_camera_fov; }
|
||||||
|
|
||||||
|
void forceUpdateMapblocksMeshes() { m_update_mapblocks_meshes = true; }
|
||||||
|
|
||||||
void onSettingChanged(const std::string &name);
|
void onSettingChanged(const std::string &name);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -195,4 +197,6 @@ class ClientMap : public Map, public scene::ISceneNode
|
|||||||
|
|
||||||
bool m_loops_occlusion_culler;
|
bool m_loops_occlusion_culler;
|
||||||
bool m_enable_raytraced_culling;
|
bool m_enable_raytraced_culling;
|
||||||
|
|
||||||
|
bool m_update_mapblocks_meshes;
|
||||||
};
|
};
|
||||||
|
@ -382,6 +382,7 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
|
|||||||
CachedPixelShaderSetting<float>
|
CachedPixelShaderSetting<float>
|
||||||
m_animation_timer_delta_pixel{"animationTimerDelta"};
|
m_animation_timer_delta_pixel{"animationTimerDelta"};
|
||||||
CachedPixelShaderSetting<float, 3> m_day_light{"dayLight"};
|
CachedPixelShaderSetting<float, 3> m_day_light{"dayLight"};
|
||||||
|
CachedPixelShaderSetting<float, 1> m_ambient_light{"ambientLight"};
|
||||||
CachedPixelShaderSetting<float, 3> m_ambient_color{"ambientColor"};
|
CachedPixelShaderSetting<float, 3> m_ambient_color{"ambientColor"};
|
||||||
CachedPixelShaderSetting<float, 3> m_minimap_yaw{"yawVec"};
|
CachedPixelShaderSetting<float, 3> m_minimap_yaw{"yawVec"};
|
||||||
CachedPixelShaderSetting<float, 3> m_camera_offset_pixel{"cameraOffset"};
|
CachedPixelShaderSetting<float, 3> m_camera_offset_pixel{"cameraOffset"};
|
||||||
@ -474,7 +475,13 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
|
|||||||
get_sunlight_color(&sunlight, daynight_ratio);
|
get_sunlight_color(&sunlight, daynight_ratio);
|
||||||
m_day_light.set(sunlight, services);
|
m_day_light.set(sunlight, services);
|
||||||
|
|
||||||
video::SColor ambient_color = m_client->getEnv().getLocalPlayer()->getLighting().ambient_light.color;
|
auto lighting = m_client->getEnv().getLocalPlayer()->getLighting();
|
||||||
|
|
||||||
|
float ambient_light = lighting.ambient_light.luminance / 16.f;
|
||||||
|
|
||||||
|
m_ambient_light.set(&ambient_light, services);
|
||||||
|
|
||||||
|
video::SColor ambient_color = lighting.ambient_light.color;
|
||||||
|
|
||||||
float ac_f[3] = {
|
float ac_f[3] = {
|
||||||
ambient_color.getRed()/255.f,
|
ambient_color.getRed()/255.f,
|
||||||
@ -514,7 +521,7 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
|
|||||||
m_texel_size0_vertex.set(m_texel_size0, services);
|
m_texel_size0_vertex.set(m_texel_size0, services);
|
||||||
m_texel_size0_pixel.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 AutoExposure &exposure_params = lighting.exposure;
|
||||||
std::array<float, 7> exposure_buffer = {
|
std::array<float, 7> exposure_buffer = {
|
||||||
std::pow(2.0f, exposure_params.luminance_min),
|
std::pow(2.0f, exposure_params.luminance_min),
|
||||||
std::pow(2.0f, exposure_params.luminance_max),
|
std::pow(2.0f, exposure_params.luminance_max),
|
||||||
@ -531,8 +538,6 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
|
|||||||
m_bloom_radius_pixel.set(&m_bloom_radius, services);
|
m_bloom_radius_pixel.set(&m_bloom_radius, services);
|
||||||
m_bloom_strength_pixel.set(&m_bloom_strength, services);
|
m_bloom_strength_pixel.set(&m_bloom_strength, services);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto &lighting = m_client->getEnv().getLocalPlayer()->getLighting();
|
|
||||||
float saturation = lighting.saturation;
|
float saturation = lighting.saturation;
|
||||||
m_saturation_pixel.set(&saturation, services);
|
m_saturation_pixel.set(&saturation, services);
|
||||||
|
|
||||||
@ -575,7 +580,6 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
|
|||||||
float moon_brightness = 0.f;
|
float moon_brightness = 0.f;
|
||||||
m_moon_brightness_pixel.set(&moon_brightness, services);
|
m_moon_brightness_pixel.set(&moon_brightness, services);
|
||||||
}
|
}
|
||||||
|
|
||||||
float volumetric_light_strength = lighting.volumetric_light_strength;
|
float volumetric_light_strength = lighting.volumetric_light_strength;
|
||||||
m_volumetric_light_strength_pixel.set(&volumetric_light_strength, services);
|
m_volumetric_light_strength_pixel.set(&volumetric_light_strength, services);
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
#include "skyparams.h"
|
#include "skyparams.h"
|
||||||
#include "particles.h"
|
#include "particles.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include "client/clientmap.h"
|
||||||
|
|
||||||
void Client::handleCommand_Deprecated(NetworkPacket* pkt)
|
void Client::handleCommand_Deprecated(NetworkPacket* pkt)
|
||||||
{
|
{
|
||||||
@ -1805,9 +1806,12 @@ void Client::handleCommand_SetLighting(NetworkPacket *pkt)
|
|||||||
*pkt >> lighting.shadow_intensity;
|
*pkt >> lighting.shadow_intensity;
|
||||||
if (pkt->getRemainingBytes() >= 4)
|
if (pkt->getRemainingBytes() >= 4)
|
||||||
*pkt >> lighting.saturation;
|
*pkt >> lighting.saturation;
|
||||||
if (pkt->getRemainingBytes() >= 1)
|
if (pkt->getRemainingBytes() >= 1) {
|
||||||
*pkt >> lighting.ambient_light.luminance
|
*pkt >> lighting.ambient_light.luminance
|
||||||
>> lighting.ambient_light.color;
|
>> lighting.ambient_light.color;
|
||||||
|
|
||||||
|
getEnv().getClientMap().forceUpdateMapblocksMeshes();
|
||||||
|
}
|
||||||
if (pkt->getRemainingBytes() >= 24) {
|
if (pkt->getRemainingBytes() >= 24) {
|
||||||
*pkt >> lighting.exposure.luminance_min
|
*pkt >> lighting.exposure.luminance_min
|
||||||
>> lighting.exposure.luminance_max
|
>> lighting.exposure.luminance_max
|
||||||
|
Loading…
Reference in New Issue
Block a user