From b9c573ea114ff340e8753463337f7ea44731eb34 Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Thu, 13 Jun 2013 13:26:37 +0300 Subject: [PATCH] Tweak to prevent the cloud LOD system from dropping sprites in very faint clouds which have just few sprites to begin with and appear unrealistic when these are dropped --- Shaders/3dcloud-lightfield.vert | 4 ++-- Shaders/3dcloud.vert | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Shaders/3dcloud-lightfield.vert b/Shaders/3dcloud-lightfield.vert index 0d1797f61..3dda46881 100644 --- a/Shaders/3dcloud-lightfield.vert +++ b/Shaders/3dcloud-lightfield.vert @@ -94,7 +94,7 @@ void main(void) float fogCoord = length(vec3(gl_ModelViewMatrix * vec4(gl_Color.x, gl_Color.y, gl_Color.z, 1.0))); float center_dist = length(vec3(gl_ModelViewMatrix * vec4(0.0,0.0,0.0,1.0))); - if ((fogCoord > detail_range) && (fogCoord > center_dist)) { + if ((fogCoord > detail_range) && (fogCoord > center_dist) && (shade_factor < 0.7)) { // More than detail_range away, so discard all sprites on opposite side of // cloud center by shifting them beyond the view fustrum gl_Position = vec4(0.0,0.0,10.0,1.0); @@ -176,7 +176,7 @@ void main(void) //gl_FrontColor.a = 1.0; //light_diffuse+ gl_FrontLightModelProduct.sceneColor;// * shade ;//+ gl_FrontLightModelProduct.sceneColor; - if ((fogCoord > (0.9 * detail_range)) && (fogCoord > center_dist)) { + if ((fogCoord > (0.9 * detail_range)) && (fogCoord > center_dist) && (shade_factor < 0.7)) { // cloudlet is almost at the detail range, so fade it out. gl_FrontColor.a = 1.0 - smoothstep(0.9 * detail_range, detail_range, fogCoord); } else { diff --git a/Shaders/3dcloud.vert b/Shaders/3dcloud.vert index 005ac1e8e..f32f8c527 100644 --- a/Shaders/3dcloud.vert +++ b/Shaders/3dcloud.vert @@ -44,7 +44,7 @@ void main(void) float fogCoord = length(vec3(gl_ModelViewMatrix * vec4(gl_Color.x, gl_Color.y, gl_Color.z, 1.0))); float center_dist = length(vec3(gl_ModelViewMatrix * vec4(0.0,0.0,0.0,1.0))); - if ((fogCoord > detail_range) && (fogCoord > center_dist)) { + if ((fogCoord > detail_range) && (fogCoord > center_dist) && (shade_factor < 0.7)) { // More than detail_range away, so discard all sprites on opposite side of // cloud center by shifting them beyond the view fustrum gl_Position = vec4(0.0,0.0,10.0,1.0); @@ -72,7 +72,7 @@ void main(void) gl_Position = gl_ModelViewProjectionMatrix * gl_Position; gl_FrontColor = gl_LightSource[0].diffuse * shade + gl_FrontLightModelProduct.sceneColor; - if ((fogCoord > (0.9 * detail_range)) && (fogCoord > center_dist)) { + if ((fogCoord > (0.9 * detail_range)) && (fogCoord > center_dist) && (shade_factor < 0.7)) { // cloudlet is almost at the detail range, so fade it out. gl_FrontColor.a = 1.0 - smoothstep(0.9 * detail_range, detail_range, fogCoord); } else {