Updates to Earthview, based on work by Anton Gomez Alvedro
This commit is contained in:
parent
021133e657
commit
3970bad285
7 changed files with 274 additions and 20 deletions
|
@ -17,8 +17,6 @@
|
|||
|
||||
<technique n="10">
|
||||
<predicate>
|
||||
<and>
|
||||
<property>/sim/rendering/shaders/generic</property>
|
||||
<or>
|
||||
<less-equal>
|
||||
<value type="float">2.0</value>
|
||||
|
@ -31,7 +29,6 @@
|
|||
<extension-supported>GL_ARB_fragment_shader</extension-supported>
|
||||
</and>
|
||||
</or>
|
||||
</and>
|
||||
</predicate>
|
||||
<pass>
|
||||
<lighting>true</lighting>
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
</material>
|
||||
<visibility><use>/environment/visibility-m</use></visibility>
|
||||
<use-clouds><use>/earthview/cloudsphere-flag</use></use-clouds>
|
||||
<use-cloud-shadows><use>/earthview/cloud-shadow-flag</use></use-cloud-shadows>
|
||||
</parameters>
|
||||
<generate>
|
||||
<tangent type="int">6</tangent>
|
||||
|
@ -29,8 +30,6 @@
|
|||
|
||||
<technique n="10">
|
||||
<predicate>
|
||||
<and>
|
||||
<property>/sim/rendering/shaders/generic</property>
|
||||
<or>
|
||||
<less-equal>
|
||||
<value type="float">2.0</value>
|
||||
|
@ -43,7 +42,6 @@
|
|||
<extension-supported>GL_ARB_fragment_shader</extension-supported>
|
||||
</and>
|
||||
</or>
|
||||
</and>
|
||||
</predicate>
|
||||
<pass>
|
||||
<lighting>true</lighting>
|
||||
|
@ -141,6 +139,13 @@
|
|||
<use>use-clouds</use>
|
||||
</value>
|
||||
</uniform>
|
||||
<uniform>
|
||||
<name>use_cloud_shadows</name>
|
||||
<type>bool</type>
|
||||
<value>
|
||||
<use>use-cloud-shadows</use>
|
||||
</value>
|
||||
</uniform>
|
||||
</pass>
|
||||
</technique>
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
var start = func() {
|
||||
|
||||
if (earthview_running_flag == 1) {return;}
|
||||
if (earthview_running_flag ==1) {return;}
|
||||
|
||||
earthview_running_flag = 1;
|
||||
|
||||
|
@ -13,6 +13,20 @@ var lon = getprop("/position/longitude-deg");
|
|||
|
||||
earth_model.node = earthview.place_earth_model("Models/Astro/earth.xml",lat, lon, 0.0, 0.0, 0.0, 0.0);
|
||||
cloudsphere_model.node = earthview.place_earth_model("Models/Astro/cloudsphere.xml",lat, lon, 0.0, 0.0, 0.0, 0.0);
|
||||
|
||||
# set Basic Weather off
|
||||
props.globals.getNode("/environment/config/enabled").setBoolValue(0);
|
||||
props.globals.getNode("/environment/params/metar-updates-environment").setBoolValue(0);
|
||||
|
||||
# set some reasonable defaults
|
||||
|
||||
setprop("/environment/visibility-m", 80000.0);
|
||||
setprop("/sim/rendering/mie", 0.0);
|
||||
setprop("/sim/rendering/rayleigh", 0.00002);
|
||||
setprop("/sim/rendering/dome-density", 1.0);
|
||||
|
||||
control_loop();
|
||||
|
||||
}
|
||||
|
||||
var stop = func () {
|
||||
|
@ -20,6 +34,7 @@ var stop = func () {
|
|||
earth_model.node.remove();
|
||||
cloudsphere_model.node.remove();
|
||||
setprop("/earthview/control_loop_flag",0);
|
||||
|
||||
earthview_running_flag = 0;
|
||||
}
|
||||
|
||||
|
@ -70,7 +85,7 @@ model.getNode("load", 1).remove();
|
|||
setprop("/earthview/heading-deg",90);
|
||||
setprop("/earthview/control_loop_flag",1);
|
||||
|
||||
control_loop();
|
||||
|
||||
|
||||
return model;
|
||||
}
|
||||
|
@ -96,14 +111,50 @@ setprop("/earthview/longitude-deg", lon);
|
|||
setprop("/earthview/roll-deg", -(90-lat));
|
||||
setprop("/earthview/yaw-deg", -lon);
|
||||
|
||||
# now set scattering paramaters
|
||||
|
||||
if (getprop("/earthview/mrd-flag") == 1)
|
||||
{
|
||||
var rayleigh = 0.0002;
|
||||
var mie = 0.001;
|
||||
var density = 1.0;
|
||||
|
||||
if (altitude1 < 300000.0)
|
||||
{
|
||||
setprop("/sim/rendering/rayleigh",rayleigh);
|
||||
setprop("/sim/rendering/mie",mie);
|
||||
setprop("/sim/rendering/dome-density",density);
|
||||
}
|
||||
else if (altitude1 < 650000.0)
|
||||
{
|
||||
rayleigh = rayleigh - 0.00018 * (altitude1-300000.0)/350000.0;
|
||||
mie = mie - 0.001 * (altitude1-300000.0)/350000.0;
|
||||
density = 1.0;
|
||||
setprop("/sim/rendering/rayleigh",rayleigh);
|
||||
setprop("/sim/rendering/mie",mie);
|
||||
setprop("/sim/rendering/dome-density",density);
|
||||
}
|
||||
else
|
||||
{
|
||||
rayleigh = 0.00002;
|
||||
mie = 0.0;
|
||||
density = 1.0;
|
||||
setprop("/sim/rendering/rayleigh",rayleigh);
|
||||
setprop("/sim/rendering/mie",mie);
|
||||
setprop("/sim/rendering/dome-density",density);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (getprop("/earthview/control_loop_flag") ==1) {settimer( func {control_loop(); },0);}
|
||||
}
|
||||
|
||||
var earthview_running_flag = 0;
|
||||
|
||||
var ft_to_m = 0.30480;
|
||||
var m_to_ft = 1.0/ft_to_m;
|
||||
var earth_model = {};
|
||||
var cloudsphere_model = {};
|
||||
var earthview_running_flag = 0;
|
||||
|
||||
|
||||
|
|
|
@ -63,5 +63,4 @@ void main()
|
|||
fragColor = color * texel + specular;
|
||||
|
||||
gl_FragColor = fragColor;
|
||||
//gl_FragColor = (0.5,0.5,0.5,1.0);
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ varying vec3 VTangent;
|
|||
|
||||
uniform float visibility;
|
||||
uniform bool use_clouds;
|
||||
uniform bool use_cloud_shadows;
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D shadowtex;
|
||||
|
||||
|
@ -44,11 +45,11 @@ void main()
|
|||
float xOffset = -0.005 * dot(normalize(lightDir), normalize(VTangent));
|
||||
float yOffset = -0.005 * dot(normalize(lightDir), normalize(VBinormal));
|
||||
|
||||
if (use_clouds)
|
||||
if ((use_cloud_shadows)&&(use_clouds))
|
||||
{shadowTexel = texture2D(shadowtex, vec2(gl_TexCoord[0].s-xOffset, gl_TexCoord[0].t-yOffset));}
|
||||
else
|
||||
{shadowTexel = vec4 (0.0,0.0,0.0,0.0);}
|
||||
|
||||
{shadowTexel = vec4 (0.0,0.0,0.0,0.0);}
|
||||
|
||||
texel = texture2D(texture, gl_TexCoord[0].st);
|
||||
|
||||
vec3 light_specular = vec3 (1.0, 1.0, 1.0);
|
||||
|
@ -61,7 +62,7 @@ void main()
|
|||
intensity = length(light_specular);
|
||||
light_specular = mix(dawn.rgb, light_specular, smoothstep(0.0, 0.2, NdotL));
|
||||
|
||||
float specular_enhancement = 4.0 * (1.0 -smoothstep(0.0, 0.3,length(texel.rgb - vec3 (0.007,0.019, 0.078))));
|
||||
float specular_enhancement = 4.0 * (1.0 -smoothstep(0.0, 0.1,length(texel.rgb - vec3 (0.007,0.019, 0.078))));
|
||||
|
||||
if (NdotL > 0.0) {
|
||||
color += diffuse_term * NdotL * (1.0-shadowTexel.a);
|
||||
|
@ -84,13 +85,11 @@ void main()
|
|||
float angle = dot(normalize(ecViewDir), normalize(normal));
|
||||
float distance_through_atmosphere = 10.0 / ((angle)+0.001);
|
||||
|
||||
vec4 fogColor = vec4 (0.83,0.9,1.0,1.0) * clamp(length(diffuse_term.rgb * max(NdotL,0.0)),0.0,1.0);
|
||||
vec4 fogColor = vec4 (0.83,0.9,1.0,1.0) * clamp(length(diffuse_term.rgb * clamp(NdotL,0.01, 0.99)),0.0,1.0);
|
||||
//float visibility = 80.0;
|
||||
float fogFactor = exp(-distance_through_atmosphere/(visibility/1000.0));
|
||||
|
||||
fragColor = mix(fogColor, fragColor, fogFactor);
|
||||
|
||||
//fragColor.rgb = fog_Func(fragColor.rgb, fogType);
|
||||
gl_FragColor = fragColor;
|
||||
//gl_FragColor = (0.5,0.5,0.5,1.0);
|
||||
}
|
||||
|
|
|
@ -52,17 +52,60 @@
|
|||
</text>
|
||||
|
||||
<checkbox>
|
||||
<name>cloudsphere-flag</name>
|
||||
<row>0</row>
|
||||
<col>1</col>
|
||||
<halign>left</halign>
|
||||
<property>/earthview/cloudsphere-flag</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>cloudsphere-flag</object-name>
|
||||
</binding>
|
||||
</checkbox>
|
||||
|
||||
<text>
|
||||
<enable><property>/earthview/cloudsphere-flag</property></enable>
|
||||
<row>1</row>
|
||||
<col>0</col>
|
||||
<halign>right</halign>
|
||||
<label>Show cloud shadows</label>
|
||||
</text>
|
||||
|
||||
<checkbox>
|
||||
<enable><property>/earthview/cloudsphere-flag</property></enable>
|
||||
<name>cloud-shadow-flag</name>
|
||||
<row>1</row>
|
||||
<col>1</col>
|
||||
<halign>left</halign>
|
||||
<property>/earthview/cloud-shadow-flag</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>cloud-shadow-flag</object-name>
|
||||
<script>
|
||||
if(getprop("/earthview/cloud-shadow-flag")==1) {setprop("/earthview/cloudsphere-angle",0.0);}
|
||||
</script>
|
||||
</binding>
|
||||
</checkbox>
|
||||
|
||||
<text>
|
||||
<row>2</row>
|
||||
<col>0</col>
|
||||
<halign>right</halign>
|
||||
<label>Automatic light scattering</label>
|
||||
</text>
|
||||
|
||||
<checkbox>
|
||||
<row>2</row>
|
||||
<col>1</col>
|
||||
<halign>left</halign>
|
||||
<property>/earthview/mrd-flag</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
</binding>
|
||||
</checkbox>
|
||||
|
||||
<button>
|
||||
<row>1</row>
|
||||
<row>3</row>
|
||||
<col>0</col>
|
||||
<legend>Start</legend>
|
||||
<equal>true</equal>
|
||||
|
@ -73,7 +116,7 @@
|
|||
</button>
|
||||
|
||||
<button>
|
||||
<row>1</row>
|
||||
<row>3</row>
|
||||
<col>1</col>
|
||||
<legend>Stop</legend>
|
||||
<equal>true</equal>
|
||||
|
@ -84,7 +127,7 @@
|
|||
</button>
|
||||
|
||||
<button>
|
||||
<row>1</row>
|
||||
<row>3</row>
|
||||
<col>2</col>
|
||||
<legend>Cancel</legend>
|
||||
<equal>true</equal>
|
||||
|
@ -95,7 +138,164 @@
|
|||
</button>
|
||||
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<text>
|
||||
<label>Cloudsphere rotation</label>
|
||||
<halign>left</halign>
|
||||
</text>
|
||||
<hrule>
|
||||
<stretch>true</stretch>
|
||||
</hrule>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<halign>right</halign>
|
||||
<text>
|
||||
<enable><not><property>/earthview/cloud-shadow-flag</property></not></enable>
|
||||
<label>Rotation angle</label>
|
||||
</text>
|
||||
<slider>
|
||||
<enable><not><property>/earthview/cloud-shadow-flag</property></not></enable>
|
||||
<name>cloud-rotation-angle</name>
|
||||
<min>0.0</min>
|
||||
<max>360.0</max>
|
||||
<step>0.1</step>
|
||||
<live>true</live>
|
||||
<property>/earthview/cloudsphere-angle</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>cloud-rotation-angle</object-name>
|
||||
</binding>
|
||||
</slider>
|
||||
<text>
|
||||
<label>12345678</label>
|
||||
<format>%.3f</format>
|
||||
<live>true</live>
|
||||
<property>/earthview/cloudsphere-angle</property>
|
||||
</text>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<text>
|
||||
<label>Atmospheric effects</label>
|
||||
<halign>left</halign>
|
||||
</text>
|
||||
<hrule>
|
||||
<stretch>true</stretch>
|
||||
</hrule>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<halign>right</halign>
|
||||
<text>
|
||||
<enable><not><property>/earthview/mrd-flag</property></not></enable>
|
||||
<label>Mie factor</label>
|
||||
</text>
|
||||
<slider>
|
||||
<enable><not><property>/earthview/mrd-flag</property></not></enable>
|
||||
<name>mie-factor</name>
|
||||
<min>0.0</min>
|
||||
<max>0.01</max>
|
||||
<step>0.001</step>
|
||||
<live>true</live>
|
||||
<property>/sim/rendering/mie</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>mie-factor</object-name>
|
||||
</binding>
|
||||
</slider>
|
||||
<text>
|
||||
<label>12345678</label>
|
||||
<format>%.3f</format>
|
||||
<live>true</live>
|
||||
<property>/sim/rendering/mie</property>
|
||||
</text>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<halign>right</halign>
|
||||
<text>
|
||||
<enable><not><property>/earthview/mrd-flag</property></not></enable>
|
||||
<label>Rayleigh factor</label>
|
||||
</text>
|
||||
<slider>
|
||||
<enable><not><property>/earthview/mrd-flag</property></not></enable>
|
||||
<name>rayleigh-factor</name>
|
||||
<min>0.0</min>
|
||||
<max>0.001</max>
|
||||
<step>0.00002</step>
|
||||
<property>/sim/rendering/rayleigh</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>rayleigh-factor</object-name>
|
||||
</binding>
|
||||
</slider>
|
||||
<text>
|
||||
<label>12345678</label>
|
||||
<format>%.5f</format>
|
||||
<live>true</live>
|
||||
<property>/sim/rendering/rayleigh</property>
|
||||
</text>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<halign>right</halign>
|
||||
<text>
|
||||
<enable><not><property>/earthview/mrd-flag</property></not></enable>
|
||||
<label>Density factor</label>
|
||||
</text>
|
||||
<slider>
|
||||
<name>density-factor</name>
|
||||
<enable><not><property>/earthview/mrd-flag</property></not></enable>
|
||||
<min>0.0</min>
|
||||
<max>1.0</max>
|
||||
<step>0.1</step>
|
||||
<property>/sim/rendering/dome-density</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>density-factor</object-name>
|
||||
</binding>
|
||||
</slider>
|
||||
<text>
|
||||
<label>12345678</label>
|
||||
<format>%.1f</format>
|
||||
<live>true</live>
|
||||
<property>/sim/rendering/dome-density</property>
|
||||
</text>
|
||||
</group>
|
||||
|
||||
<group>
|
||||
<layout>hbox</layout>
|
||||
<halign>right</halign>
|
||||
<text>
|
||||
<label>Visibility</label>
|
||||
</text>
|
||||
<slider>
|
||||
<name>visibility</name>
|
||||
<min>30000.0</min>
|
||||
<max>250000.0</max>
|
||||
<step>10.0</step>
|
||||
<property>/environment/visibility-m</property>
|
||||
<binding>
|
||||
<command>dialog-apply</command>
|
||||
<object-name>visibility</object-name>
|
||||
</binding>
|
||||
<live>true</live>
|
||||
</slider>
|
||||
<text>
|
||||
<label>12345678</label>
|
||||
<format>%.1f</format>
|
||||
<live>true</live>
|
||||
<property>/environment/visibility-m</property>
|
||||
</text>
|
||||
</group>
|
||||
<!--<button>
|
||||
<x>10</x>
|
||||
<y>10</y>
|
||||
|
|
|
@ -1326,6 +1326,9 @@ Started September 2000 by David Megginson, david@megginson.com
|
|||
|
||||
<earthview>
|
||||
<cloudsphere-flag type="bool" userarchive="y">true</cloudsphere-flag>
|
||||
<cloud-shadow-flag type="bool" userarchive="y"></cloud-shadow-flag>
|
||||
<mrd-flag type="bool" userarchive="y"></mrd-flag>
|
||||
<cloudsphere-angle type="double" userarchive="y">0.0</cloudsphere-angle>
|
||||
</earthview>
|
||||
|
||||
</PropertyList>
|
||||
|
|
Loading…
Reference in a new issue