aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTriBlade9 <triblade9@mail.com>2015-01-14 23:34:44 +1000
committerCraig Robbins <kde.psych@gmail.com>2015-01-14 23:35:50 +1000
commite19dab2622b89471dba3000bd42b5598fc4ebee8 (patch)
tree4a4df9195599221fa2f6ea47e38354b02c06b0e6 /src
parent57f2fa57cda957be302b3542a59cd51209d46f2d (diff)
downloadminetest-e19dab2622b89471dba3000bd42b5598fc4ebee8.tar.gz
minetest-e19dab2622b89471dba3000bd42b5598fc4ebee8.tar.bz2
minetest-e19dab2622b89471dba3000bd42b5598fc4ebee8.zip
Added configurable ambient_occlusion_gamma. Default is 2.2 (same as previous hardcoded values).
Diffstat (limited to 'src')
-rw-r--r--src/defaultsettings.cpp2
-rw-r--r--src/mapblock_mesh.cpp12
2 files changed, 10 insertions, 4 deletions
diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp
index 4fb99cd55..6504c5155 100644
--- a/src/defaultsettings.cpp
+++ b/src/defaultsettings.cpp
@@ -159,6 +159,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("water_wave_speed", "5.0");
settings->setDefault("enable_waving_leaves", "false");
settings->setDefault("enable_waving_plants", "false");
+ settings->setDefault("ambient_occlusion_gamma", "2.2");
settings->setDefault("enable_shaders", "true");
settings->setDefault("repeat_rightclick_time", "0.25");
settings->setDefault("enable_particles", "true");
@@ -346,4 +347,3 @@ void override_default_settings(Settings *settings, Settings *from)
settings->setDefault(name, from->get(name));
}
}
-
diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp
index 0e5a883f2..8afca73a5 100644
--- a/src/mapblock_mesh.cpp
+++ b/src/mapblock_mesh.cpp
@@ -288,9 +288,15 @@ static u16 getSmoothLightCombined(v3s16 p, MeshMakeData *data)
if (ambient_occlusion > 4)
{
- //table of precalculated gamma space multiply factors
- //light^2.2 * factor (0.75, 0.5, 0.25, 0.0), so table holds factor ^ (1 / 2.2)
- static const float light_amount[4] = { 0.877424315, 0.729740053, 0.532520545, 0.0 };
+ static const float ao_gamma = rangelim(
+ g_settings->getFloat("ambient_occlusion_gamma"), 0.25, 4.0);
+
+ // Table of gamma space multiply factors.
+ static const float light_amount[3] = {
+ powf(0.75, 1.0 / ao_gamma),
+ powf(0.5, 1.0 / ao_gamma),
+ powf(0.25, 1.0 / ao_gamma)
+ };
//calculate table index for gamma space multiplier
ambient_occlusion -= 5;