1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Fog effect when camera is inside cloud

Fixes issue #3576

* Clouds now take camera position as 3D, not 2D

* Cloud grid filling extracted to gridFilled method

* Clouds detect whether camera is inside cloud

* Camera in cloud changes fog by overriding sky colors
  with cloud color

* Sun, moon and stars can be temporarily disabled
  with setBodiesVisible

* Disabling fog also disables all "inside cloud" behaviors
This commit is contained in:
Ben Deutsch 2017-05-07 18:41:47 +02:00 committed by SmallJoker
parent 61a3de42fd
commit 6bedb6de40
7 changed files with 84 additions and 30 deletions

View file

@ -4104,12 +4104,29 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
Update clouds
*/
if (clouds) {
v3f player_position = player->getPosition();
if (sky->getCloudsVisible()) {
clouds->setVisible(true);
clouds->step(dtime);
clouds->update(v2f(player_position.X, player_position.Z),
sky->getCloudColor());
// camera->getPosition is not enough for 3rd person views
v3f camera_node_position = camera->getCameraNode()->getPosition();
v3s16 camera_offset = camera->getOffset();
camera_node_position.X = camera_node_position.X + camera_offset.X * BS;
camera_node_position.Y = camera_node_position.Y + camera_offset.Y * BS;
camera_node_position.Z = camera_node_position.Z + camera_offset.Z * BS;
clouds->update(camera_node_position,
sky->getCloudColor());
if (clouds->isCameraInsideCloud() && m_cache_enable_fog &&
!flags.force_fog_off) {
// if inside clouds, and fog enabled, use that as sky
// color(s)
video::SColor clouds_dark = clouds->getColor()
.getInterpolated(video::SColor(255, 0, 0, 0), 0.9);
sky->overrideColors(clouds_dark, clouds->getColor());
sky->setBodiesVisible(false);
runData.fog_range = 20.0f * BS;
// do not draw clouds after all
clouds->setVisible(false);
}
} else {
clouds->setVisible(false);
}
@ -4221,7 +4238,6 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
/*
Drawing begins
*/
const video::SColor &skycolor = sky->getSkyColor();
TimeTaker tt_draw("mainloop: draw");