1
0
Fork 0

Improvements to ALS dirt runway shader effect

This commit is contained in:
Thorsten Renk 2015-10-19 12:25:07 +03:00
parent 723c79b142
commit 9a53f8e331
4 changed files with 207 additions and 23 deletions

View file

@ -19,6 +19,28 @@
<wrap-t>repeat</wrap-t>
<internal-format>normalized</internal-format>
</texture>
<texture n="18">
<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>
<strength_05m>0.5</strength_05m>
<strength_1m>0.5</strength_1m>
<strength_2m>0.0</strength_2m>
<strength_5m>0.0</strength_5m>
<strength_10m>0.0</strength_10m>
<filter_threshold>0.5</filter_threshold>
<filter_transition>0.2</filter_transition>
<relief_strength>1.0</relief_strength>
<bias_center>1</bias_center>
<bias_center_strength>0.3</bias_center_strength>
<size_base>100.0</size_base>
<size_overlay>30.0</size_overlay>
<size_grain>30.0</size_grain>
<grain_strength>1.0</grain_strength>
</parameters>
@ -99,12 +121,12 @@
</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>
<type><use>texture[18]/type</use></type>
<image><use>texture[18]/image</use></image>
<filter><use>texture[18]/filter</use></filter>
<wrap-s><use>texture[18]/wrap-s</use></wrap-s>
<wrap-t><use>texture[18]/wrap-t</use></wrap-t>
<internal-format><use>texture[18]/internal-format</use></internal-format>
</texture-unit>
<texture-unit>
<unit>7</unit>
@ -188,6 +210,71 @@
<type>float</type>
<value> <use>lichen_cover_factor</use></value>
</uniform>
<uniform>
<name>size_base</name>
<type>float</type>
<value> <use>size_base</use></value>
</uniform>
<uniform>
<name>size_overlay</name>
<type>float</type>
<value><use>size_overlay</use></value>
</uniform>
<uniform>
<name>size_grain</name>
<type>float</type>
<value><use>size_grain</use></value>
</uniform>
<uniform>
<name>grain_strength</name>
<type>float</type>
<value><use>grain_strength</use></value>
</uniform>
<uniform>
<name>strength_05m</name>
<type>float</type>
<value> <use>strength_05m</use></value>
</uniform>
<uniform>
<name>strength_1m</name>
<type>float</type>
<value> <use>strength_1m</use></value>
</uniform>
<uniform>
<name>strength_2m</name>
<type>float</type>
<value> <use>strength_2m</use></value>
</uniform>
<uniform>
<name>strength_5m</name>
<type>float</type>
<value> <use>strength_5m</use></value>
</uniform>
<uniform>
<name>strength_10m</name>
<type>float</type>
<value> <use>strength_10m</use></value>
</uniform>
<uniform>
<name>filter_transition</name>
<type>float</type>
<value> <use>filter_transition</use></value>
</uniform>
<uniform>
<name>filter_threshold</name>
<type>float</type>
<value> <use>filter_threshold</use></value>
</uniform>
<uniform>
<name>relief_strength</name>
<type>float</type>
<value> <use>relief_strength</use></value>
</uniform>
<uniform>
<name>bias_center_strength</name>
<type>float</type>
<value><use>bias_center_strength</use></value>
</uniform>
<uniform>
<name>wetness</name>
<type>float</type>
@ -443,6 +530,11 @@
<type>int</type>
<value><use>cloud_shadow_flag</use></value>
</uniform>
<uniform>
<name>bias_center</name>
<type>int</type>
<value><use>bias_center</use></value>
</uniform>
<uniform>
<name>quality_level</name>
<type>int</type>
@ -499,7 +591,7 @@
<value type="int">5</value>
</uniform>
<uniform>
<name>snow_texture</name>
<name>grain_texture</name>
<type>sampler-2d</type>
<value type="int">6</value>
</uniform>

View file

