diff --git a/Effects/planet.eff b/Effects/planet.eff
index a13041aff..37a68c79c 100644
--- a/Effects/planet.eff
+++ b/Effects/planet.eff
@@ -20,6 +20,7 @@
+
6
@@ -133,6 +134,13 @@
+
+ use_clouds
+ bool
+
+
+
+
diff --git a/Nasal/earthview.nas b/Nasal/earthview.nas
index 0b6545626..f1efb4df7 100644
--- a/Nasal/earthview.nas
+++ b/Nasal/earthview.nas
@@ -4,6 +4,10 @@
var start = func() {
+if (earthview_running_flag == 1) {return;}
+
+earthview_running_flag = 1;
+
var lat = getprop("/position/latitude-deg");
var lon = getprop("/position/longitude-deg");
@@ -16,6 +20,7 @@ var stop = func () {
earth_model.node.remove();
cloudsphere_model.node.remove();
setprop("/earthview/control_loop_flag",0);
+earthview_running_flag = 0;
}
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);}
}
-
+var earthview_running_flag = 0;
var ft_to_m = 0.30480;
var m_to_ft = 1.0/ft_to_m;
var earth_model = {};
diff --git a/Shaders/planet-cloudlayer.frag b/Shaders/planet-cloudlayer.frag
index 10f7ea528..b640e0552 100644
--- a/Shaders/planet-cloudlayer.frag
+++ b/Shaders/planet-cloudlayer.frag
@@ -40,6 +40,12 @@ void main()
vec3 light_specular = vec3 (1.0, 1.0, 1.0);
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) {
color += diffuse_term * NdotL ;
NdotHV = max(dot(n, halfVector), 0.0);
diff --git a/Shaders/planet.frag b/Shaders/planet.frag
index ab7e9b42c..92d9c740e 100644
--- a/Shaders/planet.frag
+++ b/Shaders/planet.frag
@@ -9,6 +9,7 @@ varying vec3 ecViewDir;
varying vec3 VTangent;
uniform float visibility;
+uniform bool use_clouds;
uniform sampler2D texture;
uniform sampler2D shadowtex;
@@ -43,15 +44,30 @@ void main()
float xOffset = -0.005 * dot(normalize(lightDir), normalize(VTangent));
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);
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) {
color += diffuse_term * NdotL * (1.0-shadowTexel.a);
NdotHV = max(dot(n, halfVector), 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)
* pow(NdotHV, gl_FrontMaterial.shininess));
}
@@ -60,7 +76,7 @@ void main()
// saturated. Clamping the color before modulating by the texture
// is closer to what the OpenGL fixed function pipeline does.
color = clamp(color, 0.0, 1.0);
- texel = texture2D(texture, gl_TexCoord[0].st);
+
fragColor = color * texel + specular;
//fragColor = fragColor * (1.0 - 0.5 * shadowTexel.a);
//fragColor = mix(fragColor, shadowTexel, shadowTexel.a);
diff --git a/gui/dialogs/earthview.xml b/gui/dialogs/earthview.xml
index b8e74ecc3..c91be553f 100644
--- a/gui/dialogs/earthview.xml
+++ b/gui/dialogs/earthview.xml
@@ -5,11 +5,98 @@
earthview
- 150
- 50
+ vbox
+ 3
+
false
-