From 954076af69e0ec8d3dde35265fc3689663d74b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Lemaire?= Date: Mon, 11 Mar 2013 13:32:05 +0000 Subject: [PATCH] paysages : Added lighting filtering to water preview. git-svn-id: https://subversion.assembla.com/svn/thunderk/paysages@538 b1fd45b6-86a6-48da-8261-f70d1f35bdcc --- TODO | 1 - gui_qt/formwater.cpp | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 502c2f3..8205520 100644 --- a/TODO +++ b/TODO @@ -14,7 +14,6 @@ Technology Preview 2 : => Covering texture height should inpact terrain height. => Add texture shadowing. - Clouds should keep distance to ground. -- Apply depth filtering to water preview. - Fix rendering when inside a cloud layer, with other upper or lower layers. - Improve cloud rendering precision (and beware of precision discontinuity when rendering clouds in front of ground (shorter distance)). - Translations. diff --git a/gui_qt/formwater.cpp b/gui_qt/formwater.cpp index ea50605..d01da4a 100644 --- a/gui_qt/formwater.cpp +++ b/gui_qt/formwater.cpp @@ -168,6 +168,21 @@ private: result.hit_location.x = x; result.hit_location.y = y; result.hit_location.z = 0.0; + + if (result.hit_location.y < 0.0) + { + if (result.hit_location.y < -renderer->water->definition->lighting_depth) + { + result.hit_color = COLOR_BLACK; + } + else + { + double attenuation = -result.hit_location.y / renderer->water->definition->lighting_depth; + result.hit_color.r *= 1.0 - attenuation; + result.hit_color.g *= 1.0 - attenuation; + result.hit_color.b *= 1.0 - attenuation; + } + } } return result;