1
0
Fork 0

Improvements to Earthview: enable changing cloud density, fix aurora z-ordering issue, let moonlight give a relief effect to clouds

This commit is contained in:
Thorsten Renk 2018-01-29 09:25:38 +02:00
parent 5334498037
commit d9e55dc2e5
5 changed files with 71 additions and 21 deletions

View file

@ -22,6 +22,7 @@
<use-overlay-textures><use>/earthview/overlay-texture-flag</use></use-overlay-textures> <use-overlay-textures><use>/earthview/overlay-texture-flag</use></use-overlay-textures>
<use-cloud-normals><use>/earthview/cloud-normal-flag</use></use-cloud-normals> <use-cloud-normals><use>/earthview/cloud-normal-flag</use></use-cloud-normals>
<shade-effect><use>/earthview/shade-effect</use></shade-effect> <shade-effect><use>/earthview/shade-effect</use></shade-effect>
<cloudcover-bias><use>/earthview/cloudcover-bias</use></cloudcover-bias>
<sun-angle><use>/sim/time/sun-angle-rad</use></sun-angle> <sun-angle><use>/sim/time/sun-angle-rad</use></sun-angle>
<moonlight><use>/environment/moonlight</use></moonlight> <moonlight><use>/environment/moonlight</use></moonlight>
<air_pollution><use>/environment/air-pollution-norm</use></air_pollution> <air_pollution><use>/environment/air-pollution-norm</use></air_pollution>
@ -96,7 +97,7 @@
</cull-face> </cull-face>
<rendering-hint>transparent</rendering-hint> <rendering-hint>transparent</rendering-hint>
<render-bin> <render-bin>
<bin-number>111</bin-number> <bin-number>110</bin-number>
<bin-name>DepthSortedBin</bin-name> <bin-name>DepthSortedBin</bin-name>
</render-bin> </render-bin>
<texture-unit> <texture-unit>
@ -188,6 +189,11 @@
<use>shade-effect</use> <use>shade-effect</use>
</value> </value>
</uniform> </uniform>
<uniform>
<name>cloudcover_bias</name>
<type>float</type>
<value><use>cloudcover-bias</use></value>
</uniform>
<uniform> <uniform>
<name>air_pollution</name> <name>air_pollution</name>
<type>float</type> <type>float</type>

View file

@ -16,6 +16,7 @@ uniform float moonlight;
uniform float roi_x1; uniform float roi_x1;
uniform float roi_y1; uniform float roi_y1;
uniform float lightning; uniform float lightning;
uniform float cloudcover_bias;
uniform bool use_overlay; uniform bool use_overlay;
uniform bool use_cloud_normals; uniform bool use_cloud_normals;
@ -27,7 +28,6 @@ float Noise2D(in vec2 coord, in float wavelength);
vec3 filter_combined (in vec3 color) ; vec3 filter_combined (in vec3 color) ;
vec3 moonlight_perception (in vec3 light); vec3 moonlight_perception (in vec3 light);
float add_cosines (in float cos1, in float cos2, in float sign) float add_cosines (in float cos1, in float cos2, in float sign)
{ {
@ -86,11 +86,15 @@ void main()
vec3 tangent = normalize(VTangent); vec3 tangent = normalize(VTangent);
vec3 binormal = cross(n, tangent); vec3 binormal = cross(n, tangent);
float NdotL2 = 0.0; float NdotL2 = 1.0;
texel = texture2D(texture, gl_TexCoord[0].st); texel = texture2D(texture, gl_TexCoord[0].st);
ref_texel = texel; ref_texel = texel;
float sign = -1.0;
float ml_fact = 1.0;
if (use_cloud_normals) if (use_cloud_normals)
{ {
vec2 sun2d = vec2 (0.0, 1.0); vec2 sun2d = vec2 (0.0, 1.0);
@ -114,7 +118,6 @@ void main()
// relief shading based on gradient and parallax lookup // relief shading based on gradient and parallax lookup
float slope = shade_effect * (comp_texel.a - ref_texel.a) * texel.a; float slope = shade_effect * (comp_texel.a - ref_texel.a) * texel.a;
float sign = -1.0;
if (slope < 0.0) {sign = 1.0;} if (slope < 0.0) {sign = 1.0;}
vec2 snormal = normalize(vec2 (slope, 1.0)); vec2 snormal = normalize(vec2 (slope, 1.0));
@ -122,11 +125,15 @@ void main()
NdotL2 = dot (snormal, sun2d); NdotL2 = dot (snormal, sun2d);
NdotL = add_cosines(NdotL, NdotL2, sign ); NdotL = add_cosines(NdotL, NdotL2, sign );
ml_fact = 0.5 + 1.0 * add_cosines(0.0, NdotL2, sign);
} }
ref_texel = texel;
texel.a = pow(texel.a,1.0/cloudcover_bias);
texel.a = clamp(texel.a, 0.0, 1.0);
color += diff_term * max(NdotL, 0.15) ; color += diff_term * max(NdotL, 0.15) ;
@ -142,8 +149,7 @@ void main()
vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight; vec3 moonLightColor = vec3 (0.095, 0.095, 0.15) * moonlight;
moonLightColor = moonlight_perception (moonLightColor); moonLightColor = moonlight_perception (moonLightColor);
color.rgb += moonLightColor * ml_fact;
color.rgb += moonLightColor;
color.a = 1.0;//diffuse_term.a; color.a = 1.0;//diffuse_term.a;
color = clamp(color, 0.0, 1.0); color = clamp(color, 0.0, 1.0);
@ -158,14 +164,15 @@ void main()
vec4 noiseTexel = vec4 (1.0,1.0,1.0, 0.5* noise * texel.a); vec4 noiseTexel = vec4 (1.0,1.0,1.0, 0.5* noise * texel.a);
structureTexel = mix(structureTexel, noiseTexel,noiseTexel.a); structureTexel = mix(structureTexel, noiseTexel,noiseTexel.a);
structureTexel = mix(structureTexel, texel, clamp(1.5 * ref_texel.a * (cloudcover_bias - 1.0), 0.0, 1.0));
if (use_overlay) if (use_overlay)
{ {
texel = vec4(structureTexel.rgb, smoothstep(0.0, 0.5,texel.a) * structureTexel.a); texel = vec4(structureTexel.rgb, smoothstep(0.0, 0.5,texel.a) * structureTexel.a);
} //texel.a = pow(texel.a,1.0/cloudcover_bias);
}
texel.a = clamp((1.0 + darkness_fact) * texel.a, 0.0, 1.0); texel.a = clamp((1.0 + darkness_fact) * texel.a, 0.0, 1.0);

View file

@ -24,7 +24,6 @@ float Noise2D(in vec2 coord, in float wavelength);
vec3 filter_combined (in vec3 color) ; vec3 filter_combined (in vec3 color) ;
vec3 moonlight_perception (in vec3 light); vec3 moonlight_perception (in vec3 light);
void main() void main()
{ {
vec3 n; vec3 n;

View file

@ -1349,6 +1349,7 @@ Started September 2000 by David Megginson, david@megginson.com
<earthview> <earthview>
<cloudsphere-flag type="bool" userarchive="y">true</cloudsphere-flag> <cloudsphere-flag type="bool" userarchive="y">true</cloudsphere-flag>
<cloud-shadow-flag type="bool" userarchive="y">true</cloud-shadow-flag> <cloud-shadow-flag type="bool" userarchive="y">true</cloud-shadow-flag>
<cloudcover-bias type="double" userarchive="y">1.0</cloudcover-bias>
<overlay-texture-flag type="bool" userarchive="y">true</overlay-texture-flag> <overlay-texture-flag type="bool" userarchive="y">true</overlay-texture-flag>
<mrd-flag type="bool" userarchive="y">true</mrd-flag> <mrd-flag type="bool" userarchive="y">true</mrd-flag>
<cloudsphere-angle type="double" userarchive="n">0.0</cloudsphere-angle> <cloudsphere-angle type="double" userarchive="n">0.0</cloudsphere-angle>

View file

@ -432,6 +432,43 @@
<property>/environment/air-pollution-norm</property> <property>/environment/air-pollution-norm</property>
</text> </text>
<!-- gap -->
<text>
<label> </label>
</text>
</group>
<group>
<layout>hbox</layout>
<halign>right</halign>
<!-- gap -->
<text>
<label> </label>
</text>
<text>
<label>Cloudcover</label>
</text>
<slider>
<name>cloudcover</name>
<min>0.5</min>
<max>2.0</max>
<property>/earthview/cloudcover-bias</property>
<binding>
<command>dialog-apply</command>
<object-name>cloudcover</object-name>
</binding>
<live>true</live>
</slider>
<text>
<label>12345678</label>
<format>%.1f</format>
<live>true</live>
<property>/earthview/cloudcover-bias</property>
</text>
<!-- gap --> <!-- gap -->
<text> <text>
<label> </label> <label> </label>