mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Various changes, fixes and features
This commit is contained in:
parent
b6c099073f
commit
4b88a32c1c
17 changed files with 409 additions and 261 deletions
|
@ -53,8 +53,7 @@ Clouds::Clouds(scene::ISceneManager* mgr, IShaderSource *ssrc,
|
|||
m_material.FogEnable = true;
|
||||
m_material.AntiAliasing = video::EAAM_SIMPLE;
|
||||
if (m_enable_shaders) {
|
||||
bool shaded_clouds = g_settings->getBool("soft_clouds") && g_settings->getBool("enable_dynamic_shadows");
|
||||
auto sid = ssrc->getShader(shaded_clouds ? "soft_clouds" : "cloud_shader", TILE_MATERIAL_ALPHA);
|
||||
auto sid = ssrc->getShader("cloud_shader", TILE_MATERIAL_ALPHA);
|
||||
m_material.MaterialType = ssrc->getShaderInfo(sid).material;
|
||||
} else {
|
||||
m_material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
|
@ -226,210 +225,137 @@ void Clouds::updateMesh()
|
|||
|
||||
v3f pos(p0.X, m_params.height * BS, p0.Y);
|
||||
|
||||
if (shaded_clouds_enabled) {
|
||||
bool neighbours[4] = {false, false, false, false};
|
||||
if (INAREA(xi - 1, zi, m_cloud_radius_i))
|
||||
neighbours[0] = grid[GETINDEX(xi - 1, zi, m_cloud_radius_i)];
|
||||
if (INAREA(xi, zi - 1, m_cloud_radius_i))
|
||||
neighbours[1] = grid[GETINDEX(xi, zi - 1, m_cloud_radius_i)];
|
||||
if (INAREA(xi + 1, zi, m_cloud_radius_i))
|
||||
neighbours[2] = grid[GETINDEX(xi + 1, zi, m_cloud_radius_i)];
|
||||
if (INAREA(xi, zi + 1, m_cloud_radius_i))
|
||||
neighbours[3] = grid[GETINDEX(xi, zi + 1, m_cloud_radius_i)];
|
||||
video::S3DVertex v[4] = {
|
||||
video::S3DVertex(0,0,0, 0,0,0, c_top, 0, 1),
|
||||
video::S3DVertex(0,0,0, 0,0,0, c_top, 1, 1),
|
||||
video::S3DVertex(0,0,0, 0,0,0, c_top, 1, 0),
|
||||
video::S3DVertex(0,0,0, 0,0,0, c_top, 0, 0)
|
||||
};
|
||||
|
||||
video::S3DVertex v[32];
|
||||
v[ 0].Pos = core::vector3df( -rx, ry, -rz);
|
||||
v[ 1].Pos = core::vector3df(-0.75 * rx, ry, -rz);
|
||||
v[ 2].Pos = core::vector3df( 0.75 * rx, ry, -rz);
|
||||
v[ 3].Pos = core::vector3df( rx, ry, -rz);
|
||||
v[ 4].Pos = core::vector3df( -rx, ry, -0.75 * rz);
|
||||
v[ 5].Pos = core::vector3df(-0.75 * rx, ry, -0.75 * rz);
|
||||
v[ 6].Pos = core::vector3df( 0.75 * rx, ry, -0.75 * rz);
|
||||
v[ 7].Pos = core::vector3df( rx, ry, -0.75 * rz);
|
||||
v[ 8].Pos = core::vector3df( -rx, ry, 0.75 * rz);
|
||||
v[ 9].Pos = core::vector3df(-0.75 * rx, ry, 0.75 * rz);
|
||||
v[10].Pos = core::vector3df( 0.75 * rx, ry, 0.75 * rz);
|
||||
v[11].Pos = core::vector3df( rx, ry, 0.75 * rz);
|
||||
v[12].Pos = core::vector3df( -rx, ry, rz);
|
||||
v[13].Pos = core::vector3df(-0.75 * rx, ry, rz);
|
||||
v[14].Pos = core::vector3df( 0.75 * rx, ry, rz);
|
||||
v[15].Pos = core::vector3df( rx, ry, rz);
|
||||
|
||||
// These normals are intentionally left unnormalized
|
||||
if (neighbours[0]) {
|
||||
v[ 0].Normal.X -= 1.0;
|
||||
v[ 4].Normal.X -= 1.0;
|
||||
v[ 8].Normal.X -= 1.0;
|
||||
v[12].Normal.X -= 1.0;
|
||||
}
|
||||
if (neighbours[1]) {
|
||||
v[0].Normal.Z -= 1.0;
|
||||
v[1].Normal.Z -= 1.0;
|
||||
v[2].Normal.Z -= 1.0;
|
||||
v[3].Normal.Z -= 1.0;
|
||||
}
|
||||
if (neighbours[2]) {
|
||||
v[ 3].Normal.X += 1.0;
|
||||
v[ 7].Normal.X += 1.0;
|
||||
v[11].Normal.X += 1.0;
|
||||
v[15].Normal.X += 1.0;
|
||||
}
|
||||
if (neighbours[3]) {
|
||||
v[12].Normal.Z += 1.0;
|
||||
v[13].Normal.Z += 1.0;
|
||||
v[14].Normal.Z += 1.0;
|
||||
v[15].Normal.Z += 1.0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 16; ++i) {
|
||||
v[i + 32] = v[i];
|
||||
v[i + 32].Pos.Y = -ry;
|
||||
|
||||
v[i].Normal = core::vector3df(0.0, 1.0, 0.0);
|
||||
v[i + 32].Normal = core::vector3df(0.0, -1.0, 0.0);
|
||||
for (u32 i = 0; i < num_faces_to_draw; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: // top
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Normal.set(0, 1, 0);
|
||||
}
|
||||
v[0].Pos.set(-rx, ry, -rz);
|
||||
v[1].Pos.set(-rx, ry, rz);
|
||||
v[2].Pos.set(rx, ry, rz);
|
||||
v[3].Pos.set(rx, ry, -rz);
|
||||
break;
|
||||
case 1: // back
|
||||
if (INAREA(xi, zi - 1, m_cloud_radius_i)) {
|
||||
u32 j = GETINDEX(xi, zi - 1, m_cloud_radius_i);
|
||||
if (grid[j])
|
||||
continue;
|
||||
}
|
||||
if (soft_clouds_enabled) {
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Normal.set(0, 0, -1);
|
||||
}
|
||||
v[2].Color = c_bottom;
|
||||
v[3].Color = c_bottom;
|
||||
}
|
||||
else {
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Color = c_side_1;
|
||||
vertex.Normal.set(0, 0, -1);
|
||||
}
|
||||
}
|
||||
v[0].Pos.set(-rx, ry, -rz);
|
||||
v[1].Pos.set(rx, ry, -rz);
|
||||
v[2].Pos.set(rx, 0, -rz);
|
||||
v[3].Pos.set(-rx, 0, -rz);
|
||||
break;
|
||||
case 2: //right
|
||||
if (INAREA(xi + 1, zi, m_cloud_radius_i)) {
|
||||
u32 j = GETINDEX(xi + 1, zi, m_cloud_radius_i);
|
||||
if (grid[j])
|
||||
continue;
|
||||
}
|
||||
if (soft_clouds_enabled) {
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Normal.set(1, 0, 0);
|
||||
}
|
||||
v[2].Color = c_bottom;
|
||||
v[3].Color = c_bottom;
|
||||
}
|
||||
else {
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Color = c_side_2;
|
||||
vertex.Normal.set(1, 0, 0);
|
||||
}
|
||||
}
|
||||
v[0].Pos.set(rx, ry, -rz);
|
||||
v[1].Pos.set(rx, ry, rz);
|
||||
v[2].Pos.set(rx, 0, rz);
|
||||
v[3].Pos.set(rx, 0, -rz);
|
||||
break;
|
||||
case 3: // front
|
||||
if (INAREA(xi, zi + 1, m_cloud_radius_i)) {
|
||||
u32 j = GETINDEX(xi, zi + 1, m_cloud_radius_i);
|
||||
if (grid[j])
|
||||
continue;
|
||||
}
|
||||
if (soft_clouds_enabled) {
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Normal.set(0, 0, -1);
|
||||
}
|
||||
v[2].Color = c_bottom;
|
||||
v[3].Color = c_bottom;
|
||||
}
|
||||
else {
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Color = c_side_1;
|
||||
vertex.Normal.set(0, 0, -1);
|
||||
}
|
||||
}
|
||||
v[0].Pos.set(rx, ry, rz);
|
||||
v[1].Pos.set(-rx, ry, rz);
|
||||
v[2].Pos.set(-rx, 0, rz);
|
||||
v[3].Pos.set(rx, 0, rz);
|
||||
break;
|
||||
case 4: // left
|
||||
if (INAREA(xi - 1, zi, m_cloud_radius_i)) {
|
||||
u32 j = GETINDEX(xi - 1, zi, m_cloud_radius_i);
|
||||
if (grid[j])
|
||||
continue;
|
||||
}
|
||||
if (soft_clouds_enabled) {
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Normal.set(-1, 0, 0);
|
||||
}
|
||||
v[2].Color = c_bottom;
|
||||
v[3].Color = c_bottom;
|
||||
}
|
||||
else {
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Color = c_side_2;
|
||||
vertex.Normal.set(-1, 0, 0);
|
||||
}
|
||||
}
|
||||
v[0].Pos.set(-rx, ry, rz);
|
||||
v[1].Pos.set(-rx, ry, -rz);
|
||||
v[2].Pos.set(-rx, 0, -rz);
|
||||
v[3].Pos.set(-rx, 0, rz);
|
||||
break;
|
||||
case 5: // bottom
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Color = c_bottom;
|
||||
vertex.Normal.set(0, -1, 0);
|
||||
}
|
||||
v[0].Pos.set(rx, 0, rz);
|
||||
v[1].Pos.set(-rx, 0, rz);
|
||||
v[2].Pos.set(-rx, 0, -rz);
|
||||
v[3].Pos.set(rx, 0, -rz);
|
||||
break;
|
||||
}
|
||||
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Color = shadow.toSColor();
|
||||
vertex.Pos += pos;
|
||||
}
|
||||
|
||||
//top
|
||||
|
||||
}
|
||||
else {
|
||||
video::S3DVertex v[4] = {
|
||||
video::S3DVertex(0,0,0, 0,0,0, c_top, 0, 1),
|
||||
video::S3DVertex(0,0,0, 0,0,0, c_top, 1, 1),
|
||||
video::S3DVertex(0,0,0, 0,0,0, c_top, 1, 0),
|
||||
video::S3DVertex(0,0,0, 0,0,0, c_top, 0, 0)
|
||||
};
|
||||
|
||||
for (u32 i = 0; i < num_faces_to_draw; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 0: // top
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Normal.set(0, 1, 0);
|
||||
}
|
||||
v[0].Pos.set(-rx, ry, -rz);
|
||||
v[1].Pos.set(-rx, ry, rz);
|
||||
v[2].Pos.set(rx, ry, rz);
|
||||
v[3].Pos.set(rx, ry, -rz);
|
||||
break;
|
||||
case 1: // back
|
||||
if (INAREA(xi, zi - 1, m_cloud_radius_i)) {
|
||||
u32 j = GETINDEX(xi, zi - 1, m_cloud_radius_i);
|
||||
if (grid[j])
|
||||
continue;
|
||||
}
|
||||
if (soft_clouds_enabled) {
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Normal.set(0, 0, -1);
|
||||
}
|
||||
v[2].Color = c_bottom;
|
||||
v[3].Color = c_bottom;
|
||||
}
|
||||
else {
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Color = c_side_1;
|
||||
vertex.Normal.set(0, 0, -1);
|
||||
}
|
||||
}
|
||||
v[0].Pos.set(-rx, ry, -rz);
|
||||
v[1].Pos.set(rx, ry, -rz);
|
||||
v[2].Pos.set(rx, 0, -rz);
|
||||
v[3].Pos.set(-rx, 0, -rz);
|
||||
break;
|
||||
case 2: //right
|
||||
if (INAREA(xi + 1, zi, m_cloud_radius_i)) {
|
||||
u32 j = GETINDEX(xi + 1, zi, m_cloud_radius_i);
|
||||
if (grid[j])
|
||||
continue;
|
||||
}
|
||||
if (soft_clouds_enabled) {
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Normal.set(1, 0, 0);
|
||||
}
|
||||
v[2].Color = c_bottom;
|
||||
v[3].Color = c_bottom;
|
||||
}
|
||||
else {
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Color = c_side_2;
|
||||
vertex.Normal.set(1, 0, 0);
|
||||
}
|
||||
}
|
||||
v[0].Pos.set(rx, ry, -rz);
|
||||
v[1].Pos.set(rx, ry, rz);
|
||||
v[2].Pos.set(rx, 0, rz);
|
||||
v[3].Pos.set(rx, 0, -rz);
|
||||
break;
|
||||
case 3: // front
|
||||
if (INAREA(xi, zi + 1, m_cloud_radius_i)) {
|
||||
u32 j = GETINDEX(xi, zi + 1, m_cloud_radius_i);
|
||||
if (grid[j])
|
||||
continue;
|
||||
}
|
||||
if (soft_clouds_enabled) {
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Normal.set(0, 0, -1);
|
||||
}
|
||||
v[2].Color = c_bottom;
|
||||
v[3].Color = c_bottom;
|
||||
}
|
||||
else {
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Color = c_side_1;
|
||||
vertex.Normal.set(0, 0, -1);
|
||||
}
|
||||
}
|
||||
v[0].Pos.set(rx, ry, rz);
|
||||
v[1].Pos.set(-rx, ry, rz);
|
||||
v[2].Pos.set(-rx, 0, rz);
|
||||
v[3].Pos.set(rx, 0, rz);
|
||||
break;
|
||||
case 4: // left
|
||||
if (INAREA(xi - 1, zi, m_cloud_radius_i)) {
|
||||
u32 j = GETINDEX(xi - 1, zi, m_cloud_radius_i);
|
||||
if (grid[j])
|
||||
continue;
|
||||
}
|
||||
if (soft_clouds_enabled) {
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Normal.set(-1, 0, 0);
|
||||
}
|
||||
v[2].Color = c_bottom;
|
||||
v[3].Color = c_bottom;
|
||||
}
|
||||
else {
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Color = c_side_2;
|
||||
vertex.Normal.set(-1, 0, 0);
|
||||
}
|
||||
}
|
||||
v[0].Pos.set(-rx, ry, rz);
|
||||
v[1].Pos.set(-rx, ry, -rz);
|
||||
v[2].Pos.set(-rx, 0, -rz);
|
||||
v[3].Pos.set(-rx, 0, rz);
|
||||
break;
|
||||
case 5: // bottom
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Color = c_bottom;
|
||||
vertex.Normal.set(0, -1, 0);
|
||||
}
|
||||
v[0].Pos.set(rx, 0, rz);
|
||||
v[1].Pos.set(-rx, 0, rz);
|
||||
v[2].Pos.set(-rx, 0, -rz);
|
||||
v[3].Pos.set(rx, 0, -rz);
|
||||
break;
|
||||
}
|
||||
|
||||
for (video::S3DVertex& vertex : v) {
|
||||
vertex.Pos += pos;
|
||||
vertices.push_back(vertex);
|
||||
}
|
||||
vertices.push_back(vertex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -395,8 +395,6 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
|
|||
CachedPixelShaderSetting<float, 16> m_camera_projinv_pixel{"mCameraProjInv"};
|
||||
CachedVertexShaderSetting<float, 16> m_camera_view_vertex{"mCameraView"};
|
||||
CachedPixelShaderSetting<float, 16> m_camera_view_pixel{"mCameraView"};
|
||||
CachedPixelShaderSetting<float> m_camera_near_pixel{"cameraNear"};
|
||||
CachedPixelShaderSetting<float> m_camera_far_pixel{"cameraFar"};
|
||||
CachedPixelShaderSetting<SamplerLayer_t> m_texture0{"texture0"};
|
||||
CachedPixelShaderSetting<SamplerLayer_t> m_texture1{"texture1"};
|
||||
CachedPixelShaderSetting<SamplerLayer_t> m_texture2{"texture2"};
|
||||
|
@ -428,6 +426,18 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter
|
|||
CachedPixelShaderSetting<float> m_moon_brightness_pixel{"moonBrightness"};
|
||||
CachedPixelShaderSetting<float>
|
||||
m_volumetric_light_strength_pixel{"volumetricLightStrength"};
|
||||
CachedPixelShaderSetting<float, 3>
|
||||
m_volumetric_beta_r0_pixel{ "beta_r0_l" };
|
||||
CachedVertexShaderSetting<float, 3>
|
||||
m_volumetric_beta_r0_vertex{ "beta_r0_l" };
|
||||
CachedPixelShaderSetting<float, 3> m_cdl_slope_pixel{"cdl_slope"};
|
||||
CachedPixelShaderSetting<float, 3> m_cdl_offset_pixel{"cdl_offset"};
|
||||
CachedPixelShaderSetting<float, 3> m_cdl_power_pixel{"cdl_power"};
|
||||
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_fov_pixel{"fov"};
|
||||
CachedPixelShaderSetting<float, 2> m_window_size_pixel{"windowSize"};
|
||||
|
||||
static constexpr std::array<const char*, 1> SETTING_CALLBACKS = {
|
||||
"exposure_compensation",
|
||||
|
@ -457,6 +467,7 @@ public:
|
|||
m_user_exposure_compensation = g_settings->getFloat("exposure_compensation", -1.0f, 1.0f);
|
||||
m_bloom_enabled = g_settings->getBool("enable_bloom");
|
||||
m_volumetric_light_enabled = g_settings->getBool("enable_volumetric_lighting") && m_bloom_enabled;
|
||||
m_gamma = g_settings->getFloat("secondstage_gamma");
|
||||
}
|
||||
|
||||
~GameGlobalShaderConstantSetter()
|
||||
|
@ -506,10 +517,11 @@ public:
|
|||
m_camera_view_vertex.set(camera_view, services);
|
||||
m_camera_view_pixel.set(camera_view, services);
|
||||
|
||||
float camera_near = m_client->getCamera()->getCameraNode()->getNearValue();
|
||||
m_camera_near_pixel.set(&camera_near, services);
|
||||
float camera_far = m_client->getCamera()->getCameraNode()->getFarValue();
|
||||
m_camera_far_pixel.set(&camera_far, services);
|
||||
float fov = m_client->getCamera()->getFovMax();
|
||||
m_fov_pixel.set(&fov, services);
|
||||
v2u32 window_size_int = RenderingEngine::getWindowSize();
|
||||
core::vector2df window_size = core::vector2df(window_size_int.X, window_size_int.Y);
|
||||
m_window_size_pixel.set(window_size, services);
|
||||
|
||||
SamplerLayer_t tex_id;
|
||||
tex_id = 0;
|
||||
|
@ -552,6 +564,26 @@ public:
|
|||
video::SColorf artificial_light = lighting.artificial_light_color;
|
||||
m_artificial_light.set(artificial_light, services);
|
||||
|
||||
float gamma = m_gamma;
|
||||
m_gamma_pixel.set(&gamma, services);
|
||||
|
||||
if (g_settings->getBool("enable_vignette")) {
|
||||
const Vignette &vignette_params = lighting.vignette;
|
||||
m_vignette_dark_pixel.set(&vignette_params.dark, services);
|
||||
m_vignette_bright_pixel.set(&vignette_params.bright, services);
|
||||
m_vignette_power_pixel.set(&vignette_params.power, services);
|
||||
}
|
||||
|
||||
if (g_settings->getBool("enable_color_grading")) {
|
||||
const ColorDecisionList& cdl_params = lighting.cdl;
|
||||
core::vector3df slope = cdl_params.slope;
|
||||
m_cdl_slope_pixel.set(slope, services);
|
||||
core::vector3df offset = cdl_params.offset;
|
||||
m_cdl_offset_pixel.set(offset, services);
|
||||
core::vector3df power = cdl_params.power;
|
||||
m_cdl_power_pixel.set(power, services);
|
||||
}
|
||||
|
||||
if (m_volumetric_light_enabled) {
|
||||
// Map directional light to screen space
|
||||
auto camera_node = m_client->getCamera()->getCameraNode();
|
||||
|
@ -594,6 +626,10 @@ public:
|
|||
|
||||
float volumetric_light_strength = lighting.volumetric_light_strength;
|
||||
m_volumetric_light_strength_pixel.set(&volumetric_light_strength, services);
|
||||
|
||||
core::vector3df beta_r0 = lighting.volumetric_beta_r0;
|
||||
m_volumetric_beta_r0_vertex.set(beta_r0, services);
|
||||
m_volumetric_beta_r0_pixel.set(beta_r0, services);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -727,6 +727,9 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
|
|||
if (shadow_soft_radius < 1.0f)
|
||||
shadow_soft_radius = 1.0f;
|
||||
shaders_header << "#define SOFTSHADOWRADIUS " << shadow_soft_radius << "\n";
|
||||
|
||||
if (g_settings->getBool("enable_sun_tint"))
|
||||
shaders_header << "#define ENABLE_TINTED_SUNLIGHT 1\n";
|
||||
}
|
||||
|
||||
if (g_settings->getBool("enable_bloom")) {
|
||||
|
@ -757,6 +760,10 @@ ShaderInfo ShaderSource::generateShader(const std::string &name,
|
|||
shaders_header << "#define VOLUMETRIC_LIGHT 1\n";
|
||||
}
|
||||
|
||||
if (g_settings->getBool("enable_volumetric_depth_attenuation")) {
|
||||
shaders_header << "#define VOLUMETRIC_DEPTH_ATTENUATION 1\n";
|
||||
}
|
||||
|
||||
shaders_header << "#line 0\n"; // reset the line counter for meaningful diagnostics
|
||||
|
||||
std::string common_header = shaders_header.str();
|
||||
|
|
|
@ -344,12 +344,13 @@ void set_default_settings()
|
|||
settings->setDefault("enable_auto_exposure", "false");
|
||||
settings->setDefault("enable_color_grading", "false");
|
||||
settings->setDefault("enable_vignette", "false");
|
||||
settings->setDefault("gamma", "1.6");
|
||||
settings->setDefault("secondstage_gamma", "1.6");
|
||||
settings->setDefault("debanding", "true");
|
||||
settings->setDefault("antialiasing", "none");
|
||||
settings->setDefault("enable_bloom", "false");
|
||||
settings->setDefault("enable_bloom_debug", "false");
|
||||
settings->setDefault("enable_volumetric_lighting", "false");
|
||||
settings->setDefault("enable_volumetric_depth_attenuation", "false");
|
||||
settings->setDefault("enable_bumpmaps", "false");
|
||||
settings->setDefault("enable_water_reflections", "false");
|
||||
settings->setDefault("enable_translucent_foliage", "false");
|
||||
|
@ -368,6 +369,7 @@ void set_default_settings()
|
|||
settings->setDefault("shadow_update_frames", "8");
|
||||
settings->setDefault("shadow_soft_radius", "5.0");
|
||||
settings->setDefault("shadow_sky_body_orbit_tilt", "0.0");
|
||||
settings->setDefault("enable_sun_tint", "false");
|
||||
|
||||
// Input
|
||||
settings->setDefault("invert_mouse", "false");
|
||||
|
|
|
@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
|
||||
#pragma once
|
||||
#include "SColor.h"
|
||||
#include "vector3d.h"
|
||||
|
||||
using namespace irr;
|
||||
|
||||
|
@ -48,14 +49,46 @@ struct AutoExposure
|
|||
AutoExposure();
|
||||
};
|
||||
|
||||
/**
|
||||
* Parameters for vignette in post
|
||||
*
|
||||
*/
|
||||
struct Vignette {
|
||||
/// @brief The darkest part of the vignette will be darkened/brightened by this factor.
|
||||
float dark = 0.3f;
|
||||
/// @brief The brightest part of the vignette will be darkened/brightened by this factor.
|
||||
float bright = 1.1f;
|
||||
/// @brief Describes the blending between dark and bright. Higher values mean darkening is more intense at the screen edges.
|
||||
float power = 1.1f;
|
||||
};
|
||||
|
||||
/**
|
||||
* ASL CDL parameters
|
||||
*
|
||||
* Colors in ASL CDL follow the following equation:
|
||||
*
|
||||
* out = pow(in * slope + offset, power)
|
||||
*
|
||||
*/
|
||||
struct ColorDecisionList {
|
||||
core::vector3df slope{1.2, 1.0, 0.8};
|
||||
core::vector3df offset{0.0, 0.0, 0.0};
|
||||
core::vector3df power{1.25, 1.0, 0.9};
|
||||
};
|
||||
|
||||
/** Describes ambient light settings for a player
|
||||
*/
|
||||
struct Lighting
|
||||
{
|
||||
AutoExposure exposure;
|
||||
Vignette vignette;
|
||||
ColorDecisionList cdl;
|
||||
float shadow_intensity {0.0f};
|
||||
float saturation {1.0f};
|
||||
float volumetric_light_strength {0.0f};
|
||||
// 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 };
|
||||
video::SColor artificial_light_color{ 255, 133, 133, 133 };
|
||||
video::SColor shadow_tint {255, 0, 0, 0};
|
||||
float bloom_intensity {0.05f};
|
||||
|
|
|
@ -1830,5 +1830,13 @@ void Client::handleCommand_SetLighting(NetworkPacket *pkt)
|
|||
>> lighting.bloom_radius;
|
||||
if (pkt->getRemainingBytes() >= 4)
|
||||
*pkt >> lighting.artificial_light_color;
|
||||
if (pkt->getRemainingBytes() >= 60)
|
||||
*pkt >> lighting.volumetric_beta_r0;
|
||||
*pkt >> lighting.vignette.dark
|
||||
>> lighting.vignette.bright
|
||||
>> lighting.vignette.power;
|
||||
*pkt >> lighting.cdl.slope;
|
||||
*pkt >> lighting.cdl.offset;
|
||||
*pkt >> lighting.cdl.power;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,6 +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
|
||||
[scheduled bump for 5.10.0]
|
||||
*/
|
||||
|
||||
|
|
|
@ -2654,6 +2654,12 @@ int ObjectRef::l_set_lighting(lua_State *L)
|
|||
if (lua_istable(L, -1)) {
|
||||
getfloatfield(L, -1, "strength", lighting.volumetric_light_strength);
|
||||
lighting.volumetric_light_strength = rangelim(lighting.volumetric_light_strength, 0.0f, 1.0f);
|
||||
|
||||
lua_getfield(L, -1, "beta_r0");
|
||||
if (!lua_isnil(L, -1)) {
|
||||
lighting.volumetric_beta_r0 = read_v3f(L, -1);
|
||||
}
|
||||
lua_pop(L, 1); // beta_r0
|
||||
}
|
||||
lua_pop(L, 1); // volumetric_light
|
||||
|
||||
|
@ -2664,6 +2670,31 @@ int ObjectRef::l_set_lighting(lua_State *L)
|
|||
lighting.bloom_radius = getfloatfield_default(L, -1, "radius", lighting.bloom_radius);
|
||||
}
|
||||
lua_pop(L, 1); // bloom
|
||||
|
||||
lua_getfield(L, 2, "vignette");
|
||||
if (lua_istable(L, -1)) {
|
||||
lighting.vignette.dark = getfloatfield_default(L, -1, "dark", lighting.vignette.dark);
|
||||
lighting.vignette.bright = getfloatfield_default(L, -1, "bright", lighting.vignette.bright);
|
||||
lighting.vignette.power = getfloatfield_default(L, -1, "power", lighting.vignette.power);
|
||||
}
|
||||
lua_pop(L, 1); // vignette
|
||||
|
||||
lua_getfield(L, 2, "cdl");
|
||||
if (lua_istable(L, -1)) {
|
||||
lua_getfield(L, -1, "slope");
|
||||
if (!lua_isnil(L, -1))
|
||||
lighting.cdl.slope = read_v3f(L, -1);
|
||||
lua_pop(L, 1); // slope
|
||||
lua_getfield(L, -1, "offset");
|
||||
if (!lua_isnil(L, -1))
|
||||
lighting.cdl.offset = read_v3f(L, -1);
|
||||
lua_pop(L, 1); // offset
|
||||
lua_getfield(L, -1, "power");
|
||||
if (!lua_isnil(L, -1))
|
||||
lighting.cdl.power = read_v3f(L, -1);
|
||||
lua_pop(L, 1); // power
|
||||
}
|
||||
lua_pop(L, 1); // cdl
|
||||
}
|
||||
|
||||
getServer(L)->setLighting(player, lighting);
|
||||
|
@ -2709,6 +2740,8 @@ int ObjectRef::l_get_lighting(lua_State *L)
|
|||
lua_newtable(L); // "volumetric_light"
|
||||
lua_pushnumber(L, lighting.volumetric_light_strength);
|
||||
lua_setfield(L, -2, "strength");
|
||||
push_v3f(L, lighting.volumetric_beta_r0);
|
||||
lua_setfield(L, -2, "beta_r0");
|
||||
lua_setfield(L, -2, "volumetric_light");
|
||||
lua_newtable(L); // "bloom"
|
||||
lua_pushnumber(L, lighting.bloom_intensity);
|
||||
|
@ -2718,6 +2751,22 @@ int ObjectRef::l_get_lighting(lua_State *L)
|
|||
lua_pushnumber(L, lighting.bloom_radius);
|
||||
lua_setfield(L, -2, "radius");
|
||||
lua_setfield(L, -2, "bloom");
|
||||
lua_newtable(L); // "vignette"
|
||||
lua_pushnumber(L, lighting.vignette.dark);
|
||||
lua_setfield(L, -2, "dark");
|
||||
lua_pushnumber(L, lighting.vignette.bright);
|
||||
lua_setfield(L, -2, "bright");
|
||||
lua_pushnumber(L, lighting.vignette.power);
|
||||
lua_setfield(L, -2, "power");
|
||||
lua_setfield(L, -2, "vignette");
|
||||
lua_newtable(L); // "cdl"
|
||||
push_v3f(L, lighting.cdl.slope);
|
||||
lua_setfield(L, -2, "slope");
|
||||
push_v3f(L, lighting.cdl.offset);
|
||||
lua_setfield(L, -2, "offset");
|
||||
push_v3f(L, lighting.cdl.power);
|
||||
lua_setfield(L, -2, "power");
|
||||
lua_setfield(L, -2, "cdl");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1913,7 +1913,7 @@ void Server::SendOverrideDayNightRatio(session_t peer_id, bool do_override,
|
|||
Send(&pkt);
|
||||
}
|
||||
|
||||
void Server::SendSetLighting(session_t peer_id, const Lighting &lighting)
|
||||
void Server::SendSetLighting(session_t peer_id, const Lighting & lighting)
|
||||
{
|
||||
NetworkPacket pkt(TOCLIENT_SET_LIGHTING,
|
||||
4, peer_id);
|
||||
|
@ -1932,6 +1932,13 @@ void Server::SendSetLighting(session_t peer_id, const Lighting &lighting)
|
|||
pkt << lighting.bloom_intensity << lighting.bloom_strength_factor <<
|
||||
lighting.bloom_radius;
|
||||
pkt << lighting.artificial_light_color;
|
||||
pkt << lighting.volumetric_beta_r0;
|
||||
pkt << lighting.vignette.dark
|
||||
<< lighting.vignette.bright
|
||||
<< lighting.vignette.power;
|
||||
pkt << lighting.cdl.slope;
|
||||
pkt << lighting.cdl.offset;
|
||||
pkt << lighting.cdl.power;
|
||||
|
||||
Send(&pkt);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue