From 4e9ba3e5605ccbcea70868ef5b22f18934cf8703 Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Sun, 16 Nov 2014 12:28:09 +0200 Subject: [PATCH] Basic ALS + AW infrastructure to use new cloud transparency parameter --- Effects/cloud.eff | 4 ++-- Nasal/local_weather/compat_layer.nas | 1 + Nasal/local_weather/local_weather.nas | 17 +++++++++++------ ...3dcloud-lightfield.frag => 3dcloud-ALS.frag} | 0 ...3dcloud-lightfield.vert => 3dcloud-ALS.vert} | 2 ++ 5 files changed, 16 insertions(+), 8 deletions(-) rename Shaders/{3dcloud-lightfield.frag => 3dcloud-ALS.frag} (100%) rename Shaders/{3dcloud-lightfield.vert => 3dcloud-ALS.vert} (99%) diff --git a/Effects/cloud.eff b/Effects/cloud.eff index 8a8f1db85..8e2d830e7 100644 --- a/Effects/cloud.eff +++ b/Effects/cloud.eff @@ -57,8 +57,8 @@ clamp - Shaders/3dcloud-lightfield.vert - Shaders/3dcloud-lightfield.frag + Shaders/3dcloud-ALS.vert + Shaders/3dcloud-ALS.frag usrAttr1 10 diff --git a/Nasal/local_weather/compat_layer.nas b/Nasal/local_weather/compat_layer.nas index bcd4f98f6..98c085849 100644 --- a/Nasal/local_weather/compat_layer.nas +++ b/Nasal/local_weather/compat_layer.nas @@ -655,6 +655,7 @@ var p = props.Node.new({ "layer" : 0, "min-bottom-lighting-factor": c.bottom_shade, "min-middle-lighting-factor": c.middle_shade, "min-top-lighting-factor": c.top_shade, + "alpha-factor": c.alpha_factor, "min-shade-lighting-factor": c.bottom_shade, "texture": c.texture_sheet, "num-textures-x": c.num_tex_x, diff --git a/Nasal/local_weather/local_weather.nas b/Nasal/local_weather/local_weather.nas index b95aac1af..5e4e2061e 100644 --- a/Nasal/local_weather/local_weather.nas +++ b/Nasal/local_weather/local_weather.nas @@ -1553,6 +1553,7 @@ if (path == "new") # we have to switch to new cloud generating routines local_weather.cloudAssembly.lon = lon; local_weather.cloudAssembly.alt = alt; local_weather.cloudAssembly.top_shade = top_shade; + local_weather.cloudAssembly.alpha_factor = alpha_factor; #print(lat," ",long, " ", alt); @@ -3382,22 +3383,22 @@ var v2 = v0 * (1.2 + rand() * 0.2); var d2 = d0 + dsign * (3.0 * rand() + 2.0); var v3 = v0 * (1.3 + rand() * 0.4) + 5.0; -var d3 = d0 + dsign * (3.0 * rand() + dsign * 4.0); +var d3 = d0 + dsign * (3.0 * rand() + 4.0); var v4 = v0 * (1.7 + rand() * 0.5) + 10.0; -var d4 = d0 + dsign * (4.0 * rand() + dsign * 8.0); +var d4 = d0 + dsign * (4.0 * rand() + 8.0); var v5 = v0 * (1.7 + rand() * 0.5) + 20.0; -var d5 = d0 + dsign * (4.0 * rand() + dsign * 10.0); +var d5 = d0 + dsign * (4.0 * rand() + 10.0); var v6 = v0 * (1.7 + rand() * 0.5) + 40.0; -var d6 = d0 + dsign * (4.0 * rand() + dsign * 12.0); +var d6 = d0 + dsign * (4.0 * rand() + 12.0); var v7 = v0 * (2.0 + rand() * 0.7) + 50.0; -var d7 = d0 + dsign * (4.0 * rand() + dsign * 13.0); +var d7 = d0 + dsign * (4.0 * rand() + 13.0); var v8 = v0 * (2.0 + rand() * 0.7) + 55.0;; -var d8 = d0 + dsign * (5.0 * rand() + dsign * 14.0); +var d8 = d0 + dsign * (5.0 * rand() + 14.0); var w = windIpoint.new(lat, lon, d0, v0, d1, v1, d2, v2, d3, v3, d4, v4, d5, v5, d6, v6, d7, v7, d8, v8); @@ -4563,6 +4564,10 @@ if (lowest_layer_turbulence < 0.0) {lowest_layer_turbulence = 0.0;} var top_shade = 1.0; +# global cloud transparency + +var alpha_factor = 1.0; + # global cloud size scale; var cloud_size_scale = 1.0; diff --git a/Shaders/3dcloud-lightfield.frag b/Shaders/3dcloud-ALS.frag similarity index 100% rename from Shaders/3dcloud-lightfield.frag rename to Shaders/3dcloud-ALS.frag diff --git a/Shaders/3dcloud-lightfield.vert b/Shaders/3dcloud-ALS.vert similarity index 99% rename from Shaders/3dcloud-lightfield.vert rename to Shaders/3dcloud-ALS.vert index 3dda46881..29ffc489e 100644 --- a/Shaders/3dcloud-lightfield.vert +++ b/Shaders/3dcloud-ALS.vert @@ -17,6 +17,7 @@ uniform float air_pollution; attribute vec3 usrAttr1; attribute vec3 usrAttr2; +float alpha_factor = usrAttr1.r; float shade_factor = usrAttr1.g; float cloud_height = usrAttr1.b; float bottom_factor = usrAttr2.r; @@ -237,6 +238,7 @@ void main(void) gl_FrontColor.rgb = gl_FrontColor.rgb + moonLightColor * (1.0 - smoothstep(0.4, 0.5, earthShade)); hazeColor.rgb = hazeColor.rgb + moonLightColor * (1.0 - smoothstep(0.4, 0.5, earthShade)); + gl_FrontColor.a = gl_FrontColor.a * alpha_factor; gl_BackColor = gl_FrontColor; } }