From: <tz...@us...> - 2009-02-25 03:51:55
|
Revision: 2877 http://freeorion.svn.sourceforge.net/freeorion/revision/?rev=2877&view=rev Author: tzlaine Date: 2009-02-25 03:51:52 +0000 (Wed, 25 Feb 2009) Log Message: ----------- Fixed the blacking out of the dark side of atmosphereless planets as a result of adding normal mapping. Modified Paths: -------------- trunk/FreeOrion/default/data/art/combat/meshes/planets/atmosphereless_planet.frag trunk/FreeOrion/default/data/art/combat/meshes/planets/atmosphereless_planet.vert Modified: trunk/FreeOrion/default/data/art/combat/meshes/planets/atmosphereless_planet.frag =================================================================== --- trunk/FreeOrion/default/data/art/combat/meshes/planets/atmosphereless_planet.frag 2009-02-25 03:19:11 UTC (rev 2876) +++ trunk/FreeOrion/default/data/art/combat/meshes/planets/atmosphereless_planet.frag 2009-02-25 03:51:52 UTC (rev 2877) @@ -9,8 +9,13 @@ void main() { - vec3 daytime = texture2D(day_texture, tex_coord).rgb * diffuse; - vec3 color = daytime; + vec3 color = texture2D(day_texture, tex_coord).rgb * diffuse; + + // renormalize to [-1, 1] + vec3 normal = texture2D(normal_texture, tex_coord).xyz * 2.0 - 1.0; + float normal_factor = max(dot(normal, light_vec), 0.0); + color *= normal_factor; + if (diffuse < -TERMINATOR) { vec3 nighttime = texture2D(night_texture, tex_coord).rgb; vec3 city_lights = texture2D(lights_texture, tex_coord).rgb; @@ -20,14 +25,9 @@ vec3 nighttime = texture2D(night_texture, tex_coord).rgb; vec3 city_lights = texture2D(lights_texture, tex_coord).rgb; vec3 combined_night_side = clamp(nighttime + city_lights, 0.0, 1.0); - color = mix(combined_night_side, daytime, + color = mix(combined_night_side, color, (diffuse + TERMINATOR) / (2.0 * TERMINATOR)); } - // renormalize to [-1, 1] - vec3 normal = texture2D(normal_texture, tex_coord).xyz * 2.0 - 1.0; - float normal_factor = abs(dot(normal, light_vec)); - color *= normal_factor; - gl_FragColor = vec4(color, 1.0); } Modified: trunk/FreeOrion/default/data/art/combat/meshes/planets/atmosphereless_planet.vert =================================================================== --- trunk/FreeOrion/default/data/art/combat/meshes/planets/atmosphereless_planet.vert 2009-02-25 03:19:11 UTC (rev 2876) +++ trunk/FreeOrion/default/data/art/combat/meshes/planets/atmosphereless_planet.vert 2009-02-25 03:51:52 UTC (rev 2877) @@ -1,5 +1,4 @@ // -*- C++ -*- -//uniform vec3 light_dir; uniform vec4 light_pos; varying float diffuse; |