Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added configurable ambient_occlusion_gamma. Default is 2.2 (same as p…
…revious hardcoded values).
  • Loading branch information
TriBlade9 authored and Zeno- committed Jan 14, 2015
1 parent 57f2fa5 commit e19dab2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
6 changes: 5 additions & 1 deletion minetest.conf.example
Expand Up @@ -216,6 +216,11 @@
# Set to true enables waving plants. Requires shaders enabled.
#enable_waving_plants = false
# Enables caching of facedir rotated meshes
#ambient_occlusion_gamma = 2.2
# The strength (darkness) of node ambient-occlusion shading.
# Lower is darker, Higher is lighter. The valid range of values for this
# setting is 0.25 to 4.0 inclusive. If the value is out of range it will be
# set to the nearest valid value.
#enable_mesh_cache = true
# The time in seconds it takes between repeated
# right clicks when holding the right mouse button.
Expand Down Expand Up @@ -548,4 +553,3 @@
# Noise parameters for biome API temperature and humidity
#mg_biome_np_heat = 50, 50, (500, 500, 500), 5349, 3, 0.5, 2.0
#mg_biome_np_humidity = 50, 50, (500, 500, 500), 842, 3, 0.5, 2.0

2 changes: 1 addition & 1 deletion src/defaultsettings.cpp
Expand Up @@ -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");
Expand Down Expand Up @@ -346,4 +347,3 @@ void override_default_settings(Settings *settings, Settings *from)
settings->setDefault(name, from->get(name));
}
}

12 changes: 9 additions & 3 deletions src/mapblock_mesh.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit e19dab2

Please sign in to comment.