1
0
Fork 0

More work on rendering lighting in ALS, public domain NOAA image resources are gratefully acknowledged

This commit is contained in:
Thorsten Renk 2015-08-12 11:31:05 +03:00
parent a48dea9e48
commit 454fa8df8f
15 changed files with 234 additions and 14 deletions

9
Effects/lightning.eff Normal file
View 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>

View file

@ -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>

View file

@ -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>

View 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>

Binary file not shown.

Binary file not shown.

View 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

View file

@ -1,19 +1,19 @@
<?xml version="1.0"?>
<PropertyList>
<path>lightning.ac</path>
<path>lightning1.ac</path>
<offsets>
<x-m> 0.00 </x-m>
<y-m> 0.01</y-m>
<z-m>-1.20 </z-m>
</offsets>
<effect>
<object-name>rect</object-name>
<inherits-from>Effects/rain-layer</inherits-from>
<inherits-from>Effects/lightning</inherits-from>
</effect>
<offsets>
<x-m> 0.0 </x-m>
<y-m> 0.0</y-m>
<z-m>-1.2 </z-m>
</offsets>
<animation>
<type>scale</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>

View 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

View 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>

View 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>

View file

@ -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();

View file

@ -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)

View file

@ -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);
}

View file

@ -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.