Skip to content

Commit d1a1304

Browse files
lhofhanslparamat
authored andcommittedJul 30, 2017
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.
1 parent 640ba77 commit d1a1304

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

Diff for: ‎src/clientmap.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -596,11 +596,12 @@ int ClientMap::getBackgroundBrightness(float max_d, u32 daylight_factor,
596596
};
597597
if(z_directions[0].X < -99){
598598
for(u32 i=0; i<sizeof(z_directions)/sizeof(*z_directions); i++){
599+
// Assumes FOV of 72 and 16/9 aspect ratio
599600
z_directions[i] = v3f(
600-
0.01 * myrand_range(-100, 100),
601+
0.02 * myrand_range(-100, 100),
601602
1.0,
602603
0.01 * myrand_range(-100, 100)
603-
);
604+
).normalize();
604605
z_offsets[i] = 0.01 * myrand_range(0,100);
605606
}
606607
}
@@ -613,7 +614,6 @@ int ClientMap::getBackgroundBrightness(float max_d, u32 daylight_factor,
613614
std::vector<int> values;
614615
for(u32 i=0; i<sizeof(z_directions)/sizeof(*z_directions); i++){
615616
v3f z_dir = z_directions[i];
616-
z_dir.normalize();
617617
core::CMatrix4<f32> a;
618618
a.buildRotateFromTo(v3f(0,1,0), z_dir);
619619
v3f dir = m_camera_direction;

0 commit comments

Comments
 (0)
Please sign in to comment.