1
0
Fork 0

Real geometry mapped grain overlay and wetness/rain simulation for ALS model shader, Vinson flightdeck as example

This commit is contained in:
Thorsten Renk 2014-11-08 10:42:42 +02:00
parent 9369073c5a
commit fc85e049c9
2 changed files with 62 additions and 1 deletions

View file

@ -98,6 +98,8 @@ please see Docs/README.model-combined.eff for documentation
<internal-format>normalized</internal-format>
</texture>
<!-- END Grain texture -->
<!-- simulate rain effects -->
<rain-enabled type="int">0</rain-enabled>
<!-- Dirt -->
<dirt-enabled type="int">0</dirt-enabled>
<dirt-multi type="int">0</dirt-multi>
@ -133,6 +135,8 @@ please see Docs/README.model-combined.eff for documentation
<scattering><use>/rendering/scene/scattering</use></scattering>
<terminator><use>/environment/terminator-relative-position-m</use></terminator>
<fogtype><use>/sim/rendering/shaders/skydome</use></fogtype>
<wetness><use>/environment/surface/wetness</use></wetness>
<rnorm><use>/environment/rain-norm</use></rnorm>
<cloudpos1_x><use>/local-weather/cloud-shadows/cloudpos-x[0]</use></cloudpos1_x>
<cloudpos1_y><use>/local-weather/cloud-shadows/cloudpos-y[0]</use></cloudpos1_y>
<cloudpos2_x><use>/local-weather/cloud-shadows/cloudpos-x[1]</use></cloudpos2_x>
@ -427,6 +431,7 @@ please see Docs/README.model-combined.eff for documentation
<fragment-shader n="2">Shaders/cloud-shadowfunc.frag</fragment-shader>
<fragment-shader n="3">Shaders/hazes.frag</fragment-shader>
<fragment-shader n="4">Shaders/secondary_lights.frag</fragment-shader>
<fragment-shader n="5">Shaders/noise.frag</fragment-shader>
</program>
<uniform>
@ -730,6 +735,15 @@ please see Docs/README.model-combined.eff for documentation
</value>
</uniform>
<!-- simulate wetness and rain-->
<uniform>
<name>rain_enabled</name>
<type>int</type>
<value>
<use>rain-enabled</use>
</value>
</uniform>
<!-- set the amount of ambient light correction 0.0 - 1.0 -->
<uniform>
<name>amb_correction</name>
@ -849,6 +863,16 @@ please see Docs/README.model-combined.eff for documentation
<type>float</type>
<value><use>air_pollution</use></value>
</uniform>
<uniform>
<name>rain_norm</name>
<type>float</type>
<value><use>rnorm</use></value>
</uniform>
<uniform>
<name>wetness</name>
<type>float</type>
<value><use>wetness</use></value>
</uniform>
<uniform>
<name>view_pitch_offset</name>
<type>float</type>

View file

@ -35,6 +35,7 @@ uniform int nmap_enabled;
uniform int refl_enabled;
uniform int refl_map;
uniform int grain_texture_enabled;
uniform int rain_enabled;
uniform int cloud_shadow_flag;
uniform int use_searchlight;
uniform int use_landing_light;
@ -54,6 +55,8 @@ uniform float refl_fresnel;
uniform float refl_noise;
uniform float refl_rainbow;
uniform float grain_magnification;
uniform float wetness;
uniform float rain_norm;
uniform float avisibility;
uniform float cloud_self_shading;
@ -68,6 +71,8 @@ uniform float terrain_alt;
uniform float visibility;
uniform float air_pollution;
uniform float osg_SimulationTime;
uniform float landing_light1_offset;
uniform float landing_light2_offset;
@ -85,6 +90,7 @@ uniform vec3 dirt_r_color;
uniform vec3 dirt_g_color;
uniform vec3 dirt_b_color;
float DotNoise2D(in vec2 coord, in float wavelength, in float fractionalMaxDotSize, in float dot_density);
float shadow_func (in float x, in float y, in float noise, in float dist);
float fog_func (in float targ, in float altitude);
float rayleigh_in_func(in float dist, in float air_pollution, in float avisibility, in float eye_alt, in float vertex_alt);
@ -208,11 +214,17 @@ void main (void)
/// END light
/// BEGIN grain overlay
if (grain_texture_enabled > 0)
if (grain_texture_enabled ==1)
{
grainTexel = texture2D(GrainTex, gl_TexCoord[0].st * grain_magnification);
texel.rgb = mix(texel.rgb, grainTexel.rgb, grainTexel.a );
}
else if (grain_texture_enabled == 2)
{
grainTexel = texture2D(GrainTex, rawpos.xy * grain_magnification);
texel.rgb = mix(texel.rgb, grainTexel.rgb, grainTexel.a );
}
/// END grain overlay
///BEGIN bump
@ -344,6 +356,31 @@ void main (void)
//END Dirt
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//begin WETNESS
//////////////////////////////////////////////////////////////////////
if (rain_enabled >0.0)
{
texel.rgb = texel.rgb * (1.0 - 0.6 * wetness);
float rain_factor = 0.0;
if (rain_norm > 0.0)
{
rain_factor += DotNoise2D(rawpos.xy, 0.2 ,0.5, rain_norm) * abs(sin(6.0*osg_SimulationTime));
rain_factor += DotNoise2D(rawpos.xy, 0.3 ,0.4, rain_norm) * abs(sin(6.0*osg_SimulationTime + 2.094));
rain_factor += DotNoise2D(rawpos.xy, 0.4 ,0.3, rain_norm)* abs(sin(6.0*osg_SimulationTime + 4.188));
}
// secondary reflection of sky irradiance in water film
float fresnelW = ((0.8 * wetness) ) * (1.0-smoothstep(0.0,0.4, dot(N,-normalize(vertVec)) * 1.0 - 0.2 * rain_factor * wetness));
float sky_factor = (1.0-ct*ct);
vec3 sky_light = vec3 (1.0,1.0,1.0) * length(light_diffuse.rgb) * (1.0-effective_scattering);
Specular.rgb += sky_factor * fresnelW * sky_light;
}
/////////////////////////////////////////////////////////////////////
//end WETNESS
//////////////////////////////////////////////////////////////////////
// set ambient adjustment to remove bluiness with user input
float ambient_offset = clamp(amb_correction, -1.0, 1.0);