More work on ALS glass and cockpit interior
This commit is contained in:
parent
f4a3977127
commit
1a169d6de3
5 changed files with 60 additions and 17 deletions
|
@ -29,6 +29,7 @@
|
||||||
</images>
|
</images>
|
||||||
</texture>
|
</texture>
|
||||||
<glass-tint type="vec4d" n="0"> 1.0 1.0 1.0 1.0</glass-tint>
|
<glass-tint type="vec4d" n="0"> 1.0 1.0 1.0 1.0</glass-tint>
|
||||||
|
<overlay-color type="vec3d" n="0"> 1.0 1.0 1.0</overlay-color>
|
||||||
<splash-x><use>/environment/aircraft-effects/splash-vector-x</use></splash-x>
|
<splash-x><use>/environment/aircraft-effects/splash-vector-x</use></splash-x>
|
||||||
<splash-y><use>/environment/aircraft-effects/splash-vector-y</use></splash-y>
|
<splash-y><use>/environment/aircraft-effects/splash-vector-y</use></splash-y>
|
||||||
<splash-z><use>/environment/aircraft-effects/splash-vector-z</use></splash-z>
|
<splash-z><use>/environment/aircraft-effects/splash-vector-z</use></splash-z>
|
||||||
|
@ -37,7 +38,10 @@
|
||||||
<frost-level><use>/environment/aircraft-effects/frost-level</use></frost-level>
|
<frost-level><use>/environment/aircraft-effects/frost-level</use></frost-level>
|
||||||
<fog-level><use>/environment/aircraft-effects/fog-level</use></fog-level>
|
<fog-level><use>/environment/aircraft-effects/fog-level</use></fog-level>
|
||||||
<use-wipers><use>/environment/aircraft-effects/use-wipers</use></use-wipers>
|
<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>
|
||||||
<use-reflection type="int">0</use-reflection>
|
<use-reflection type="int">0</use-reflection>
|
||||||
|
<reflection-strength type="float">1.0</reflection-strength>
|
||||||
<use-mask type="int">0</use-mask>
|
<use-mask type="int">0</use-mask>
|
||||||
|
|
||||||
</parameters>
|
</parameters>
|
||||||
|
@ -127,6 +131,11 @@
|
||||||
<type>float-vec4</type>
|
<type>float-vec4</type>
|
||||||
<value><use>glass-tint</use></value>
|
<value><use>glass-tint</use></value>
|
||||||
</uniform>
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>overlay_color</name>
|
||||||
|
<type>float-vec3</type>
|
||||||
|
<value><use>overlay-color</use></value>
|
||||||
|
</uniform>
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>splash_x</name>
|
<name>splash_x</name>
|
||||||
<type>float</type>
|
<type>float</type>
|
||||||
|
@ -207,6 +216,16 @@
|
||||||
<type>float</type>
|
<type>float</type>
|
||||||
<value><use>air_pollution</use></value>
|
<value><use>air_pollution</use></value>
|
||||||
</uniform>
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>reflection_strength</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>reflection-strength</use></value>
|
||||||
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>overlay_alpha</name>
|
||||||
|
<type>float</type>
|
||||||
|
<value><use>overlay-alpha</use></value>
|
||||||
|
</uniform>
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>texture</name>
|
<name>texture</name>
|
||||||
<type>sampler-2d</type>
|
<type>sampler-2d</type>
|
||||||
|
@ -242,6 +261,11 @@
|
||||||
<type>int</type>
|
<type>int</type>
|
||||||
<value><use>use-wipers</use></value>
|
<value><use>use-wipers</use></value>
|
||||||
</uniform>
|
</uniform>
|
||||||
|
<uniform>
|
||||||
|
<name>use_overlay</name>
|
||||||
|
<type>int</type>
|
||||||
|
<value><use>use-overlay</use></value>
|
||||||
|
</uniform>
|
||||||
<uniform>
|
<uniform>
|
||||||
<name>colorMode</name>
|
<name>colorMode</name>
|
||||||
<type>int</type>
|
<type>int</type>
|
||||||
|
|
|
@ -458,6 +458,8 @@
|
||||||
<fog-level type="float" userarchive="n">0.0</fog-level>
|
<fog-level type="float" userarchive="n">0.0</fog-level>
|
||||||
<ground-splash-norm type="float" userarchive="n">0.0</ground-splash-norm>
|
<ground-splash-norm type="float" userarchive="n">0.0</ground-splash-norm>
|
||||||
<use-wipers type="int" userarchive="n">0</use-wipers>
|
<use-wipers type="int" userarchive="n">0</use-wipers>
|
||||||
|
<use-overlay type="int" userarchive="n">0</use-overlay>
|
||||||
|
<overlay-alpha type="float" userarchive="n">1.0</overlay-alpha>
|
||||||
</aircraft-effects>
|
</aircraft-effects>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ varying vec3 refl_vec;
|
||||||
varying vec3 light_diffuse;
|
varying vec3 light_diffuse;
|
||||||
varying float splash_angle;
|
varying float splash_angle;
|
||||||
varying float Mie;
|
varying float Mie;
|
||||||
|
varying float ambient_fraction;
|
||||||
|
|
||||||
uniform sampler2D texture;
|
uniform sampler2D texture;
|
||||||
uniform sampler2D frost_texture;
|
uniform sampler2D frost_texture;
|
||||||
|
@ -14,12 +15,15 @@ uniform sampler2D func_texture;
|
||||||
uniform samplerCube cube_texture;
|
uniform samplerCube cube_texture;
|
||||||
|
|
||||||
uniform vec4 tint;
|
uniform vec4 tint;
|
||||||
|
uniform vec3 overlay_color;
|
||||||
|
|
||||||
|
|
||||||
uniform float rain_norm;
|
uniform float rain_norm;
|
||||||
uniform float ground_splash_norm;
|
uniform float ground_splash_norm;
|
||||||
uniform float frost_level;
|
uniform float frost_level;
|
||||||
uniform float fog_level;
|
uniform float fog_level;
|
||||||
|
uniform float reflection_strength;
|
||||||
|
uniform float overlay_alpha;
|
||||||
uniform float splash_x;
|
uniform float splash_x;
|
||||||
uniform float splash_y;
|
uniform float splash_y;
|
||||||
uniform float splash_z;
|
uniform float splash_z;
|
||||||
|
@ -28,6 +32,7 @@ uniform float osg_SimulationTime;
|
||||||
uniform int use_reflection;
|
uniform int use_reflection;
|
||||||
uniform int use_mask;
|
uniform int use_mask;
|
||||||
uniform int use_wipers;
|
uniform int use_wipers;
|
||||||
|
uniform int use_overlay;
|
||||||
|
|
||||||
float DotNoise2D(in vec2 coord, in float wavelength, in float fractionalMaxDotSize, in float dot_density);
|
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);
|
float DropletNoise2D(in vec2 coord, in float wavelength, in float fractionalMaxDotSize, in float dot_density);
|
||||||
|
@ -45,17 +50,35 @@ texel *=gl_Color;
|
||||||
|
|
||||||
frost_texel = texture2D(frost_texture, vertPos.xy * 7.0);
|
frost_texel = texture2D(frost_texture, vertPos.xy * 7.0);
|
||||||
func_texel = texture2D(func_texture, gl_TexCoord[0].st);
|
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);
|
float noise_003m = Noise2D(vertPos.xy, 0.03);
|
||||||
float noise_0003m = Noise2D(vertPos.xy, 0.003);
|
float noise_0003m = Noise2D(vertPos.xy, 0.003);
|
||||||
|
|
||||||
|
|
||||||
// damage_pattern
|
// environment reflection
|
||||||
|
|
||||||
if (use_mask == 1)
|
vec4 reflection = textureCube(cube_texture, refl_vec);
|
||||||
|
|
||||||
|
if (use_reflection ==1)
|
||||||
{
|
{
|
||||||
texel = mix(texel, vec4(light_diffuse.rgb,1.0), func_texel.b);
|
// to determine whether what we see reflected is currently in light, we make the somewhat drastic
|
||||||
|
// assumption that its normal will be opposite to the glass normal
|
||||||
|
// (which is mostly truish in a normal cockpit)
|
||||||
|
float reflection_shade = ambient_fraction + (1.0-ambient_fraction) * max(0.0, dot (normalize(normal), normalize(gl_LightSource[0].position.xyz)));
|
||||||
|
texel.rgb = mix(texel.rgb, reflection.rgb, reflection_strength * reflection_shade * (1.0-Mie));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// overlay pattern
|
||||||
|
|
||||||
|
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);
|
||||||
|
texel = mix(texel, overlay_texel, func_texel.b * overlay_texel.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -65,8 +88,6 @@ float fth = (1.0-frost_level) * 0.4 + 0.3;
|
||||||
float fbl = 0.2 * frost_level;
|
float fbl = 0.2 * frost_level;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float frost_factor = (fbl + (1.0-fbl)* smoothstep(fth,fth+0.2,noise_003m)) * (4.0 + 4.0* Mie);
|
float frost_factor = (fbl + (1.0-fbl)* smoothstep(fth,fth+0.2,noise_003m)) * (4.0 + 4.0* Mie);
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,12 +158,7 @@ rain_factor = smoothstep(0.1,0.2, rain_factor) * (1.0 - smoothstep(0.4,1.0, rain
|
||||||
vec4 rainColor = vec4 (0.2,0.2, 0.2, 0.6 - 0.3 * smoothstep(1.0,2.0, splash_speed));
|
vec4 rainColor = vec4 (0.2,0.2, 0.2, 0.6 - 0.3 * smoothstep(1.0,2.0, splash_speed));
|
||||||
rainColor.rgb *= length(light_diffuse)/1.73;
|
rainColor.rgb *= length(light_diffuse)/1.73;
|
||||||
|
|
||||||
// environment reflection
|
|
||||||
|
|
||||||
vec4 reflection = textureCube(cube_texture, refl_vec);
|
|
||||||
|
|
||||||
if (use_reflection ==1)
|
|
||||||
{texel.rgb = mix(texel.rgb, reflection.rgb, 0.5);}
|
|
||||||
|
|
||||||
// glass tint
|
// glass tint
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ varying vec3 light_diffuse;
|
||||||
varying vec3 refl_vec;
|
varying vec3 refl_vec;
|
||||||
varying float splash_angle;
|
varying float splash_angle;
|
||||||
varying float Mie;
|
varying float Mie;
|
||||||
|
varying float ambient_fraction;
|
||||||
|
|
||||||
uniform float ground_scattering;
|
uniform float ground_scattering;
|
||||||
uniform float hazeLayerAltitude;
|
uniform float hazeLayerAltitude;
|
||||||
|
@ -107,7 +108,7 @@ splash_angle = dot(gl_Normal, corrected_splash);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ambient_fraction = length(light_ambient.rgb)/length(light_diffuse.rgb +light_ambient.rgb );
|
||||||
|
|
||||||
|
|
||||||
gl_Position = ftransform();
|
gl_Position = ftransform();
|
||||||
|
|
|
@ -121,19 +121,20 @@ void main()
|
||||||
vec4 opacity = textureCube(cube_texture, lookup_vec);
|
vec4 opacity = textureCube(cube_texture, lookup_vec);
|
||||||
|
|
||||||
|
|
||||||
|
vec4 diffuse = diffuse_term;
|
||||||
NdotL = dot(n, lightDir);
|
NdotL = dot(n, lightDir);
|
||||||
//NdotL = dot(n, (gl_ModelViewMatrix * vec4 (light_vec,0.0)).xyz);
|
//NdotL = dot(n, (gl_ModelViewMatrix * vec4 (light_vec,0.0)).xyz);
|
||||||
if (NdotL > 0.0) {
|
if (NdotL > 0.0) {
|
||||||
diffuse_term.rgb += 2.0 * diffuse_term.rgb * (1.0 - opacity.a);
|
|
||||||
color += diffuse_term * NdotL * opacity;
|
diffuse.rgb += 2.0 * diffuse.rgb * (1.0 - opacity.a);
|
||||||
|
color += diffuse * NdotL * opacity;
|
||||||
NdotHV = max(dot(n, halfVector), 0.0);
|
NdotHV = max(dot(n, halfVector), 0.0);
|
||||||
if (gl_FrontMaterial.shininess > 0.0)
|
if (gl_FrontMaterial.shininess > 0.0)
|
||||||
specular.rgb = (gl_FrontMaterial.specular.rgb
|
specular.rgb = (gl_FrontMaterial.specular.rgb
|
||||||
* light_specular.rgb
|
* light_specular.rgb
|
||||||
* pow(NdotHV, gl_FrontMaterial.shininess));
|
* pow(NdotHV, gl_FrontMaterial.shininess));
|
||||||
}
|
}
|
||||||
color.a = diffuse_term.a;
|
color.a = diffuse.a;
|
||||||
// This shouldn't be necessary, but our lighting becomes very
|
// This shouldn't be necessary, but our lighting becomes very
|
||||||
// saturated. Clamping the color before modulating by the texture
|
// saturated. Clamping the color before modulating by the texture
|
||||||
// is closer to what the OpenGL fixed function pipeline does.
|
// is closer to what the OpenGL fixed function pipeline does.
|
||||||
|
@ -148,6 +149,5 @@ void main()
|
||||||
|
|
||||||
|
|
||||||
gl_FragColor = fragColor;
|
gl_FragColor = fragColor;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue