Updates to Earthview
This commit is contained in:
parent
4e13342019
commit
5a2ada9619
6 changed files with 134 additions and 8 deletions
|
@ -20,6 +20,7 @@
|
||||||
<!-- DIFFUSE -->
|
<!-- DIFFUSE -->
|
||||||
</material>
|
</material>
|
||||||
<visibility><use>/environment/visibility-m</use></visibility>
|
<visibility><use>/environment/visibility-m</use></visibility>
|
||||||
|
<use-clouds><use>/earthview/cloudsphere-flag</use></use-clouds>
|
||||||
</parameters>
|
</parameters>
|
||||||
<generate>
|
<generate>
|
||||||
<tangent type="int">6</tangent>
|
<tangent type="int">6</tangent>
|
||||||
|
@ -133,6 +134,13 @@
|
||||||
<use>visibility</use>
|
<use>visibility</use>
|
||||||
</value>
|
</value>
|
||||||
</uniform>
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>use_clouds</name>
|
||||||
|
<type>bool</type>
|
||||||
|
<value>
|
||||||
|
<use>use-clouds</use>
|
||||||
|
</value>
|
||||||
|
</uniform>
|
||||||
</pass>
|
</pass>
|
||||||
</technique>
|
</technique>
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
var start = func() {
|
var start = func() {
|
||||||
|
|
||||||
|
if (earthview_running_flag == 1) {return;}
|
||||||
|
|
||||||
|
earthview_running_flag = 1;
|
||||||
|
|
||||||
var lat = getprop("/position/latitude-deg");
|
var lat = getprop("/position/latitude-deg");
|
||||||
var lon = getprop("/position/longitude-deg");
|
var lon = getprop("/position/longitude-deg");
|
||||||
|
|
||||||
|
@ -16,6 +20,7 @@ var stop = func () {
|
||||||
earth_model.node.remove();
|
earth_model.node.remove();
|
||||||
cloudsphere_model.node.remove();
|
cloudsphere_model.node.remove();
|
||||||
setprop("/earthview/control_loop_flag",0);
|
setprop("/earthview/control_loop_flag",0);
|
||||||
|
earthview_running_flag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var place_earth_model = func(path, lat, lon, alt, heading, pitch, roll) {
|
var place_earth_model = func(path, lat, lon, alt, heading, pitch, roll) {
|
||||||
|
@ -96,7 +101,7 @@ setprop("/earthview/yaw-deg", -lon);
|
||||||
if (getprop("/earthview/control_loop_flag") ==1) {settimer( func {control_loop(); },0);}
|
if (getprop("/earthview/control_loop_flag") ==1) {settimer( func {control_loop(); },0);}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var earthview_running_flag = 0;
|
||||||
var ft_to_m = 0.30480;
|
var ft_to_m = 0.30480;
|
||||||
var m_to_ft = 1.0/ft_to_m;
|
var m_to_ft = 1.0/ft_to_m;
|
||||||
var earth_model = {};
|
var earth_model = {};
|
||||||
|
|
|
@ -40,6 +40,12 @@ void main()
|
||||||
|
|
||||||
vec3 light_specular = vec3 (1.0, 1.0, 1.0);
|
vec3 light_specular = vec3 (1.0, 1.0, 1.0);
|
||||||
NdotL = dot(n, lightDir);
|
NdotL = dot(n, lightDir);
|
||||||
|
|
||||||
|
float intensity = length(diffuse_term);
|
||||||
|
vec4 dawn = intensity * normalize (vec4 (1.0,0.4,0.4,1.0));
|
||||||
|
|
||||||
|
vec4 diff_term = mix(dawn, diffuse_term, smoothstep(0.0, 0.2, NdotL));
|
||||||
|
|
||||||
if (NdotL > 0.0) {
|
if (NdotL > 0.0) {
|
||||||
color += diffuse_term * NdotL ;
|
color += diffuse_term * NdotL ;
|
||||||
NdotHV = max(dot(n, halfVector), 0.0);
|
NdotHV = max(dot(n, halfVector), 0.0);
|
||||||
|
|
|
@ -9,6 +9,7 @@ varying vec3 ecViewDir;
|
||||||
varying vec3 VTangent;
|
varying vec3 VTangent;
|
||||||
|
|
||||||
uniform float visibility;
|
uniform float visibility;
|
||||||
|
uniform bool use_clouds;
|
||||||
uniform sampler2D texture;
|
uniform sampler2D texture;
|
||||||
uniform sampler2D shadowtex;
|
uniform sampler2D shadowtex;
|
||||||
|
|
||||||
|
@ -43,15 +44,30 @@ void main()
|
||||||
float xOffset = -0.005 * dot(normalize(lightDir), normalize(VTangent));
|
float xOffset = -0.005 * dot(normalize(lightDir), normalize(VTangent));
|
||||||
float yOffset = -0.005 * dot(normalize(lightDir), normalize(VBinormal));
|
float yOffset = -0.005 * dot(normalize(lightDir), normalize(VBinormal));
|
||||||
|
|
||||||
shadowTexel = texture2D(shadowtex, vec2(gl_TexCoord[0].s-xOffset, gl_TexCoord[0].t-yOffset));
|
if (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);}
|
||||||
|
|
||||||
|
texel = texture2D(texture, gl_TexCoord[0].st);
|
||||||
|
|
||||||
vec3 light_specular = vec3 (1.0, 1.0, 1.0);
|
vec3 light_specular = vec3 (1.0, 1.0, 1.0);
|
||||||
NdotL = dot(n, lightDir);
|
NdotL = dot(n, lightDir);
|
||||||
|
|
||||||
|
float intensity = length(diffuse_term);
|
||||||
|
vec4 dawn = intensity * normalize (vec4 (1.0,0.4,0.4,1.0));
|
||||||
|
vec4 diff_term = mix(dawn, diffuse_term, smoothstep(0.0, 0.2, NdotL));
|
||||||
|
|
||||||
|
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))));
|
||||||
|
|
||||||
if (NdotL > 0.0) {
|
if (NdotL > 0.0) {
|
||||||
color += diffuse_term * NdotL * (1.0-shadowTexel.a);
|
color += diffuse_term * NdotL * (1.0-shadowTexel.a);
|
||||||
NdotHV = max(dot(n, halfVector), 0.0);
|
NdotHV = max(dot(n, halfVector), 0.0);
|
||||||
if (gl_FrontMaterial.shininess > 0.0)
|
if (gl_FrontMaterial.shininess > 0.0)
|
||||||
specular.rgb = (gl_FrontMaterial.specular.rgb
|
specular.rgb = (gl_FrontMaterial.specular.rgb * specular_enhancement
|
||||||
* light_specular * (1.0-shadowTexel.a)
|
* light_specular * (1.0-shadowTexel.a)
|
||||||
* pow(NdotHV, gl_FrontMaterial.shininess));
|
* pow(NdotHV, gl_FrontMaterial.shininess));
|
||||||
}
|
}
|
||||||
|
@ -60,7 +76,7 @@ void main()
|
||||||
// saturated. Clamping the color before modulating by the texture
|
// saturated. Clamping the color before modulating by the texture
|
||||||
// is closer to what the OpenGL fixed function pipeline does.
|
// is closer to what the OpenGL fixed function pipeline does.
|
||||||
color = clamp(color, 0.0, 1.0);
|
color = clamp(color, 0.0, 1.0);
|
||||||
texel = texture2D(texture, gl_TexCoord[0].st);
|
|
||||||
fragColor = color * texel + specular;
|
fragColor = color * texel + specular;
|
||||||
//fragColor = fragColor * (1.0 - 0.5 * shadowTexel.a);
|
//fragColor = fragColor * (1.0 - 0.5 * shadowTexel.a);
|
||||||
//fragColor = mix(fragColor, shadowTexel, shadowTexel.a);
|
//fragColor = mix(fragColor, shadowTexel, shadowTexel.a);
|
||||||
|
|
|
@ -5,11 +5,98 @@
|
||||||
|
|
||||||
|
|
||||||
<name>earthview</name>
|
<name>earthview</name>
|
||||||
<width>150</width>
|
<layout>vbox</layout>
|
||||||
<height>50</height>
|
<default-padding>3</default-padding>
|
||||||
|
<!--<width>150</width>
|
||||||
|
<height>50</height>-->
|
||||||
<modal>false</modal>
|
<modal>false</modal>
|
||||||
|
|
||||||
<button>
|
<group>
|
||||||
|
<layout>hbox</layout>
|
||||||
|
<default-padding>1</default-padding>
|
||||||
|
|
||||||
|
<empty>
|
||||||
|
<stretch>true</stretch>
|
||||||
|
</empty>
|
||||||
|
|
||||||
|
<text>
|
||||||
|
<label>Earthview Orbital Rendering</label>
|
||||||
|
</text>
|
||||||
|
|
||||||
|
<empty>
|
||||||
|
<stretch>true</stretch>
|
||||||
|
</empty>
|
||||||
|
|
||||||
|
<button>
|
||||||
|
<legend/>
|
||||||
|
<key>Esc</key>
|
||||||
|
<pref-width>16</pref-width>
|
||||||
|
<pref-height>16</pref-height>
|
||||||
|
<border>2</border>
|
||||||
|
<binding>
|
||||||
|
<command>dialog-close</command>
|
||||||
|
</binding>
|
||||||
|
</button>
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<hrule/>
|
||||||
|
|
||||||
|
<group>
|
||||||
|
<layout>table</layout>
|
||||||
|
|
||||||
|
<text>
|
||||||
|
<row>0</row>
|
||||||
|
<col>0</col>
|
||||||
|
<halign>right</halign>
|
||||||
|
<label>Show cloud layer</label>
|
||||||
|
</text>
|
||||||
|
|
||||||
|
<checkbox>
|
||||||
|
<row>0</row>
|
||||||
|
<col>1</col>
|
||||||
|
<halign>left</halign>
|
||||||
|
<property>/earthview/cloudsphere-flag</property>
|
||||||
|
<binding>
|
||||||
|
<command>dialog-apply</command>
|
||||||
|
</binding>
|
||||||
|
</checkbox>
|
||||||
|
|
||||||
|
<button>
|
||||||
|
<row>1</row>
|
||||||
|
<col>0</col>
|
||||||
|
<legend>Start</legend>
|
||||||
|
<equal>true</equal>
|
||||||
|
<binding>
|
||||||
|
<command>nasal</command>
|
||||||
|
<script>earthview.start()</script>
|
||||||
|
</binding>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button>
|
||||||
|
<row>1</row>
|
||||||
|
<col>1</col>
|
||||||
|
<legend>Stop</legend>
|
||||||
|
<equal>true</equal>
|
||||||
|
<binding>
|
||||||
|
<command>nasal</command>
|
||||||
|
<script>earthview.stop()</script>
|
||||||
|
</binding>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button>
|
||||||
|
<row>1</row>
|
||||||
|
<col>2</col>
|
||||||
|
<legend>Cancel</legend>
|
||||||
|
<equal>true</equal>
|
||||||
|
<key>Esc</key>
|
||||||
|
<binding>
|
||||||
|
<command>dialog-close</command>
|
||||||
|
</binding>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
</group>
|
||||||
|
|
||||||
|
<!--<button>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>10</y>
|
<y>10</y>
|
||||||
<legend>Start</legend>
|
<legend>Start</legend>
|
||||||
|
@ -40,6 +127,6 @@
|
||||||
<binding>
|
<binding>
|
||||||
<command>dialog-close</command>
|
<command>dialog-close</command>
|
||||||
</binding>
|
</binding>
|
||||||
</button>
|
</button>-->
|
||||||
|
|
||||||
</PropertyList>
|
</PropertyList>
|
||||||
|
|
|
@ -1324,6 +1324,10 @@ Started September 2000 by David Megginson, david@megginson.com
|
||||||
<events type="string"/>
|
<events type="string"/>
|
||||||
</scenery>
|
</scenery>
|
||||||
|
|
||||||
|
<earthview>
|
||||||
|
<cloudsphere-flag type="bool" userarchive="y">true</cloudsphere-flag>
|
||||||
|
</earthview>
|
||||||
|
|
||||||
</PropertyList>
|
</PropertyList>
|
||||||
|
|
||||||
<!-- end of preferences.xml -->
|
<!-- end of preferences.xml -->
|
||||||
|
|
Loading…
Add table
Reference in a new issue