@ -522,15 +522,14 @@
<rolling-friction>0.1</rolling-friction>
<bumpiness>0.1</bumpiness>
<load-resistance>1e30</load-resistance>
<!-- uncomment this to get volumetric grass on airport keep
<wood-coverage>10.0</wood-coverage>
<!-- uncomment this to get volumetric grass on airport keep-->
<!--<wood-coverage>10.0</wood-coverage>
<tree-texture>Trees/grass_blades.png</tree-texture>
<tree-varieties>1</tree-varieties>
<tree-range-m>200.0</tree-range-m>
<tree-height-m>0.3</tree-height-m>
<tree-width-m>1.0</tree-width-m>
-->
<tree-effect>Effects/tree-grass</tree-effect>-->
</material>
<!-- default mixed crop -->

View file

@ -5,8 +5,34 @@
<material>
<name>grass_rwy</name>
<effect>Effects/airfield</effect>
<!--<effect>Effects/airfield</effect>-->
<effect>Effects/dirt-runway</effect>
<texture-set>
<texture>Runway/dirt_rwy.png</texture>
<texture n="16">Terrain/sand_hires_ochre.png</texture>
<texture n="17">Terrain/airport_grass2.png</texture>
</texture-set>
<parameters>
<strength_05m>0.3</strength_05m>
<strength_1m>0.4</strength_1m>
<strength_2m>0.0</strength_2m>
<strength_5m>0.1</strength_5m>
<strength_10m>0.2</strength_10m>
<filter_threshold>0.15</filter_threshold>
<filter_transition>0.1</filter_transition>
<bias_center>1</bias_center>
<bias_center_strength>0.6</bias_center_strength>
<relief_strength>0.35</relief_strength>
<size_base>25.0</size_base>
<size_overlay>30.0</size_overlay>
<size_grain>50.0</size_grain>
<grain_strength>0.8</grain_strength>
</parameters>
<texture-set>
<texture>Runway/grass_rwy.png</texture>
<texture n="16">Terrain/airport_grass2.png</texture>
<texture n="17">Terrain/sand_hires_ochre.png</texture>
</texture-set>
<xsize>75</xsize>
<ysize>75</ysize>
<solid>1</solid>
@ -26,8 +52,29 @@
</material>
<material>
<effect>Effects/dirt-runway</effect>
<name>lakebed_taxiway</name>
<texture>Runway/lakebed_taxiway.png</texture>
<texture-set>
<texture>Runway/lakebed_taxiway.png</texture>
<texture n="16">Terrain/sand_hires.png</texture>
<texture n="17">Terrain/sand1.png</texture>
</texture-set>
<parameters>
<strength_05m>0.0</strength_05m>
<strength_1m>0.4</strength_1m>
<strength_2m>0.3</strength_2m>
<strength_5m>0.2</strength_5m>
<strength_10m>0.1</strength_10m>
<filter_threshold>0.2</filter_threshold>
<filter_transition>0.2</filter_transition>
<bias_center>1</bias_center>
<bias_center_strength>0.6</bias_center_strength>
<relief_strength>0.35</relief_strength>
<size_base>25.0</size_base>
<size_overlay>100.0</size_overlay>
<size_grain>100.0</size_grain>
<grain_strength>0.3</grain_strength>
</parameters>
<rolling-friction>0.04</rolling-friction>
<bumpiness>0.05</bumpiness>
</material>

View file

