1
0
Fork 0

Cloud shadows for runway shader effect

This commit is contained in:
Thorsten Renk 2014-03-17 08:49:49 +02:00
parent f4662b65a3
commit 553fd2c171
2 changed files with 214 additions and 85 deletions

View file

@ -60,9 +60,7 @@
<normalmap_dds type="float">0.0</normalmap_dds>
<vertex-program-two-side type="bool">false</vertex-program-two-side>
<cull-face>back</cull-face>
<rnorm>
<use>/environment/rain-norm</use>
</rnorm>
<rnorm><use>/environment/rain-norm</use></rnorm>
<!-- BEGIN fog include -->
<visibility><use>/environment/ground-visibility-m</use></visibility>
@ -122,31 +120,6 @@
</and>
</predicate>
<!--
<pass>
<lighting>true</lighting>
<material>
<ambient><use>material/ambient</use></ambient>
<diffuse><use>material/diffuse</use></diffuse>
<specular><use>material/specular</use></specular>
<emissive><use>material/emissive</use></emissive>
<shininess><use>material/shininess</use></shininess>
<color-mode>ambient-and-diffuse</color-mode>
</material>
<alpha-test><use>transparent</use></alpha-test>
<shade-model>smooth</shade-model>
<cull-face>back</cull-face>
<render-bin>
<bin-number>-1</bin-number>
<bin-name>RenderBin</bin-name>
</render-bin>
<program>
<vertex-shader>Shaders/trivial.vert</vertex-shader>
<fragment-shader>Shaders/trivial.frag</fragment-shader>
</program>
<color-mask type="vec4d">0 0 0 0</color-mask>
</pass>
-->
<pass>
<lighting>true</lighting>
@ -184,36 +157,10 @@
<wrap-t><use>texture[4]/wrap-t</use></wrap-t>
<internal-format><use>texture[4]/internal-format</use></internal-format>
</texture-unit>
<texture-unit>
<unit>5</unit>
<type><use>texture[12]/type</use></type>
<image><use>texture[12]/image</use></image>
<filter><use>texture[12]/filter</use></filter>
<wrap-s><use>texture[12]/wrap-s</use></wrap-s>
<wrap-t><use>texture[12]/wrap-t</use></wrap-t>
<internal-format><use>texture[12]/internal-format</use></internal-format>
</texture-unit>
<texture-unit>
<unit>6</unit>
<type><use>texture[10]/type</use></type>
<image><use>texture[10]/image</use></image>
<filter><use>texture[10]/filter</use></filter>
<wrap-s><use>texture[10]/wrap-s</use></wrap-s>
<wrap-t><use>texture[10]/wrap-t</use></wrap-t>
<internal-format><use>texture[10]/internal-format</use></internal-format>
</texture-unit>
<texture-unit>
<unit>7</unit>
<type><use>texture[11]/type</use></type>
<image><use>texture[11]/image</use></image>
<filter><use>texture[11]/filter</use></filter>
<wrap-s><use>texture[11]/wrap-s</use></wrap-s>
<wrap-t><use>texture[11]/wrap-t</use></wrap-t>
<internal-format><use>texture[11]/internal-format</use></internal-format>
</texture-unit>
<program>
<vertex-shader>Shaders/terrain-haze-ultra.vert</vertex-shader>
<fragment-shader>Shaders/runway-lightfield.frag</fragment-shader>
<fragment-shader>Shaders/cloud-shadowfunc.frag</fragment-shader>
</program>
<uniform>
<name>visibility</name>
@ -300,6 +247,211 @@
<type>float</type>
<value><use>moonlight</use></value>
</uniform>
<uniform>
<name>cloudpos1_x</name>
<type>float</type>
<value><use>cloudpos1_x</use></value>
</uniform>
<uniform>
<name>cloudpos1_y</name>
<type>float</type>
<value><use>cloudpos1_y</use></value>
</uniform>
<uniform>
<name>cloudpos2_x</name>
<type>float</type>
<value><use>cloudpos2_x</use></value>
</uniform>
<uniform>
<name>cloudpos2_y</name>
<type>float</type>
<value><use>cloudpos2_y</use></value>
</uniform>
<uniform>
<name>cloudpos3_x</name>
<type>float</type>
<value><use>cloudpos3_x</use></value>
</uniform>
<uniform>
<name>cloudpos3_y</name>
<type>float</type>
<value><use>cloudpos3_y</use></value>
</uniform>
<uniform>
<name>cloudpos4_x</name>
<type>float</type>
<value><use>cloudpos4_x</use></value>
</uniform>
<uniform>
<name>cloudpos4_y</name>
<type>float</type>
<value><use>cloudpos4_y</use></value>
</uniform>
<uniform>
<name>cloudpos5_x</name>
<type>float</type>
<value><use>cloudpos5_x</use></value>
</uniform>
<uniform>
<name>cloudpos5_y</name>
<type>float</type>
<value><use>cloudpos5_y</use></value>
</uniform>
<uniform>
<name>cloudpos6_x</name>
<type>float</type>
<value><use>cloudpos6_x</use></value>
</uniform>
<uniform>
<name>cloudpos6_y</name>
<type>float</type>
<value><use>cloudpos6_y</use></value>
</uniform>
<uniform>
<name>cloudpos7_x</name>
<type>float</type>
<value><use>cloudpos7_x</use></value>
</uniform>
<uniform>
<name>cloudpos7_y</name>
<type>float</type>
<value><use>cloudpos7_y</use></value>
</uniform>
<uniform>
<name>cloudpos8_x</name>
<type>float</type>
<value><use>cloudpos8_x</use></value>
</uniform>
<uniform>
<name>cloudpos8_y</name>
<type>float</type>
<value><use>cloudpos8_y</use></value>
</uniform>
<uniform>
<name>cloudpos9_x</name>
<type>float</type>
<value><use>cloudpos9_x</use></value>
</uniform>
<uniform>
<name>cloudpos9_y</name>
<type>float</type>
<value><use>cloudpos9_y</use></value>
</uniform>
<uniform>
<name>cloudpos10_x</name>
<type>float</type>
<value><use>cloudpos10_x</use></value>
</uniform>
<uniform>
<name>cloudpos10_y</name>
<type>float</type>
<value><use>cloudpos10_y</use></value>
</uniform>
<uniform>
<name>cloudpos11_x</name>
<type>float</type>
<value><use>cloudpos11_x</use></value>
</uniform>
<uniform>
<name>cloudpos11_y</name>
<type>float</type>
<value><use>cloudpos11_y</use></value>
</uniform>
<uniform>
<name>cloudpos12_x</name>
<type>float</type>
<value><use>cloudpos12_x</use></value>
</uniform>
<uniform>
<name>cloudpos12_y</name>
<type>float</type>
<value><use>cloudpos12_y</use></value>
</uniform>
<uniform>
<name>cloudpos13_x</name>
<type>float</type>
<value><use>cloudpos13_x</use></value>
</uniform>
<uniform>
<name>cloudpos13_y</name>
<type>float</type>
<value><use>cloudpos13_y</use></value>
</uniform>
<uniform>
<name>cloudpos14_x</name>
<type>float</type>
<value><use>cloudpos14_x</use></value>
</uniform>
<uniform>
<name>cloudpos14_y</name>
<type>float</type>
<value><use>cloudpos14_y</use></value>
</uniform>
<uniform>
<name>cloudpos15_x</name>
<type>float</type>
<value><use>cloudpos15_x</use></value>
</uniform>
<uniform>
<name>cloudpos15_y</name>
<type>float</type>
<value><use>cloudpos15_y</use></value>
</uniform>
<uniform>
<name>cloudpos16_x</name>
<type>float</type>
<value><use>cloudpos16_x</use></value>
</uniform>
<uniform>
<name>cloudpos16_y</name>
<type>float</type>
<value><use>cloudpos16_y</use></value>
</uniform>
<uniform>
<name>cloudpos17_x</name>
<type>float</type>
<value><use>cloudpos17_x</use></value>
</uniform>
<uniform>
<name>cloudpos17_y</name>
<type>float</type>
<value><use>cloudpos17_y</use></value>
</uniform>
<uniform>
<name>cloudpos18_x</name>
<type>float</type>
<value><use>cloudpos18_x</use></value>
</uniform>
<uniform>
<name>cloudpos18_y</name>
<type>float</type>
<value><use>cloudpos18_y</use></value>
</uniform>
<uniform>
<name>cloudpos19_x</name>
<type>float</type>
<value><use>cloudpos19_x</use></value>
</uniform>
<uniform>
<name>cloudpos19_y</name>
<type>float</type>
<value><use>cloudpos19_y</use></value>
</uniform>
<uniform>
<name>cloudpos20_x</name>
<type>float</type>
<value><use>cloudpos20_x</use></value>
</uniform>
<uniform>
<name>cloudpos20_y</name>
<type>float</type>
<value><use>cloudpos20_y</use></value>
</uniform>
<uniform>
<name>cloud_shadow_flag</name>
<type>int</type>
<value><use>cloud_shadow_flag</use></value>
</uniform>
<uniform>
<name>quality_level</name>
<type>int</type>
@ -320,21 +472,6 @@
<type>sampler-2d</type>
<value type="int">4</value>
</uniform>
<uniform>
<name>mix_texture</name>
<type>sampler-2d</type>
<value type="int">5</value>
</uniform>
<uniform>
<name>snow_texture</name>
<type>sampler-2d</type>
<value type="int">6</value>
</uniform>
<uniform>
<name>detail_texture</name>
<type>sampler-2d</type>
<value type="int">7</value>
</uniform>
<uniform>
<name>colorMode</name>
<type>int</type>

View file

@ -4,7 +4,6 @@
// Ambient term comes in gl_Color.rgb.
varying vec4 diffuse_term;
varying vec3 normal;
//varying vec2 nvec;
varying vec3 relPos;
varying vec2 rawPos;
varying vec3 ecViewdir;
@ -12,13 +11,7 @@ varying vec3 ecViewdir;
uniform sampler2D texture;
uniform sampler2D NormalTex;
//uniform sampler3D NoiseTex;
//uniform sampler2D snow_texture;
//uniform sampler2D detail_texture;
//uniform sampler2D mix_texture;
//varying float yprime_alt;
//varying float mie_angle;
varying float steepness;
@ -37,8 +30,10 @@ uniform float wetness;
uniform float fogstructure;
uniform float snow_thickness_factor;
uniform float cloud_self_shading;
uniform int quality_level;
uniform int tquality_level;
uniform int cloud_shadow_flag;
const float EarthRadius = 5800000.0;
const float terminator_width = 200000.0;
@ -48,7 +43,7 @@ float eShade;
float yprime_alt;
float mie_angle;
float shadow_func (in float x, in float y, in float noise, in float dist);
float rand2D(in vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
@ -142,7 +137,6 @@ void main()
yprime_alt = diffuse_term.a;
//diffuse_term.a = 1.0;
mie_angle = gl_Color.a;
float effective_scattering = min(scattering, cloud_self_shading);
@ -275,7 +269,6 @@ if ((dist < 5000.0)&& (quality_level > 3) && (wetness>0.0))
{
water_threshold1 = 1.0-0.5* wetness;
water_threshold2 = 1.0 - 0.3 * wetness;
//water_factor = smoothstep(water_threshold1, water_threshold2 , (0.3 * (2.0 * (1.0-noise_10m) + (1.0 -noise_5m)) * (1.0 - smoothstep(2000.0, 5000.0, dist))) - 5.0 * (1.0 -steepness));
water_factor = smoothstep(water_threshold1, water_threshold2 , 0.5 * (noise_5m + (1.0 -noise_1m))) * (1.0 - smoothstep(1000.0, 3000.0, dist));
}
@ -291,8 +284,7 @@ if ((dist < 5000.0)&& (quality_level > 3) && (wetness>0.0))
// If gl_Color.a == 0, this is a back-facing polygon and the
// normal should be reversed.
//n = (2.0 * gl_Color.a - 1.0) * normal;
n = normal;//vec3 (nvec.x, nvec.y, sqrt(1.0 -pow(nvec.x,2.0) - pow(nvec.y,2.0) ));
n = normal;
n = normalize(n);
NdotL = dot(n, lightDir);
@ -300,12 +292,12 @@ if ((dist < 5000.0)&& (quality_level > 3) && (wetness>0.0))
if (quality_level > 4)
{
NdotL = NdotL + (3.0 * N.r + 0.1 * (noise_01m-0.5))* (1.0 - water_factor) ;
//NdotL = NdotL + 3.0 * N.r + 0.1 * (noise_01m-0.5) ;
}
if (NdotL > 0.0) {
if (cloud_shadow_flag == 1)
{NdotL = NdotL * shadow_func(relPos.x, relPos.y, 1.0, dist);}
color += diffuse_term * NdotL;
NdotHV = max(dot(n, halfVector), 0.0);
//if (gl_FrontMaterial.shininess > 0.0)
specular.rgb = ((gl_FrontMaterial.specular.rgb + (water_factor * vec3 (1.0, 1.0, 1.0)))
* light_specular.rgb
* pow(NdotHV, gl_FrontMaterial.shininess + (20.0 * water_factor)));