More work on rendering lighting in ALS, public domain NOAA image resources are gratefully acknowledged
This commit is contained in:
parent
a48dea9e48
commit
454fa8df8f
15 changed files with 234 additions and 14 deletions
9
Effects/lightning.eff
Normal file
9
Effects/lightning.eff
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- lightning -->
|
||||
<PropertyList>
|
||||
<name>Effects/lightning</name>
|
||||
<inherits-from>Effects/rain-layer</inherits-from>
|
||||
<parameters>
|
||||
<is-lightning type="bool">1</is-lightning>
|
||||
</parameters>
|
||||
</PropertyList>
|
|
@ -11,6 +11,7 @@
|
|||
<lightning-pos-x><use>/environment/lightning/lightning-pos-x</use></lightning-pos-x>
|
||||
<lightning-pos-y><use>/environment/lightning/lightning-pos-y</use></lightning-pos-y>
|
||||
<lightning-range><use>/environment/lightning/lightning-range</use></lightning-range>
|
||||
<is-lightning type="bool">0</is-lightning>
|
||||
</parameters>
|
||||
<technique n="9">
|
||||
<predicate>
|
||||
|
@ -101,6 +102,11 @@
|
|||
<type>float</type>
|
||||
<value><use>lightning-range</use></value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>is_lightning</name>
|
||||
<type>bool</type>
|
||||
<value><use>is-lightning</use></value>
|
||||
</uniform>
|
||||
<!--<vertex-program-two-side>true</vertex-program-two-side>-->
|
||||
</pass>
|
||||
</technique>
|
||||
|
|
|
@ -108,6 +108,10 @@
|
|||
<cloud-shadow-flag type="bool" userarchive="y">0</cloud-shadow-flag>
|
||||
<cloud-shadow-fov-flag type="bool" userarchive="y">0</cloud-shadow-fov-flag>
|
||||
</cloud-shadows>
|
||||
|
||||
<lightning>
|
||||
<model-index type="int" userarchive="n">0</model-index>
|
||||
</lightning>
|
||||
</PropertyList>
|
||||
|
||||
|
||||
|
|
61
Models/Weather/lightning.xml
Normal file
61
Models/Weather/lightning.xml
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<PropertyList>
|
||||
|
||||
<path>lightning.ac</path>
|
||||
<offsets>
|
||||
<x-m> 0.0 </x-m>
|
||||
<y-m> 0.0</y-m>
|
||||
<z-m>-1.2 </z-m>
|
||||
</offsets>
|
||||
|
||||
|
||||
<effect>
|
||||
<object-name>rect</object-name>
|
||||
<inherits-from>Effects/lightning</inherits-from>
|
||||
</effect>
|
||||
|
||||
|
||||
<animation>
|
||||
<type>scale</type>
|
||||
<x-offset>700.0</x-offset>
|
||||
<y-offset>700.0</y-offset>
|
||||
<z-offset>1000.0</z-offset>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>material</type>
|
||||
<emission>
|
||||
<red> 0.9 </red>
|
||||
<green> 0.9 </green>
|
||||
<blue> 1.0 </blue>
|
||||
</emission>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>select</type>
|
||||
<condition>
|
||||
<and>
|
||||
<greater-than>
|
||||
<property>/environment/lightning/flash</property>
|
||||
<value>0.0</value>
|
||||
</greater-than>
|
||||
<equals>
|
||||
<property>/local-weather/lightning/model-index</property>
|
||||
<value>0</value>
|
||||
</equals>
|
||||
</and>
|
||||
</condition>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>billboard</type>
|
||||
<spherical>false</spherical>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<enable-hot type="bool">false</enable-hot>
|
||||
</animation>
|
||||
|
||||
|
||||
</PropertyList>
|
BIN
Models/Weather/lightning01.rgb
Normal file
BIN
Models/Weather/lightning01.rgb
Normal file
Binary file not shown.
BIN
Models/Weather/lightning02.rgb
Normal file
BIN
Models/Weather/lightning02.rgb
Normal file
Binary file not shown.
22
Models/Weather/lightning1.ac
Normal file
22
Models/Weather/lightning1.ac
Normal file
|
@ -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
|
|
@ -1,26 +1,26 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<PropertyList>
|
||||
<path>lightning.ac</path>
|
||||
|
||||
<effect>
|
||||
<object-name>rect</object-name>
|
||||
<inherits-from>Effects/rain-layer</inherits-from>
|
||||
</effect>
|
||||
|
||||
<path>lightning1.ac</path>
|
||||
<offsets>
|
||||
<x-m> 0.0 </x-m>
|
||||
<y-m> 0.0</y-m>
|
||||
<z-m>-1.2 </z-m>
|
||||
<x-m> 0.00 </x-m>
|
||||
<y-m> 0.01</y-m>
|
||||
<z-m>-1.20 </z-m>
|
||||
</offsets>
|
||||
|
||||
|
||||
<animation>
|
||||
<effect>
|
||||
<object-name>rect</object-name>
|
||||
<inherits-from>Effects/lightning</inherits-from>
|
||||
</effect>
|
||||
|
||||
|
||||
<animation>
|
||||
<type>scale</type>
|
||||
<x-offset>700.0</x-offset>
|
||||
<y-offset>700.0</y-offset>
|
||||
<z-offset>1000.0</z-offset>
|
||||
</animation>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>material</type>
|
||||
|
@ -34,10 +34,16 @@
|
|||
<animation>
|
||||
<type>select</type>
|
||||
<condition>
|
||||
<and>
|
||||
<greater-than>
|
||||
<property>/environment/lightning/flash</property>
|
||||
<value>0.0</value>
|
||||
</greater-than>
|
||||
<equals>
|
||||
<property>/local-weather/lightning/model-index</property>
|
||||
<value>1</value>
|
||||
</equals>
|
||||
</and>
|
||||
</condition>
|
||||
</animation>
|
||||
|
||||
|
|
22
Models/Weather/lightning2.ac
Normal file
22
Models/Weather/lightning2.ac
Normal file
|
@ -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
|
60
Models/Weather/lightning2.xml
Normal file
60
Models/Weather/lightning2.xml
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<PropertyList>
|
||||
<path>lightning2.ac</path>
|
||||
<offsets>
|
||||
<x-m> 0.00 </x-m>
|
||||
<y-m> 0.02 </y-m>
|
||||
<z-m>-1.20 </z-m>
|
||||
</offsets>
|
||||
|
||||
|
||||
<effect>
|
||||
<object-name>rect</object-name>
|
||||
<inherits-from>Effects/lightning</inherits-from>
|
||||
</effect>
|
||||
|
||||
|
||||
<animation>
|
||||
<type>scale</type>
|
||||
<x-offset>700.0</x-offset>
|
||||
<y-offset>700.0</y-offset>
|
||||
<z-offset>1000.0</z-offset>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>material</type>
|
||||
<emission>
|
||||
<red> 0.9 </red>
|
||||
<green> 0.9 </green>
|
||||
<blue> 1.0 </blue>
|
||||
</emission>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>select</type>
|
||||
<condition>
|
||||
<and>
|
||||
<greater-than>
|
||||
<property>/environment/lightning/flash</property>
|
||||
<value>0.0</value>
|
||||
</greater-than>
|
||||
<equals>
|
||||
<property>/local-weather/lightning/model-index</property>
|
||||
<value>2</value>
|
||||
</equals>
|
||||
</and>
|
||||
</condition>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<type>billboard</type>
|
||||
<spherical>false</spherical>
|
||||
</animation>
|
||||
|
||||
<animation>
|
||||
<enable-hot type="bool">false</enable-hot>
|
||||
</animation>
|
||||
|
||||
|
||||
</PropertyList>
|
17
Models/Weather/lightning_combined.xml
Normal file
17
Models/Weather/lightning_combined.xml
Normal file
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<PropertyList>
|
||||
|
||||
<model>
|
||||
<path>lightning.xml</path>
|
||||
</model>
|
||||
|
||||
<model>
|
||||
<path>lightning1.xml</path>
|
||||
</model>
|
||||
|
||||
<model>
|
||||
<path>lightning2.xml</path>
|
||||
</model>
|
||||
|
||||
</PropertyList>
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue