1
0
Fork 0

Improvements and bugfixes for orbital rendering

This commit is contained in:
Thorsten Renk 2015-03-29 13:16:19 +03:00
parent 164aefa2c8
commit 59e01f4edc
9 changed files with 99 additions and 17 deletions

View file

@ -6,12 +6,21 @@
<texture n ="0">
<type>white</type>
</texture>
<texture n="1">
<image>Models/Astro/cloud_structure.png</image>
<type>2d</type>
<filter>linear-mipmap-linear</filter>
<wrap-s>repeat</wrap-s>
<wrap-t>repeat</wrap-t>
<internal-format>normalized</internal-format>
</texture>
<vertex-program-two-side type="bool">false</vertex-program-two-side>
<material>
<color-mode-uniform>1</color-mode-uniform>
<!-- DIFFUSE -->
</material>
<visibility><use>/environment/visibility-m</use></visibility>
<use-overlay-textures><use>/earthview/overlay-texture-flag</use></use-overlay-textures>
</parameters>
@ -72,8 +81,6 @@
<!-- The texture unit is always active because the shaders expect
that. -->
<unit>0</unit>
<!-- If there is a texture, the type in the derived effect
will be "2d". -->
<type>
<use>texture[0]/type</use>
</type>
@ -89,11 +96,15 @@
<wrap-t>
<use>texture[0]/wrap-t</use>
</wrap-t>
<!--
<internal-format>
<use>texture[0]/internal-format</use>
</internal-format>
-->
</texture-unit>
<texture-unit>
<unit>1</unit>
<image><use>texture[1]/image</use></image>
<type><use>texture[1]/type</use></type>
<filter><use>texture[1]/filter</use></filter>
<wrap-s><use>texture[1]/wrap-s</use></wrap-s>
<wrap-t><use>texture[1]/wrap-t</use></wrap-t>
<internal-format><use>texture[1]/internal-format</use></internal-format>
</texture-unit>
<!--<vertex-program-two-side>
<use>vertex-program-two-side</use>
@ -108,6 +119,18 @@
<type>sampler-2d</type>
<value type="int">0</value>
</uniform>
<uniform>
<name>structure_texture</name>
<type>sampler-2d</type>
<value type="int">1</value>
</uniform>
<uniform>
<name>use_overlay</name>
<type>bool</type>
<value>
<use>use-overlay-textures</use>
</value>
</uniform>
<uniform>
<name>colorMode</name>
<type>int</type>

View file

@ -14,6 +14,14 @@
<wrap-t>repeat</wrap-t>
<internal-format>normalized</internal-format>
</texture>
<texture n="2">
<image>Textures/Terrain/grain_texture.png</image>
<type>2d</type>
<filter>linear-mipmap-linear</filter>
<wrap-s>repeat</wrap-s>
<wrap-t>repeat</wrap-t>
<internal-format>normalized</internal-format>
</texture>
<vertex-program-two-side type="bool">false</vertex-program-two-side>
<material>
<color-mode-uniform>1</color-mode-uniform>
@ -22,6 +30,7 @@
<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>
<use-overlay-textures><use>/earthview/overlay-texture-flag</use></use-overlay-textures>
</parameters>
<generate>
<tangent type="int">6</tangent>
@ -96,6 +105,15 @@
<wrap-t><use>texture[1]/wrap-t</use></wrap-t>
<internal-format><use>texture[1]/internal-format</use></internal-format>
</texture-unit>
<texture-unit>
<unit>2</unit>
<image><use>texture[2]/image</use></image>
<type><use>texture[2]/type</use></type>
<filter><use>texture[2]/filter</use></filter>
<wrap-s><use>texture[2]/wrap-s</use></wrap-s>
<wrap-t><use>texture[2]/wrap-t</use></wrap-t>
<internal-format><use>texture[2]/internal-format</use></internal-format>
</texture-unit>
<program>
<vertex-shader>Shaders/planet.vert</vertex-shader>
@ -118,6 +136,11 @@
<type>sampler-2d</type>
<value type="int">1</value>
</uniform>
<uniform>
<name>grain_texture</name>
<type>sampler-2d</type>
<value type="int">2</value>
</uniform>
<uniform>
<name>colorMode</name>
<type>int</type>
@ -139,6 +162,13 @@
<use>use-clouds</use>
</value>
</uniform>
<uniform>
<name>use_overlay</name>
<type>bool</type>
<value>
<use>use-overlay-textures</use>
</value>
</uniform>
<uniform>
<name>use_cloud_shadows</name>
<type>bool</type>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,013 KiB

View file

@ -8,9 +8,10 @@ varying vec3 normal;
varying vec3 ecViewDir;
varying vec3 VTangent;
uniform bool use_overlay;
uniform sampler2D texture;
uniform sampler2D structure_texture;
@ -28,6 +29,7 @@ void main()
vec3 halfVector = normalize(normalize(lightDir) + normalize(ecViewDir));
vec4 texel;
vec4 structureTexel;
vec4 fragColor;
vec4 specular = vec4(0.0);
@ -40,6 +42,7 @@ void main()
vec3 light_specular = vec3 (1.0, 1.0, 1.0);
NdotL = dot(n, lightDir);
NdotL = smoothstep(-0.2,0.2,NdotL);
float intensity = length(diffuse_term);
vec4 dawn = intensity * normalize (vec4 (1.0,0.4,0.4,1.0));
@ -60,6 +63,9 @@ void main()
// is closer to what the OpenGL fixed function pipeline does.
color = clamp(color, 0.0, 1.0);
texel = texture2D(texture, gl_TexCoord[0].st);
structureTexel = texture2D(structure_texture, 20.0 * gl_TexCoord[0].st);
if (use_overlay) {texel = vec4(structureTexel.rgb, texel.a * structureTexel.a);}
fragColor = color * texel + specular;
gl_FragColor = fragColor;

View file

@ -11,8 +11,10 @@ varying vec3 VTangent;
uniform float visibility;
uniform bool use_clouds;
uniform bool use_cloud_shadows;
uniform bool use_overlay;
uniform sampler2D texture;
uniform sampler2D shadowtex;
uniform sampler2D grain_texture;
@ -27,10 +29,11 @@ void main()
float NdotL, NdotHV;
vec4 color = gl_Color;
vec3 lightDir = gl_LightSource[0].position.xyz;
//vec3 halfVector = gl_LightSource[0].halfVector.xyz;
vec3 halfVector = normalize(normalize(lightDir) + normalize(ecViewDir));
vec4 texel;
vec4 shadowTexel;
vec4 shadowTexel;
vec4 grainTexel;
vec4 fragColor;
vec4 specular = vec4(0.0);
@ -51,18 +54,27 @@ void main()
{shadowTexel = vec4 (0.0,0.0,0.0,0.0);}
texel = texture2D(texture, gl_TexCoord[0].st);
grainTexel = texture2D(grain_texture, gl_TexCoord[0].st * 40.0);
vec3 light_specular = vec3 (1.0, 1.0, 1.0);
NdotL = dot(n, lightDir);
// due to atmosphere scattering, we should make this harder
NdotL = smoothstep(-0.2,0.2,NdotL);
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 oceanness = smoothstep(0.0, 0.1,length(texel.rgb - vec3 (0.007,0.019, 0.078)));
float specular_enhancement = 4.0 * (1.0 - oceanness);
float specular_enhancement = 4.0 * (1.0 -smoothstep(0.0, 0.1,length(texel.rgb - vec3 (0.007,0.019, 0.078))));
if (use_overlay) {texel.rgb = mix(texel.rgb, grainTexel.rgb, 0.4* grainTexel.a * oceanness);}
if (NdotL > 0.0) {
color += diffuse_term * NdotL * (1.0-shadowTexel.a);
@ -85,7 +97,7 @@ 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 * clamp(NdotL,0.01, 0.99)),0.0,1.0);
vec4 fogColor = vec4 (0.83,0.9,1.0,1.0) * clamp(length(diffuse_term.rgb/1.73 * clamp(NdotL,0.01, 0.99)),0.0,1.0);
//float visibility = 80.0;
float fogFactor = exp(-distance_through_atmosphere/(visibility/1000.0));

View file

@ -49,7 +49,7 @@ void main()
ambient_color = gl_FrontMaterial.ambient;
}
vec4 light_diffuse = vec4 (1.0,1.0,1.0,1.0);
vec4 light_ambient = vec4 (0.05, 0.05, 0.05, 1.0);
vec4 light_ambient = vec4 (0.03, 0.03, 0.03, 1.0);
diffuse_term = diffuse_color * light_diffuse;//gl_LightSource[0].diffuse;
vec4 constant_term = gl_FrontMaterial.emission + ambient_color *

View file

@ -224,7 +224,7 @@ float minLightIntensity = min(0.2,0.16 * lightArg + 0.5);
vec3 minLight = minLightIntensity * vec3 (0.2, 0.3, 0.4);
// this is for the bare Rayleigh and Mie sky, highly altitude dependent
color.rgb = max(color.rgb, minLight.rgb * (1.0- alt/100000.0) * (1.0 - costheta));
color.rgb = max(color.rgb, minLight.rgb * (1.0- min(alt/100000.0,1.0)) * (1.0 - costheta));
// this is for the terrain drawn
terrainHazeColor = max(terrainHazeColor.rgb, minLight.rgb);

View file

@ -85,6 +85,16 @@
<command>dialog-apply</command>
</binding>
</checkbox>
<checkbox>
<row>3</row>
<col>1</col>
<label> Overlay textures</label>
<halign>left</halign>
<property>/earthview/overlay-texture-flag</property>
<binding>
<command>dialog-apply</command>
</binding>
</checkbox>
</group>
</group>

View file

@ -1259,8 +1259,9 @@ Started September 2000 by David Megginson, david@megginson.com
</scenery>
<earthview>
<cloudsphere-flag type="bool" userarchive="y">true</cloudsphere-flag>
<cloud-shadow-flag type="bool" userarchive="y"/>
<mrd-flag type="bool" userarchive="y"/>
<cloud-shadow-flag type="bool" userarchive="y"/>true</cloud-shadow-flag>
<overlay-texture-flag type="bool" userarchive="y">true</overlay-texture-flag>
<mrd-flag type="bool" userarchive="y"/>true</mrd-flag>
<cloudsphere-angle type="double" userarchive="y">0.0</cloudsphere-angle>
</earthview>
</PropertyList>