@ -12,6 +12,7 @@ varying vec3 ecViewdir;
uniform sampler2D texture;
uniform sampler2D NormalTex;
uniform sampler2D mix_texture;
uniform sampler2D grain_texture;
varying float steepness;
@ -27,6 +28,19 @@ uniform float eye_alt;
uniform float snowlevel;
uniform float dust_cover_factor;
uniform float lichen_cover_factor;
uniform float filter_threshold;
uniform float filter_transition;
uniform float size_base;
uniform float size_overlay;
uniform float size_grain;
uniform float strength_05m;
uniform float strength_1m;
uniform float strength_2m;
uniform float strength_5m;
uniform float strength_10m;
uniform float relief_strength;
uniform float grain_strength;
uniform float bias_center_strength;
uniform float wetness;
uniform float fogstructure;
uniform float snow_thickness_factor;
@ -39,6 +53,7 @@ uniform float air_pollution;
uniform int quality_level;
uniform int tquality_level;
uniform int cloud_shadow_flag;
uniform int bias_center;
uniform int use_searchlight;
uniform int use_landing_light;
uniform int use_alt_landing_light;
@ -72,6 +87,7 @@ void main()
{
yprime_alt = diffuse_term.a;
//diffuse_term.a = 1.0;
mie_angle = gl_Color.a;
@ -98,8 +114,8 @@ float ct = dot(vec3(0.0, 0.0, 1.0), relPos)/dist;
vec4 texel;
vec4 snow_texel;
vec4 detail_texel;
vec4 mix_texel;
vec4 grain_texel;
vec4 fragColor;
vec4 specular = vec4(0.0);
float intensity;
@ -115,11 +131,12 @@ float ct = dot(vec3(0.0, 0.0, 1.0), relPos)/dist;
// 2000m: overlay, detail, snow, fog
float noise_01m;
float noise_05m = Noise2D(rawPos.xy, 0.5);
float noise_1m = Noise2D(rawPos.xy, 1.0);
float noise_10m;
float noise_5m;
noise_10m = Noise2D(rawPos.xy, 10.0);
noise_5m = Noise2D(rawPos.xy ,5.0);
float noise_2m = Noise2D(rawPos.xy, 2.0);
float noise_10m = Noise2D(rawPos.xy, 10.0);
float noise_5m = Noise2D(rawPos.xy ,5.0);
float noisegrad_10m;
float noisegrad_5m;
@ -139,9 +156,13 @@ float noise_2000m = Noise2D(rawPos.xy, 2000.0);
// get the texels
texel = texture2D(texture, gl_TexCoord[0].st);
mix_texel = texture2D(mix_texture, gl_TexCoord[0].st * 5.0);
//texel = texture2D(texture, gl_TexCoord[0].st);
//mix_texel = texture2D(mix_texture, gl_TexCoord[0].st * 5.0);
texel = texture2D(texture, rawPos * 1.0/size_base);
mix_texel = texture2D(mix_texture, rawPos * 1.0/size_overlay);
grain_texel = texture2D(grain_texture, rawPos * 1.0/size_grain);
vec4 nmap = texture2D(NormalTex, gl_TexCoord[0].st * 8.0);
//vec4 nmap = texture2D(NormalTex, rawPos * 0.01);
vec3 N = nmap.rgb * 2.0 - 1.0;
float distortion_factor = 1.0;
@ -152,8 +173,33 @@ float noise_2000m = Noise2D(rawPos.xy, 2000.0);
float snow_alpha;
noise_term = smoothstep(0.8,1.0,noise_1m);
texel = mix(texel, mix_texel, noise_term);
//noise_term = smoothstep(overlay_limit ,1.0,noise_1m);
//noise_term = smoothstep(overlay_limit, 1.0, 0.5 * noise_1m + 0.5 * noise_10m);
noise_term = strength_05m * noise_05m;
noise_term += strength_1m * noise_1m;
noise_term += strength_2m * noise_2m;
noise_term += strength_5m * noise_5m;
noise_term += strength_10m * noise_10m;
if (bias_center == 1)
{
float centerness = smoothstep(0.02, 0.1, (0.14 - abs(gl_TexCoord[0].s - 0.14)));
centerness *= smoothstep(0.05, 0.15, gl_TexCoord[0].t);
centerness = 1.0 - centerness;
noise_term *= (1.0 - bias_center_strength) + bias_center_strength * centerness;
noise_term = clamp(noise_term, 0.0, 1.0);
}
float filtered_noise_term = smoothstep(filter_threshold, filter_threshold + filter_transition, noise_term);
texel = mix(texel, mix_texel, filtered_noise_term);
texel.rgb = mix(texel.rgb, grain_texel.rgb, grain_strength * grain_texel.a * (1.0 - noise_term));// * (1.0-smoothstep(2000.0,5000.0, dist)));
//float view_angle = abs(dot(normal, normalize(ecViewdir)));
@ -232,7 +278,7 @@ 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))* (1.0 - water_factor) * relief_strength;
//NdotL = NdotL + 3.0 * N.r + 0.1 * (noise_01m-0.5) ;
}
if (NdotL > 0.0) {