aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Hofhansl <larsh@apache.org>2017-07-22 12:44:15 -0700
committerparamat <mat.gregory@virginmedia.com>2017-07-30 18:28:16 +0100
commitd1a130488e5a5f3837479ad7f929beb4c43e81fb (patch)
tree4ea7161553d23f492375e41952479319ef815be9 /src
parent640ba7727629392211ed3c2bd116e938883a6f90 (diff)
downloadhax-minetest-server-d1a130488e5a5f3837479ad7f929beb4c43e81fb.tar.gz
hax-minetest-server-d1a130488e5a5f3837479ad7f929beb4c43e81fb.zip
Darkness detection: Reduce chance of false positives darkening the skybox
The getBackgroundBrightness() function detects darkness in the view direction to decide when to make the skybox dark. The volume checked was too narrow and missed the left and right edges of the view, too easily causing a dark skybox. Widen the checked volume to match a FOV of 72 degrees and a 16:9 aspect ratio game window.
Diffstat (limited to 'src')
-rw-r--r--src/clientmap.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/clientmap.cpp b/src/clientmap.cpp
index 7027d07e4..c443773b6 100644
--- a/src/clientmap.cpp
+++ b/src/clientmap.cpp
@@ -596,11 +596,12 @@ int ClientMap::getBackgroundBrightness(float max_d, u32 daylight_factor,
};
if(z_directions[0].X < -99){
for(u32 i=0; i<sizeof(z_directions)/sizeof(*z_directions); i++){
+ // Assumes FOV of 72 and 16/9 aspect ratio
z_directions[i] = v3f(
- 0.01 * myrand_range(-100, 100),
+ 0.02 * myrand_range(-100, 100),
1.0,
0.01 * myrand_range(-100, 100)
- );
+ ).normalize();
z_offsets[i] = 0.01 * myrand_range(0,100);
}
}
@@ -613,7 +614,6 @@ int ClientMap::getBackgroundBrightness(float max_d, u32 daylight_factor,
std::vector<int> values;
for(u32 i=0; i<sizeof(z_directions)/sizeof(*z_directions); i++){
v3f z_dir = z_directions[i];
- z_dir.normalize();
core::CMatrix4<f32> a;
a.buildRotateFromTo(v3f(0,1,0), z_dir);
v3f dir = m_camera_direction;