summaryrefslogtreecommitdiff
path: root/src/mapblock_mesh.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-05-20 14:12:17 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-05-20 14:12:17 +0300
commitafda9810f12f30c0d62da5e43956ad1db800f707 (patch)
tree616e54849a787d9984341e5a4ef18a03a825a4d0 /src/mapblock_mesh.cpp
parent22df8b81b39b98bb6c5f161ebcad57fe185492c8 (diff)
downloadminetest-afda9810f12f30c0d62da5e43956ad1db800f707.tar.gz
minetest-afda9810f12f30c0d62da5e43956ad1db800f707.tar.bz2
minetest-afda9810f12f30c0d62da5e43956ad1db800f707.zip
Tune smooth lighting a bit
Diffstat (limited to 'src/mapblock_mesh.cpp')
-rw-r--r--src/mapblock_mesh.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp
index 0e26161e2..658ffe5ee 100644
--- a/src/mapblock_mesh.cpp
+++ b/src/mapblock_mesh.cpp
@@ -274,8 +274,16 @@ static u8 getSmoothLight(enum LightBank bank, v3s16 p, MeshMakeData *data)
if(ambient_occlusion > 4)
{
- ambient_occlusion -= 4;
- light = (float)light / ((float)ambient_occlusion * 0.5 + 1.0);
+ //ambient_occlusion -= 4;
+ //light = (float)light / ((float)ambient_occlusion * 0.5 + 1.0);
+ float light_amount = (8 - ambient_occlusion) / 4.0;
+ float light_f = (float)light / 255.0;
+ light_f = pow(light_f, 2.2); // gamma -> linear space
+ light_f = light_f * light_amount;
+ light_f = pow(light_f, 1.0/2.2); // linear -> gamma space
+ if(light_f > 1.0)
+ light_f = 1.0;
+ light = 255.0 * light_f + 0.5;
}
return light;