From ce77fcfac99b1813b7f3bb47953803db742657f6 Mon Sep 17 00:00:00 2001 From: Thorsten Renk Date: Wed, 18 Feb 2015 10:35:00 +0200 Subject: [PATCH] European deciduous trees change autumn color in ALS --- Effects/tree-european-deciduous.eff | 8 ++++++ Effects/tree-european-mixed.eff | 8 ++++++ Effects/tree.eff | 22 +++++++++++++++ Materials/regions/europe.xml | 43 +++++++++++++++++++++++++++++ Materials/regions/global-summer.xml | 9 ++++++ Shaders/tree-ALS.frag | 16 +++++++++++ Shaders/tree-ALS.vert | 9 +++++- 7 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 Effects/tree-european-deciduous.eff create mode 100644 Effects/tree-european-mixed.eff diff --git a/Effects/tree-european-deciduous.eff b/Effects/tree-european-deciduous.eff new file mode 100644 index 000000000..02b03fa06 --- /dev/null +++ b/Effects/tree-european-deciduous.eff @@ -0,0 +1,8 @@ + + + Effects/tree-european-deciduous + Effects/tree + + 8 + + diff --git a/Effects/tree-european-mixed.eff b/Effects/tree-european-mixed.eff new file mode 100644 index 000000000..da967fd86 --- /dev/null +++ b/Effects/tree-european-mixed.eff @@ -0,0 +1,8 @@ + + + Effects/tree-european-mixed + Effects/tree + + 4 + + diff --git a/Effects/tree.eff b/Effects/tree.eff index 8b5226d06..c6fb62716 100644 --- a/Effects/tree.eff +++ b/Effects/tree.eff @@ -17,6 +17,7 @@ + 0 /environment/ground-visibility-m /environment/visibility-m /environment/ground-haze-thickness-m @@ -29,6 +30,7 @@ /sim/rendering/eye-altitude-m /environment/snow-level-m /environment/tree-season + /environment/season /environment/surface/dust-cover-factor /sim/rendering/shaders/skydome /environment/fog-structure @@ -202,6 +204,11 @@ float season + + cseason + float + cseason + WindE float @@ -472,6 +479,11 @@ int display_ysize + + num_deciduous_trees + int + num_deciduous_trees + texture sampler-2d @@ -618,6 +630,11 @@ float season + + cseason + float + cseason + WindE float @@ -888,6 +905,11 @@ int display_ysize + + num_deciduous_trees + int + num_deciduous_trees + texture sampler-2d diff --git a/Materials/regions/europe.xml b/Materials/regions/europe.xml index 254c6a91a..05e5fa037 100644 --- a/Materials/regions/europe.xml +++ b/Materials/regions/europe.xml @@ -60,6 +60,7 @@ Effects/cropgrass + Effects/tree-european-mixed CropGrassCover CropGrass Terrain/cropgrass-hires-autumn.png @@ -97,6 +98,7 @@ BuiltUpCover Urban + Effects/tree-european-deciduous Terrain/18th_century_city.png Terrain/18th_century_city.mask.png 1000 @@ -245,4 +247,45 @@ 12.0 + + Effects/forest + Effects/tree-european-deciduous + DeciduousBroadCover + DeciduousForest + Bog + Heath + Terrain/deciduous-hires-autumn.png + 2000 + 2000 + 10000000.0 + 4000.0 + Trees/deciduous-alt.png + 8 + + 25.0 + 15.0 + 1 + 0.85 + + + + Effects/forest + Effects/tree-european-mixed + MixedForestCover + MixedForest + RainForest + Terrain/mixedforest-hires-autumn.png + 2000 + 2000 + 5000000.0 + 4000.0 + Trees/mixed-alt.png + 8 + + 25.0 + 15.0 + 1 + 0.95 + + diff --git a/Materials/regions/global-summer.xml b/Materials/regions/global-summer.xml index c329f0097..ba17e97d8 100644 --- a/Materials/regions/global-summer.xml +++ b/Materials/regions/global-summer.xml @@ -522,6 +522,15 @@ 0.1 0.1 1e30 + diff --git a/Shaders/tree-ALS.frag b/Shaders/tree-ALS.frag index e3988f332..9f48306dd 100644 --- a/Shaders/tree-ALS.frag +++ b/Shaders/tree-ALS.frag @@ -11,6 +11,7 @@ uniform sampler2D texture; varying float yprime_alt; +varying float autumn_flag; uniform float visibility; uniform float avisibility; @@ -26,6 +27,7 @@ uniform float dust_cover_factor; uniform float air_pollution; uniform float landing_light1_offset; uniform float landing_light2_offset; +uniform float cseason; uniform int use_searchlight; uniform int use_landing_light; @@ -135,10 +137,22 @@ void main() if (quality_level > 3) { + + // seasonal color changes + + if ((cseason < 1.5)&& (autumn_flag > 0.0)) + { + texel.r = min(1.0, (1.0 + 5.0 *cseason * autumn_flag ) * texel.r); + //texel.g = texel.g + 0.05 * (autumn_flag-0.5) * cseason; + texel.b = max(0.0, (1.0 - 8.0 * cseason) * texel.b); + } + // mix dust vec4 dust_color = vec4 (0.76, 0.71, 0.56, texel.a); texel = mix(texel, dust_color, clamp(0.6 * dust_cover_factor ,0.0, 1.0) ); + + } @@ -346,6 +360,8 @@ fragColor.rgb = mix( hazeColor + secondary_light * fog_backscatter(mvisibility) } +//if (autumn_flag > 0.0) {fragColor = vec4 (0.0,0.0,0.0,1.0);} + gl_FragColor = fragColor; } diff --git a/Shaders/tree-ALS.vert b/Shaders/tree-ALS.vert index 3ef742141..65c7e4136 100644 --- a/Shaders/tree-ALS.vert +++ b/Shaders/tree-ALS.vert @@ -22,10 +22,12 @@ varying vec3 relPos; varying float yprime_alt; +varying float autumn_flag; uniform int colorMode; uniform int wind_effects; uniform int forest_effects; +uniform int num_deciduous_trees; uniform float hazeLayerAltitude; uniform float terminator; uniform float terrain_alt; @@ -66,7 +68,6 @@ return e / pow((1.0 + a * exp(-b * (x-c)) ),(1.0/d)); void main() { - //vec4 light_diffuse; vec4 light_ambient; vec3 shadedFogColor = vec3(0.55, 0.67, 0.88); @@ -81,6 +82,12 @@ void main() float numVarieties = gl_Normal.z; float texFract = floor(fract(gl_MultiTexCoord0.x) * numVarieties) / numVarieties; + +// determine whether the tree changes color in autumn + if (texFract < (float) num_deciduous_trees/numVarieties) {autumn_flag = 0.5 + fract(gl_Color.x);} + else {autumn_flag = 0.0;} + + texFract += floor(gl_MultiTexCoord0.x) / numVarieties; // Determine the rotation for the tree. The Fog Coordinate provides rotation information