1
0
Fork 0

Glare parameter and side window support for glass effect

This commit is contained in:
Thorsten Renk 2015-03-21 08:39:56 +02:00
parent 58e79d8471
commit 62b7946a0a
3 changed files with 43 additions and 9 deletions

View file

@ -36,14 +36,15 @@
<rnorm><use>/environment/rain-norm</use></rnorm>
<gsnorm><use>/environment/aircraft-effects/ground-splash-norm</use></gsnorm>
<frost-level><use>/environment/aircraft-effects/frost-level</use></frost-level>
<surface-mapping-scheme type="int">0</surface-mapping-scheme>
<fog-level><use>/environment/aircraft-effects/fog-level</use></fog-level>
<use-wipers><use>/environment/aircraft-effects/use-wipers</use></use-wipers>
<use-overlay><use>/environment/aircraft-effects/use-overlay</use></use-overlay>
<overlay-alpha><use>/environment/aircraft-effects/overlay-alpha</use></overlay-alpha>
<overlay-glare type="float">0.5</overlay-glare>
<use-reflection type="int">0</use-reflection>
<reflection-strength type="float">1.0</reflection-strength>
<use-mask type="int">0</use-mask>
</parameters>
<technique n="4">
@ -235,6 +236,11 @@
<type>float</type>
<value><use>overlay-alpha</use></value>
</uniform>
<uniform>
<name>overlay_glare</name>
<type>float</type>
<value><use>overlay-glare</use></value>
</uniform>
<uniform>
<name>texture</name>
<type>sampler-2d</type>
@ -275,6 +281,11 @@
<type>int</type>
<value><use>use-overlay</use></value>
</uniform>
<uniform>
<name>adaptive_mapping</name>
<type>int</type>
<value><use>surface-mapping-scheme</use></value>
</uniform>
<uniform>
<name>colorMode</name>
<type>int</type>

View file

@ -1,6 +1,7 @@
// -*-C++-*-
varying vec2 rawPos;
varying vec2 nPos;
varying vec3 vertPos;
varying vec3 normal;
varying vec3 refl_vec;
@ -24,6 +25,7 @@ uniform float frost_level;
uniform float fog_level;
uniform float reflection_strength;
uniform float overlay_alpha;
uniform float overlay_glare;
uniform float splash_x;
uniform float splash_y;
uniform float splash_z;
@ -33,6 +35,7 @@ uniform int use_reflection;
uniform int use_mask;
uniform int use_wipers;
uniform int use_overlay;
uniform int adaptive_mapping;
float DotNoise2D(in vec2 coord, in float wavelength, in float fractionalMaxDotSize, in float dot_density);
float DropletNoise2D(in vec2 coord, in float wavelength, in float fractionalMaxDotSize, in float dot_density);
@ -48,9 +51,15 @@ vec4 func_texel;
texel = texture2D(texture, gl_TexCoord[0].st);
texel *=gl_Color;
frost_texel = texture2D(frost_texture, vertPos.xy * 7.0);
vec2 frost_coords;
if (adaptive_mapping == 1) {frost_coords = gl_TexCoord[0].st * 7.0;}
else if (adaptive_mapping ==2) {frost_coords = nPos * 7.0;}
else {frost_coords = vertPos.xy * 7.0;}
frost_texel = texture2D(frost_texture, frost_coords);
func_texel = texture2D(func_texture, gl_TexCoord[0].st);
//func_texel = texture2D(func_texture, vertPos.xy * 3.0);
float noise_003m = Noise2D(vertPos.xy, 0.03);
@ -76,8 +85,8 @@ if (use_reflection ==1)
if ((use_mask == 1) && (use_overlay==1))
{
vec4 overlay_texel = vec4(overlay_color, overlay_alpha);
overlay_texel.rgb *= light_diffuse.rgb* (1.0 + 1.5*Mie);
overlay_texel.a *=(1.0 + 0.5* Mie);
overlay_texel.rgb *= light_diffuse.rgb* (1.0 + (1.0 + overlay_glare)*Mie);
overlay_texel.a *=(1.0 + overlay_glare* Mie);
texel = mix(texel, overlay_texel, func_texel.b * overlay_texel.a);
}
@ -148,6 +157,7 @@ if (rnorm > 0.0)
float sweep = min(1./splash_speed,1.0);
if ((use_mask ==1)&&(use_wipers==1)) {sweep *= (1.0 - func_texel.g);}
if (adaptive_mapping ==2) {rainPos = nPos;}
rain_factor += DropletNoise2D(rainPos.xy, 0.02 * droplet_size ,0.5, 0.6* rnorm * sweep);
rain_factor += DotNoise2D(rainPos.xy, 0.012 * droplet_size ,0.7, 0.6* rnorm * sweep);
}
@ -186,7 +196,7 @@ fragColor.a = max(outerColor.a, fog_texel.a);
gl_FragColor = clamp(fragColor,0.0,1.0);
//gl_FragColor = func_texel;
//gl_FragColor = vec4(normal,1.0);
}

View file

@ -1,6 +1,7 @@
// -*-C++-*-
varying vec2 rawPos;
varying vec2 nPos;
varying vec3 vertPos;
varying vec3 normal;
varying vec3 light_diffuse;
@ -94,6 +95,12 @@ refl_vec = reflVec_stat;
vec3 splash_vec = vec3 (splash_x, splash_y, splash_z);
vec3 corrected_splash = normalize(splash_vec);
float angle = abs(dot(corrected_splash, gl_Normal));
//corrected_splash = normalize(corrected_splash + 0.4* gl_Normal );
vec3 base_1 = vec3 (-corrected_splash.y, corrected_splash.x, 0.0);
vec3 base_2 = cross (corrected_splash, base_1);
@ -101,13 +108,19 @@ base_1 = normalize(base_1);
base_2 = normalize(base_2);
rawPos = vec2 (dot(gl_Vertex.xyz, base_1), dot(gl_Vertex.xyz, base_2));
base_1 = vec3 (-gl_Normal.y, gl_Normal.x, 0.0);
base_2 = cross(gl_Normal, base_1);
base_1 = normalize(base_1);
base_2 = normalize(base_2);
nPos = vec2 (dot(gl_Vertex.xyz, base_1), dot(gl_Vertex.xyz, base_2));
vertPos = gl_Vertex.xyz;
splash_angle = dot(gl_Normal, corrected_splash);
ambient_fraction = length(light_ambient.rgb)/length(light_diffuse.rgb +light_ambient.rgb );