diff --git a/Effects/terrain-default.eff b/Effects/terrain-default.eff index 6265ec6c2..27eed7f74 100644 --- a/Effects/terrain-default.eff +++ b/Effects/terrain-default.eff @@ -116,6 +116,47 @@ /environment/sea/surface/wind-from-north-fps /sim/rendering/shaders/landmass /sim/rendering/shaders/transition + /local-weather/cloud-shadows/cloudpos-x[0] + /local-weather/cloud-shadows/cloudpos-y[0] + /local-weather/cloud-shadows/cloudpos-x[1] + /local-weather/cloud-shadows/cloudpos-y[1] + /local-weather/cloud-shadows/cloudpos-x[2] + /local-weather/cloud-shadows/cloudpos-y[2] + /local-weather/cloud-shadows/cloudpos-x[3] + /local-weather/cloud-shadows/cloudpos-y[3] + /local-weather/cloud-shadows/cloudpos-x[4] + /local-weather/cloud-shadows/cloudpos-y[4] + /local-weather/cloud-shadows/cloudpos-x[5] + /local-weather/cloud-shadows/cloudpos-y[5] + /local-weather/cloud-shadows/cloudpos-x[6] + /local-weather/cloud-shadows/cloudpos-y[6] + /local-weather/cloud-shadows/cloudpos-x[7] + /local-weather/cloud-shadows/cloudpos-y[7] + /local-weather/cloud-shadows/cloudpos-x[8] + /local-weather/cloud-shadows/cloudpos-y[8] + /local-weather/cloud-shadows/cloudpos-x[9] + /local-weather/cloud-shadows/cloudpos-y[9] + /local-weather/cloud-shadows/cloudpos-x[10] + /local-weather/cloud-shadows/cloudpos-y[10] + /local-weather/cloud-shadows/cloudpos-x[11] + /local-weather/cloud-shadows/cloudpos-y[11] + /local-weather/cloud-shadows/cloudpos-x[12] + /local-weather/cloud-shadows/cloudpos-y[12] + /local-weather/cloud-shadows/cloudpos-x[13] + /local-weather/cloud-shadows/cloudpos-y[13] + /local-weather/cloud-shadows/cloudpos-x[14] + /local-weather/cloud-shadows/cloudpos-y[14] + /local-weather/cloud-shadows/cloudpos-x[15] + /local-weather/cloud-shadows/cloudpos-y[15] + /local-weather/cloud-shadows/cloudpos-x[16] + /local-weather/cloud-shadows/cloudpos-y[16] + /local-weather/cloud-shadows/cloudpos-x[17] + /local-weather/cloud-shadows/cloudpos-y[17] + /local-weather/cloud-shadows/cloudpos-x[18] + /local-weather/cloud-shadows/cloudpos-y[18] + /local-weather/cloud-shadows/cloudpos-x[19] + /local-weather/cloud-shadows/cloudpos-y[19] + /local-weather/cloud-shadows/cloud-shadow-flag @@ -249,6 +290,7 @@ Shaders/terrain-haze-ultra.vert Shaders/terrain-haze-ultra.frag + Shaders/cloud-shadowfunc.frag grain_strength @@ -385,6 +427,206 @@ float season + + cloudpos1_x + float + cloudpos1_x + + + cloudpos1_y + float + cloudpos1_y + + + cloudpos2_x + float + cloudpos2_x + + + cloudpos2_y + float + cloudpos2_y + + + cloudpos3_x + float + cloudpos3_x + + + cloudpos3_y + float + cloudpos3_y + + + cloudpos4_x + float + cloudpos4_x + + + cloudpos4_y + float + cloudpos4_y + + + cloudpos5_x + float + cloudpos5_x + + + cloudpos5_y + float + cloudpos5_y + + + cloudpos6_x + float + cloudpos6_x + + + cloudpos6_y + float + cloudpos6_y + + + cloudpos7_x + float + cloudpos7_x + + + cloudpos7_y + float + cloudpos7_y + + + cloudpos8_x + float + cloudpos8_x + + + cloudpos8_y + float + cloudpos8_y + + + cloudpos9_x + float + cloudpos9_x + + + cloudpos9_y + float + cloudpos9_y + + + cloudpos10_x + float + cloudpos10_x + + + cloudpos10_y + float + cloudpos10_y + + + cloudpos11_x + float + cloudpos11_x + + + cloudpos11_y + float + cloudpos11_y + + + cloudpos12_x + float + cloudpos12_x + + + cloudpos12_y + float + cloudpos12_y + + + cloudpos13_x + float + cloudpos13_x + + + cloudpos13_y + float + cloudpos13_y + + + cloudpos14_x + float + cloudpos14_x + + + cloudpos14_y + float + cloudpos14_y + + + cloudpos15_x + float + cloudpos15_x + + + cloudpos15_y + float + cloudpos15_y + + + cloudpos16_x + float + cloudpos16_x + + + cloudpos16_y + float + cloudpos16_y + + + cloudpos17_x + float + cloudpos17_x + + + cloudpos17_y + float + cloudpos17_y + + + cloudpos18_x + float + cloudpos18_x + + + cloudpos18_y + float + cloudpos18_y + + + cloudpos19_x + float + cloudpos19_x + + + cloudpos19_y + float + cloudpos19_y + + + cloudpos20_x + float + cloudpos20_x + + + cloudpos20_y + float + cloudpos20_y + WindE float @@ -406,10 +648,15 @@ tquality_level - wind_effects - int - wind_effects + wind_effects + int + wind_effects + + cloud_shadow_flag + int + cloud_shadow_flag + texture sampler-2d diff --git a/Environment/local-weather-defaults.xml b/Environment/local-weather-defaults.xml index 6826b38e7..5c7f532f0 100644 --- a/Environment/local-weather-defaults.xml +++ b/Environment/local-weather-defaults.xml @@ -103,6 +103,10 @@ 0.2 12 + + 0 + 0 + diff --git a/Nasal/local_weather/local_weather.nas b/Nasal/local_weather/local_weather.nas index 094639ab4..5086860ae 100644 --- a/Nasal/local_weather/local_weather.nas +++ b/Nasal/local_weather/local_weather.nas @@ -1656,6 +1656,7 @@ setprop(lw~"timing-loop-flag",0); setprop(lw~"buffer-loop-flag",0); setprop(lw~"housekeeping-loop-flag",0); setprop(lw~"convective-loop-flag",0); +setprop(lw~"shadow-loop-flag",0); weather_dynamics.convective_loop_kill_flag = 1; # long-running loop needs a different scheme to end @@ -1691,6 +1692,14 @@ n_effectVolumeArray = 0; weather_tile_management.remove_impostors(); +# clear out the visual shadows + +for (var i = 0; i 0.0) {height_bias = height_bias + 15.0 *edge_bias + 20.0 * rand create_streak(btype,lat,lon, alt -offset_map["Congestus"] -900.0, 100.0,n_b,0.0,edge,0.3*x,1,0.0,0.0,0.3*y,alpha,1.0); + if (local_weather.cloud_shadow_flag == 1) + { + var cs = local_weather.cloudShadow.new(lat, lon, 0.9 * (1.5 * x)/5000.0 , 0.9); + cs.index = getprop(lw~"tiles/tile-counter"); + append(cloudShadowCandidateArray,cs); + } + + } else if (size>1.1) { @@ -1822,6 +1841,13 @@ if (edge_bias > 0.0) {height_bias = height_bias + 15.0 *edge_bias + 20.0 * rand height_bias = 1.0; create_streak(btype,lat,lon, alt -offset_map["Cumulus"] - 200.0, 100.0,n_b,0.0,edge,0.3*x,1,0.0,0.0,0.3*y,alpha,1.0); + if (local_weather.cloud_shadow_flag == 1) + { + var cs = local_weather.cloudShadow.new(lat, lon, 0.9 * (1.5 * x)/5000.0 , 0.8); + cs.index = getprop(lw~"tiles/tile-counter"); + append(cloudShadowCandidateArray,cs); + } + } else if (size>0.8) { @@ -1998,7 +2024,7 @@ var alt_base = alt_20_array[tile_index -1]; #var alt_base = getprop(lw~"tmp/tile-alt-offset-ft"); # } -var sec_to_rad = 2.0 * math.pi/86400; # conversion factor for sinusoidal dependence on daytime +#var sec_to_rad = 2.0 * math.pi/86400; # conversion factor for sinusoidal dependence on daytime calc_geo(blat); @@ -2190,7 +2216,7 @@ var detail_flag = detailed_clouds_flag; alpha = alpha * math.pi/180.0; # the tile orientation -var sec_to_rad = 2.0 * math.pi/86400; # conversion factor for sinusoidal dependence on daytime +#var sec_to_rad = 2.0 * math.pi/86400; # conversion factor for sinusoidal dependence on daytime # current aircraft position @@ -3984,6 +4010,16 @@ local_weather.init_sea_colors(); # create impostors - this should only happen when sufficiently high in air weather_tile_management.create_impostors(); +# start the cloud shadow loop + +local_weather.cloud_shadow_flag = getprop("/local-weather/cloud-shadows/cloud-shadow-flag"); + +if (local_weather.cloud_shadow_flag == 1) + { + setprop(lw~"shadow-loop-flag",1); + weather_tile_management.shadow_management_loop(0); + } + # weather_tile_management.watchdog_loop(); } @@ -4400,6 +4436,7 @@ var lat_to_m = 110952.0; # latitude degrees to meters var m_to_lat = 9.01290648208234e-06; # meters to latitude degrees var ft_to_m = 0.30480; var m_to_ft = 1.0/ft_to_m; +var sec_to_rad = 2.0 * math.pi/86400; var lon_to_m = 0.0; # needs to be calculated dynamically var m_to_lon = 0.0; # we do this on startup diff --git a/Nasal/local_weather/weather_tile_management.nas b/Nasal/local_weather/weather_tile_management.nas index b4f3f3dde..f077736e7 100644 --- a/Nasal/local_weather/weather_tile_management.nas +++ b/Nasal/local_weather/weather_tile_management.nas @@ -16,6 +16,7 @@ # housekeeping_loop to shift clouds from the scenery into the buffer # remove_impostors to delete a ring of impostors to mimick distant clouds # create_impostors to create a ring of impostors to mimick distant clouds +# shadow_management_loop to manage cloud shadow information # watchdog loop (debug helping structure) # calc_geo to get local Cartesian geometry for latitude conversion # get_lat to get latitude from Cartesian coordinates @@ -1120,6 +1121,19 @@ var housekeeping_loop = func (index, index1) { if (local_weather.local_weather_running_flag == 0) {return;} +# supply a few properties which are used more generally + +lwObserverLat = getprop("/position/latitude-deg"); +lwObserverLon = getprop("/position/longitude-deg"); + +var heading = getprop("/orientation/heading-deg"); +var offset = getprop("/sim/current-view/heading-offset-deg"); +lwViewDir = (heading - offset) * math.pi/180.0 ; +setsize(lwViewVec,0); +append(lwViewVec,math.cos(lwViewDir)); +append(lwViewVec,-math.sin(lwViewDir)); + + var n = 5; var n_max = size(cloudSceneryArray); n_cloudSceneryArray = n_max; @@ -1248,6 +1262,130 @@ weather_tiles.create_impostor_ring(lat, lon, alt, alpha, type, n); } +############################### +# Cloud shadow management +############################### + + + +var shadow_management_loop = func (index) { + +if (local_weather.local_weather_running_flag == 0) {return;} + +var n = 50; +var n_max = size(cloudShadowCandidateArray); +var s = size(active_tile_list); + +# don't do anything as long as the array is empty + +if (n_max == 0) # nothing to do, loop over + {if (getprop(lw~"shadow-loop-flag") ==1) {settimer( func {shadow_management_loop(index)}, 0);} return;} + +# compute some general-purpose stuff for the loop + +var eyeLat = lwObserverLat; +var eyeLon = lwObserverLon; + +#var sec_to_rad = 2.0 * math.pi/86400; +var time = getprop("/sim/time/utc/day-seconds") + getprop("/sim/time/local-offset"); +var sun_angle = getprop("/sim/time/sun-angle-rad"); +var cloud_alt = getprop("/environment/ground-haze-thickness-m"); +var offset_mag = cloud_alt * math.tan(sun_angle); +var offset_x = -math.cos(time * local_weather.sec_to_rad) * math.cos(eyeLat) * offset_mag; +var offset_y = -math.sin(time * local_weather.sec_to_rad) * math.sin(eyeLat) * offset_mag; + + +# indexing, we don't want to run through hundreds of candidates per frame + +if (index > n_max-1) {index = 0;} + +var i_max = index + n; +if (i_max > n_max) {i_max = n_max;} + +for (var i = index; i < i_max; i = i+1) + { + var shadow = cloudShadowCandidateArray[i]; + + # housekeeping - delete shadows from deleted tiles + + var flag = 0; + + for (var j = 0; j < s; j = j+1) + { + if (active_tile_list[j] == shadow.index) {flag = 1; break;} + if (shadow.index == 0) {flag =1; break;} # clouds in tile index 0 are special + } + if (flag == 0) + { + #print("Shadow management housekeeping!"); + cloudShadowCandidateArray = delete_from_vector(cloudShadowCandidateArray,i); + i = i -1; i_max = i_max - 1; n_max = n_max - 1; + continue; + } + + # find nearest shadows + + if (shadow.shadow_flag == 0) + { + var diffx = (shadow.lat - eyeLat) * local_weather.lat_to_m + offset_x; + var diffy = -(shadow.lon - eyeLon) * local_weather.lon_to_m + offset_y; + var dist = math.sqrt(diffx * diffx + diffy * diffy) ; + if (getprop("/local-weather/cloud-shadows/cloud-shadow-fov-flag")==1) + { + var viewDotPos = (diffx * lwViewVec[0] + diffy * lwViewVec[1])/dist; + if (viewDotPos <0.7) {dist = dist -(viewDotPos - 0.7) * 10000.0;} + } + if (dist < cloudShadowMaxDist) + { + #print("Shadow management:"); + #print("Max. dist is now: ", dist); + #print("Adding cloud"); + #print("Array size is now: ", size(cloudShadowArray)); + #print("CloudShadowMinIndex is now: ", cloudShadowMinIndex); + cloudShadowMaxDist = dist; + if (size(cloudShadowArray)>cloudShadowArraySize-1) + { + cloudShadowArray[cloudShadowMinIndex].shadow_flag = 0; + cloudShadowArray = delete_from_vector(cloudShadowArray,cloudShadowMinIndex); + } + append(cloudShadowArray,shadow); + shadow.shadow_flag = 1; + break; + } + } + } + +var index_max = -1; +var dist_max = -1.0; + +var counter = 0; + +foreach(s; cloudShadowArray) + { + var diffx = (s.lat - eyeLat) * local_weather.lat_to_m + offset_x; + var diffy = -(s.lon - eyeLon) * local_weather.lon_to_m + offset_y; + + var dist = math.sqrt(diffx*diffx + diffy*diffy); + if (getprop("/local-weather/cloud-shadows/cloud-shadow-fov-flag")==1) + { + var viewDotPos = (diffx * lwViewVec[0] + diffy * lwViewVec[1])/dist; + if (viewDotPos <0.7) {dist = dist -(viewDotPos - 0.7) * 10000.0;} + } + if (dist > dist_max) {dist_max = dist; index_max = counter;} + + setprop("/local-weather/cloud-shadows/cloudpos-x["~counter~"]",int(diffx) + s.size); + setprop("/local-weather/cloud-shadows/cloudpos-y["~counter~"]",int(diffy) + 0.9 ); + counter = counter+1; + } + #print("Dist_max:", dist_max, " index_max: ", index_max); + cloudShadowMinIndex = index_max; + if (dist_max > 0.0) {cloudShadowMaxDist = dist_max;} + + +settimer( func {shadow_management_loop(i)}, 0); +} + + ############################### # watchdog loop for debugging @@ -1374,12 +1512,22 @@ var hp_to_inhg = 1.0/inhg_to_hp; var lon_to_m = 0.0; #local_weather.lon_to_m; var m_to_lon = 0.0; # local_weather.m_to_lon; var lw = "/local-weather/"; +var cloud_shadow_flag = 0; var cloud_view_distance = getprop(lw~"config/clouds-visible-range-m"); var modelArrays = []; var active_tile_list = []; +# a bunch of variables to be updated per frame used by different +# routines, managed by the housekeeping loop + +var lwObserverLat = 0.0; +var lwObserverLon = 0.0; +var lwViewDir = 0.0; +var lwViewVec = []; +var lwTileIndex = 0; + ##################################################### # hashes to manage clouds in scenery or in the buffer @@ -1442,6 +1590,24 @@ var cloudImpostor = { }; +var cloudShadowArray = []; +var cloudShadowCandidateArray = []; +var cloudShadowArraySize = 20; +var cloudShadowMaxDist = 100000.0; +var cloudShadowMinIndex = -1; + +var cloudShadow = { + new: func (lat, lon, size, strength) { + var s = {parents: [cloudShadow] }; + s.lat = lat; + s.lon = lon; + s.size = size; + s.strength = strength; + s.shadow_flag = 0; + return s; + }, +}; + var cloudSceneryArray = []; var n_cloudSceneryArray = 0; diff --git a/Nasal/local_weather/weather_tiles.nas b/Nasal/local_weather/weather_tiles.nas index 49fabeca1..db0661bda 100644 --- a/Nasal/local_weather/weather_tiles.nas +++ b/Nasal/local_weather/weather_tiles.nas @@ -4257,6 +4257,27 @@ else } +if (local_weather.cloud_shadow_flag == 1) + { + var cs = local_weather.cloudShadow.new(lat+get_lat(x,y+6000,phi), lon+get_lon(x,y+6000,phi) , 0.9 , 0.9); + cs.index = getprop(lw~"tiles/tile-counter"); + append(cloudShadowCandidateArray,cs); + + cs = local_weather.cloudShadow.new(lat+get_lat(x,y-6000,phi), lon+get_lon(x,y-6000,phi) , 0.9 , 0.9); + cs.index = getprop(lw~"tiles/tile-counter"); + append(cloudShadowCandidateArray,cs); + + cs = local_weather.cloudShadow.new(lat+get_lat(x,y-3000,phi), lon+get_lon(x,y-3000,phi) , 0.9 , 0.9); + cs.index = getprop(lw~"tiles/tile-counter"); + append(cloudShadowCandidateArray,cs); + + cs = local_weather.cloudShadow.new(lat+get_lat(x,y+3000,phi), lon+get_lon(x,y+3000,phi) , 0.9 , 0.9); + cs.index = getprop(lw~"tiles/tile-counter"); + append(cloudShadowCandidateArray,cs); + + } + + } diff --git a/Shaders/cloud-shadowfunc.frag b/Shaders/cloud-shadowfunc.frag new file mode 100644 index 000000000..c1d44edac --- /dev/null +++ b/Shaders/cloud-shadowfunc.frag @@ -0,0 +1,138 @@ +#version 120 +uniform float cloudpos1_x; +uniform float cloudpos1_y; +uniform float cloudpos2_x; +uniform float cloudpos2_y; +uniform float cloudpos3_x; +uniform float cloudpos3_y; +uniform float cloudpos4_x; +uniform float cloudpos4_y; +uniform float cloudpos5_x; +uniform float cloudpos5_y; +uniform float cloudpos6_x; +uniform float cloudpos6_y; +uniform float cloudpos7_x; +uniform float cloudpos7_y; +uniform float cloudpos8_x; +uniform float cloudpos8_y; +uniform float cloudpos9_x; +uniform float cloudpos9_y; +uniform float cloudpos10_x; +uniform float cloudpos10_y; +uniform float cloudpos11_x; +uniform float cloudpos11_y; +uniform float cloudpos12_x; +uniform float cloudpos12_y; +uniform float cloudpos13_x; +uniform float cloudpos13_y; +uniform float cloudpos14_x; +uniform float cloudpos14_y; +uniform float cloudpos15_x; +uniform float cloudpos15_y; +uniform float cloudpos16_x; +uniform float cloudpos16_y; +uniform float cloudpos17_x; +uniform float cloudpos17_y; +uniform float cloudpos18_x; +uniform float cloudpos18_y; +uniform float cloudpos19_x; +uniform float cloudpos19_y; +uniform float cloudpos20_x; +uniform float cloudpos20_y; + +float shadow_func (in float x, in float y, in float noise, in float dist) +{ + +if (dist > 30000.0) {return 1.0;} + +float width = fract((cloudpos1_x)) * 5000.0; +float strength = fract((cloudpos1_y)); + + +float dlength = length( vec2 (x - cloudpos1_x, y - cloudpos1_y)); +float shadeValue = strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos2_x, y - cloudpos2_y)); +width = fract((cloudpos2_x)) * 5000.0; strength = fract((cloudpos2_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos3_x, y - cloudpos3_y)); +width = fract((cloudpos3_x)) * 5000.0; strength = fract((cloudpos3_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos4_x, y - cloudpos4_y)); +width = fract((cloudpos4_x)) * 5000.0; strength = fract((cloudpos4_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos5_x, y - cloudpos5_y)); +width = fract((cloudpos5_x)) * 5000.0; strength = fract((cloudpos5_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos6_x, y - cloudpos6_y)); +width = fract((cloudpos6_x)) * 5000.0; strength = fract((cloudpos6_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos7_x, y - cloudpos7_y)); +width = fract((cloudpos7_x)) * 5000.0; strength = fract((cloudpos7_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos8_x, y - cloudpos8_y)); +width = fract((cloudpos8_x)) * 5000.0; strength = fract((cloudpos8_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos9_x, y - cloudpos9_y)); +width = fract((cloudpos9_x)) * 5000.0; strength = fract((cloudpos9_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos10_x, y - cloudpos10_y)); +width = fract((cloudpos10_x)) * 5000.0; strength = fract((cloudpos10_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos11_x, y - cloudpos11_y)); +width = fract((cloudpos11_x)) * 5000.0; strength = fract((cloudpos11_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos12_x, y - cloudpos12_y)); +width = fract((cloudpos12_x)) * 5000.0; strength = fract((cloudpos12_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos13_x, y - cloudpos13_y)); +width = fract((cloudpos13_x)) * 5000.0; strength = fract((cloudpos13_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos14_x, y - cloudpos14_y)); +width = fract((cloudpos14_x)) * 5000.0; strength = fract((cloudpos14_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos15_x, y - cloudpos15_y)); +width = fract((cloudpos15_x)) * 5000.0; strength = fract((cloudpos15_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos16_x, y - cloudpos16_y)); +width = fract((cloudpos16_x)) * 5000.0; strength = fract((cloudpos16_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos17_x, y - cloudpos17_y)); +width = fract((cloudpos17_x)) * 5000.0; strength = fract((cloudpos17_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos18_x, y - cloudpos18_y)); +width = fract((cloudpos18_x)) * 5000.0; strength = fract((cloudpos18_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos19_x, y - cloudpos19_y)); +width = fract((cloudpos19_x)) * 5000.0; strength = fract((cloudpos19_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +dlength = length ( vec2 (x - cloudpos20_x, y - cloudpos20_y)); +width = fract((cloudpos20_x)) * 5000.0; strength = fract((cloudpos20_y)); +shadeValue = shadeValue + strength * (1.0-smoothstep(width * 0.5, width, dlength)); + +shadeValue = clamp(shadeValue * (0.5 + 2.0 * noise),0.0,1.0); + +shadeValue = shadeValue * (1.0 - smoothstep(15000.0, 30000.0,dist)); +//shadeValue = clamp(shadeValue * (0.5 + 0.5 * noise),0.0,1.0); + +return 1.0 - shadeValue;// exp(- (dlength * dlength)/(width*width)); + +} diff --git a/Shaders/surface-light-lightfield.frag b/Shaders/surface-light-lightfield.frag index a581b715e..2e1350dbb 100644 --- a/Shaders/surface-light-lightfield.frag +++ b/Shaders/surface-light-lightfield.frag @@ -41,7 +41,7 @@ else } -float light_sprite (in vec2 coord, in float transmission) +vec4 light_sprite (in vec2 coord, in float transmission) { coord.s = coord.s - 0.5; diff --git a/Shaders/terrain-haze-ultra.frag b/Shaders/terrain-haze-ultra.frag index e640a481e..8398c48ad 100644 --- a/Shaders/terrain-haze-ultra.frag +++ b/Shaders/terrain-haze-ultra.frag @@ -54,9 +54,11 @@ uniform float dust_resistance; uniform float WindE; uniform float WindN; uniform float osg_SimulationTime; + uniform int quality_level; uniform int tquality_level; uniform int wind_effects; +uniform int cloud_shadow_flag; const float EarthRadius = 5800000.0; const float terminator_width = 200000.0; @@ -66,7 +68,7 @@ float eShade; float yprime_alt; float mie_angle; - +float shadow_func (in float x, in float y, in float noise, in float dist); float rand2D(in vec2 co){ return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453); @@ -548,6 +550,7 @@ if ((dist < 5000.0)&& (quality_level > 3) && (combined_wetness>0.0)) NdotL = NdotL + (1.0-snow_mix_factor) * 0.3* dot_texel.a * (0.5* dotnoisegrad_10m * detail_fade(1.0 * dot_size, view_angle, dist) +0.5 * dotnoisegrad_10m * noise_01m * detail_fade(0.1, view_angle, dist)) ; if (NdotL > 0.0) { + if (cloud_shadow_flag == 1) {NdotL = NdotL * shadow_func(relPos.x, relPos.y, 0.3 * noise_250m + 0.5 * noise_500m+0.2 * noise_1500m, dist);} color += diffuse_term * NdotL; NdotHV = max(dot(n, halfVector), 0.0); if (gl_FrontMaterial.shininess > 0.0) diff --git a/Shaders/water_lightfield.frag b/Shaders/water_lightfield.frag index ff8dd59c6..b53b79f7c 100644 --- a/Shaders/water_lightfield.frag +++ b/Shaders/water_lightfield.frag @@ -507,7 +507,7 @@ void main(void) - specular_light = gl_Color.rgb; + specular_light = gl_Color.rgb * earthShade; vec3 specular_color = vec3(specular_light) @@ -525,7 +525,7 @@ void main(void) vec4 ambient_light; //intensity = length(specular_light.rgb); - ambient_light.rgb = max(specular_light.rgb, vec3(0.1, 0.1, 0.1)); + ambient_light.rgb = max(specular_light.rgb, vec3(0.05, 0.05, 0.05)); //ambient_light.rgb = max(intensity * normalize(vec3 (0.33, 0.4, 0.5)), vec3 (0.1,0.1,0.1)); ambient_light.a = 1.0; diff --git a/Shaders/water_lightfield_lr.frag b/Shaders/water_lightfield_lr.frag index 6336756e6..48b0e4138 100644 --- a/Shaders/water_lightfield_lr.frag +++ b/Shaders/water_lightfield_lr.frag @@ -407,7 +407,7 @@ void main(void) vec4 ambient_light; //intensity = length(specular_light.rgb); - ambient_light.rgb = max(specular_light.rgb, vec3(0.1, 0.1, 0.1)); + ambient_light.rgb = max(specular_light.rgb, vec3(0.05, 0.05, 0.05)); //ambient_light.rgb = max(intensity * normalize(vec3 (0.33, 0.4, 0.5)), vec3 (0.1,0.1,0.1)); ambient_light.a = 1.0;