diff --git a/Effects/lightning.eff b/Effects/lightning.eff new file mode 100644 index 000000000..bf957e718 --- /dev/null +++ b/Effects/lightning.eff @@ -0,0 +1,9 @@ + + + + Effects/lightning + Effects/rain-layer + + 1 + + diff --git a/Effects/rain-layer.eff b/Effects/rain-layer.eff index aa834df4d..130c0742f 100644 --- a/Effects/rain-layer.eff +++ b/Effects/rain-layer.eff @@ -11,6 +11,7 @@ /environment/lightning/lightning-pos-x /environment/lightning/lightning-pos-y /environment/lightning/lightning-range + 0 @@ -101,6 +102,11 @@ float lightning-range + + is_lightning + bool + is-lightning + diff --git a/Environment/local-weather-defaults.xml b/Environment/local-weather-defaults.xml index a7c0ac76d..68e609937 100644 --- a/Environment/local-weather-defaults.xml +++ b/Environment/local-weather-defaults.xml @@ -108,6 +108,10 @@ 0 0 + + + 0 + diff --git a/Models/Weather/lightning.xml b/Models/Weather/lightning.xml new file mode 100644 index 000000000..6c2789ba6 --- /dev/null +++ b/Models/Weather/lightning.xml @@ -0,0 +1,61 @@ + + + + + lightning.ac + + 0.0 + 0.0 + -1.2 + + + + + rect + Effects/lightning + + + + + scale + 700.0 + 700.0 + 1000.0 + + + + material + + 0.9 + 0.9 + 1.0 + + + + + select + + + + /environment/lightning/flash + 0.0 + + + /local-weather/lightning/model-index + 0 + + + + + + + billboard + false + + + + false + + + + diff --git a/Models/Weather/lightning01.rgb b/Models/Weather/lightning01.rgb new file mode 100644 index 000000000..ac0d6135f Binary files /dev/null and b/Models/Weather/lightning01.rgb differ diff --git a/Models/Weather/lightning02.rgb b/Models/Weather/lightning02.rgb new file mode 100644 index 000000000..633a0f790 Binary files /dev/null and b/Models/Weather/lightning02.rgb differ diff --git a/Models/Weather/lightning1.ac b/Models/Weather/lightning1.ac new file mode 100644 index 000000000..f6fae7b34 --- /dev/null +++ b/Models/Weather/lightning1.ac @@ -0,0 +1,22 @@ +AC3Db +MATERIAL "ac3dmat1" rgb 1 1 1 amb 0.2 0.2 0.2 emis 0 0 0 spec 0.502 0.502 0.502 shi 10 trans 0.008 +OBJECT world +kids 1 +OBJECT poly +name "rect" +loc 0.015 0.165 0 +texture "lightning01.rgb" +numvert 4 +-0.68 1.21 0 +0.68 1.21 0 +0.68 -1.21 0 +-0.68 -1.21 0 +numsurf 1 +SURF 0x0 +mat 0 +refs 4 +3 0 0 +2 1 0 +1 1 1 +0 0 1 +kids 0 diff --git a/Models/Weather/lightning1.xml b/Models/Weather/lightning1.xml index 3df51f1f0..bada6bc2e 100644 --- a/Models/Weather/lightning1.xml +++ b/Models/Weather/lightning1.xml @@ -1,26 +1,26 @@ - lightning.ac + lightning1.ac + + 0.00 + 0.01 + -1.20 + + rect - Effects/rain-layer + Effects/lightning - - 0.0 - 0.0 - -1.2 - - - + scale 700.0 700.0 1000.0 - + material @@ -34,10 +34,16 @@ select + /environment/lightning/flash 0.0 + + /local-weather/lightning/model-index + 1 + + diff --git a/Models/Weather/lightning2.ac b/Models/Weather/lightning2.ac new file mode 100644 index 000000000..1dea06cad --- /dev/null +++ b/Models/Weather/lightning2.ac @@ -0,0 +1,22 @@ +AC3Db +MATERIAL "ac3dmat1" rgb 1 1 1 amb 0.2 0.2 0.2 emis 0 0 0 spec 0.502 0.502 0.502 shi 10 trans 0.008 +OBJECT world +kids 1 +OBJECT poly +name "rect" +loc 0.015 0.165 0 +texture "lightning02.rgb" +numvert 4 +-0.68 1.21 0 +0.68 1.21 0 +0.68 -1.21 0 +-0.68 -1.21 0 +numsurf 1 +SURF 0x0 +mat 0 +refs 4 +3 0 0 +2 1 0 +1 1 1 +0 0 1 +kids 0 diff --git a/Models/Weather/lightning2.xml b/Models/Weather/lightning2.xml new file mode 100644 index 000000000..02e976f2e --- /dev/null +++ b/Models/Weather/lightning2.xml @@ -0,0 +1,60 @@ + + + + lightning2.ac + + 0.00 + 0.02 + -1.20 + + + + + rect + Effects/lightning + + + + + scale + 700.0 + 700.0 + 1000.0 + + + + material + + 0.9 + 0.9 + 1.0 + + + + + select + + + + /environment/lightning/flash + 0.0 + + + /local-weather/lightning/model-index + 2 + + + + + + + billboard + false + + + + false + + + + diff --git a/Models/Weather/lightning_combined.xml b/Models/Weather/lightning_combined.xml new file mode 100644 index 000000000..3cacc872b --- /dev/null +++ b/Models/Weather/lightning_combined.xml @@ -0,0 +1,17 @@ + + + + + + lightning.xml + + + + lightning1.xml + + + + lightning2.xml + + + diff --git a/Nasal/local_weather/local_weather.nas b/Nasal/local_weather/local_weather.nas index d48c616cf..0b39a8570 100644 --- a/Nasal/local_weather/local_weather.nas +++ b/Nasal/local_weather/local_weather.nas @@ -4058,7 +4058,7 @@ if (local_weather.cloud_shadow_flag == 1) setprop(lw~"thunderstorm-loop-flag",1); -local_weather.place_model_controlled("lightning", "Models/Weather/lightning1.xml", lat, lon, 0.0, 0.0, 0.0, 0.0); +local_weather.place_model_controlled("lightning", "Models/Weather/lightning_combined.xml", lat, lon, 0.0, 0.0, 0.0, 0.0); local_weather.thunderstorm_management_loop(); diff --git a/Nasal/local_weather/weather_tile_management.nas b/Nasal/local_weather/weather_tile_management.nas index 2d37d831f..c89d7fdd8 100644 --- a/Nasal/local_weather/weather_tile_management.nas +++ b/Nasal/local_weather/weather_tile_management.nas @@ -1303,6 +1303,13 @@ for (var i = 0; i < n; i=i+1) setprop("/local-weather/lightning/latitude-deg", tstorm.lat - offset_x * local_weather.m_to_lat); setprop("/local-weather/lightning/longitude-deg", tstorm.lon + offset_y * local_weather.m_to_lon); setprop("/local-weather/lightning/altitude-ft", tstorm.alt); + + var rn = rand(); + var type = 0; + if (rn > 0.7) {type = 1;} + else if (rn > 0.3) {type = 2;} + setprop("/local-weather/lightning/model-index", type); + lightning_strike(); if (dist > 50000.0) diff --git a/Shaders/rain-layer-ALS.frag b/Shaders/rain-layer-ALS.frag index 000da97c8..17d2c4d85 100644 --- a/Shaders/rain-layer-ALS.frag +++ b/Shaders/rain-layer-ALS.frag @@ -1,12 +1,16 @@ uniform sampler2D baseTexture; varying float fogFactor; - varying vec3 hazeColor; +uniform bool is_lightning; + void main(void) { vec4 base = texture2D( baseTexture, gl_TexCoord[0].st); vec4 finalColor = base * gl_Color; - gl_FragColor.rgb = mix(hazeColor, finalColor.rgb, fogFactor ); + if (is_lightning==0) + {gl_FragColor.rgb = mix(hazeColor, finalColor.rgb, fogFactor );} + else + {gl_FragColor.rgb = finalColor;} gl_FragColor.a = mix(0.0, finalColor.a, fogFactor); } diff --git a/Shaders/rain-layer-ALS.vert b/Shaders/rain-layer-ALS.vert index b008d5553..5b23ee5bd 100644 --- a/Shaders/rain-layer-ALS.vert +++ b/Shaders/rain-layer-ALS.vert @@ -101,7 +101,9 @@ void main(void) vec2 lightningRelVector = relVector.xy - vec2(lightning_pos_x, lightning_pos_y); float rCoord = length(lightningRelVector); - gl_FrontColor.rgb += 2.0 * flash * vec3 (0.43, 0.57, 1.0) * (1.0 - smoothstep(lightning_range, 5.0 * lightning_range, rCoord)); + vec3 flashColor = 2.0 * flash * vec3 (0.43, 0.57, 1.0) * (1.0 - smoothstep(lightning_range, 5.0 * lightning_range, rCoord)); + + gl_FrontColor.rgb += flashColor; gl_FrontColor.rgb = clamp(gl_FrontColor.rgb,0.0,1.0); // As we get within 100m of the sprite, it is faded out. Equally at large distances it also fades out.