mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add artificial light control
This commit is contained in:
parent
dd475d8af4
commit
ded1b09838
8 changed files with 24 additions and 4 deletions
|
@ -46,7 +46,7 @@ varying float area_enable_parallax;
|
|||
varying highp vec3 eyeVec;
|
||||
varying float nightRatio;
|
||||
// Color of the light emitted by the light sources.
|
||||
const vec3 artificialLight = vec3(1.04, 1.04, 1.04);
|
||||
uniform vec3 artificialLight;
|
||||
const float e = 2.718281828459;
|
||||
const float BS = 10.0;
|
||||
uniform float xyPerspectiveBias0;
|
||||
|
@ -211,7 +211,7 @@ void main(void)
|
|||
// The alpha gives the ratio of sunlight in the incoming light.
|
||||
nightRatio = 1.0 - color.a;
|
||||
color.rgb = color.rgb * (color.a * dayLight.rgb +
|
||||
nightRatio * artificialLight.rgb) * 2.0;
|
||||
nightRatio * 2.0 * artificialLight.rgb) * 2.0;
|
||||
color.a = 1.0;
|
||||
|
||||
// Emphase blue a bit in darker places
|
||||
|
|
|
@ -33,7 +33,7 @@ centroid varying vec2 varTexCoord;
|
|||
varying highp vec3 eyeVec;
|
||||
varying float nightRatio;
|
||||
// Color of the light emitted by the light sources.
|
||||
const vec3 artificialLight = vec3(1.04, 1.04, 1.04);
|
||||
uniform vec3 artificialLight;
|
||||
varying float vIDiff;
|
||||
const float e = 2.718281828459;
|
||||
const float BS = 10.0;
|
||||
|
@ -120,7 +120,7 @@ void main(void)
|
|||
// The alpha gives the ratio of sunlight in the incoming light.
|
||||
nightRatio = 1.0 - color.a;
|
||||
color.rgb = color.rgb * (color.a * dayLight.rgb +
|
||||
nightRatio * artificialLight.rgb) * 2.0;
|
||||
nightRatio * 2.0 * artificialLight.rgb) * 2.0;
|
||||
color.a = 1.0;
|
||||
|
||||
// Emphase blue a bit in darker places
|
||||
|
|
|
@ -381,6 +381,7 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
|
|||
m_animation_timer_delta_vertex{"animationTimerDelta"};
|
||||
CachedPixelShaderSetting<float>
|
||||
m_animation_timer_delta_pixel{"animationTimerDelta"};
|
||||
CachedPixelShaderSetting<float, 3> m_artificial_light{ "artificialLight" };
|
||||
CachedPixelShaderSetting<float, 3> m_day_light{"dayLight"};
|
||||
CachedPixelShaderSetting<float, 3> m_minimap_yaw{"yawVec"};
|
||||
CachedPixelShaderSetting<float, 3> m_camera_offset_pixel{"cameraOffset"};
|
||||
|
@ -525,6 +526,8 @@ public:
|
|||
const auto &lighting = m_client->getEnv().getLocalPlayer()->getLighting();
|
||||
float saturation = lighting.saturation;
|
||||
m_saturation_pixel.set(&saturation, services);
|
||||
video::SColorf artificial_light = lighting.artificial_light_color;
|
||||
m_artificial_light.set(artificial_light, services);
|
||||
|
||||
if (m_volumetric_light_enabled) {
|
||||
// Map directional light to screen space
|
||||
|
|
|
@ -18,7 +18,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
*/
|
||||
|
||||
#pragma once
|
||||
#include <SColor.h>
|
||||
|
||||
using namespace irr;
|
||||
|
||||
/**
|
||||
* Parameters for automatic exposure compensation
|
||||
|
@ -54,4 +56,5 @@ struct Lighting
|
|||
float shadow_intensity {0.0f};
|
||||
float saturation {1.0f};
|
||||
float volumetric_light_strength {0.0f};
|
||||
video::SColor artificial_light_color{ 133, 133, 133, 255 };
|
||||
};
|
||||
|
|
|
@ -1815,4 +1815,6 @@ void Client::handleCommand_SetLighting(NetworkPacket *pkt)
|
|||
}
|
||||
if (pkt->getRemainingBytes() >= 4)
|
||||
*pkt >> lighting.volumetric_light_strength;
|
||||
if (pkt->getRemainingBytes() >= 4)
|
||||
*pkt >> lighting.artificial_light_color;
|
||||
}
|
||||
|
|
|
@ -224,6 +224,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
Add TOCLIENT_MOVE_PLAYER_REL
|
||||
Move default minimap from client-side C++ to server-side builtin Lua
|
||||
[scheduled bump for 5.9.0]
|
||||
Add artificial light color packet
|
||||
*/
|
||||
|
||||
#define LATEST_PROTOCOL_VERSION 44
|
||||
|
|
|
@ -2528,6 +2528,13 @@ int ObjectRef::l_set_lighting(lua_State *L)
|
|||
if (!lua_isnoneornil(L, 2)) {
|
||||
luaL_checktype(L, 2, LUA_TTABLE);
|
||||
lighting = player->getLighting();
|
||||
|
||||
lua_getfield(L, 2, "artificial_light");
|
||||
if (!lua_isnil(L, -1)) {
|
||||
read_color(L, -1, &lighting.artificial_light_color);
|
||||
}
|
||||
lua_pop(L, 1); // artificial_light
|
||||
|
||||
lua_getfield(L, 2, "shadows");
|
||||
if (lua_istable(L, -1)) {
|
||||
getfloatfield(L, -1, "intensity", lighting.shadow_intensity);
|
||||
|
@ -2571,6 +2578,8 @@ int ObjectRef::l_get_lighting(lua_State *L)
|
|||
const Lighting &lighting = player->getLighting();
|
||||
|
||||
lua_newtable(L); // result
|
||||
push_ARGB8(L, lighting.artificial_light_color);
|
||||
lua_setfield(L, -2, "artificial_light");
|
||||
lua_newtable(L); // "shadows"
|
||||
lua_pushnumber(L, lighting.shadow_intensity);
|
||||
lua_setfield(L, -2, "intensity");
|
||||
|
|
|
@ -1895,6 +1895,8 @@ void Server::SendSetLighting(session_t peer_id, const Lighting &lighting)
|
|||
|
||||
pkt << lighting.volumetric_light_strength;
|
||||
|
||||
pkt << lighting.artificial_light_color;
|
||||
|
||||
Send(&pkt);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue