diff --git a/Effects/glass.eff b/Effects/glass.eff index d4f37995a..86ee48b47 100644 --- a/Effects/glass.eff +++ b/Effects/glass.eff @@ -29,6 +29,7 @@ 1.0 1.0 1.0 1.0 + 1.0 1.0 1.0 /environment/aircraft-effects/splash-vector-x /environment/aircraft-effects/splash-vector-y /environment/aircraft-effects/splash-vector-z @@ -37,7 +38,10 @@ /environment/aircraft-effects/frost-level /environment/aircraft-effects/fog-level /environment/aircraft-effects/use-wipers + /environment/aircraft-effects/use-overlay + /environment/aircraft-effects/overlay-alpha 0 + 1.0 0 @@ -127,6 +131,11 @@ float-vec4 glass-tint + + overlay_color + float-vec3 + overlay-color + splash_x float @@ -207,6 +216,16 @@ float air_pollution + + reflection_strength + float + reflection-strength + + + overlay_alpha + float + overlay-alpha + texture sampler-2d @@ -242,6 +261,11 @@ int use-wipers + + use_overlay + int + use-overlay + colorMode int diff --git a/Environment/environment.xml b/Environment/environment.xml index a69619331..000791e02 100644 --- a/Environment/environment.xml +++ b/Environment/environment.xml @@ -458,6 +458,8 @@ 0.0 0.0 0 + 0 + 1.0 diff --git a/Shaders/glass-ALS.frag b/Shaders/glass-ALS.frag index 483ec1701..ab056f7a1 100644 --- a/Shaders/glass-ALS.frag +++ b/Shaders/glass-ALS.frag @@ -7,6 +7,7 @@ varying vec3 refl_vec; varying vec3 light_diffuse; varying float splash_angle; varying float Mie; +varying float ambient_fraction; uniform sampler2D texture; uniform sampler2D frost_texture; @@ -14,12 +15,15 @@ uniform sampler2D func_texture; uniform samplerCube cube_texture; uniform vec4 tint; +uniform vec3 overlay_color; uniform float rain_norm; uniform float ground_splash_norm; uniform float frost_level; uniform float fog_level; +uniform float reflection_strength; +uniform float overlay_alpha; uniform float splash_x; uniform float splash_y; uniform float splash_z; @@ -28,6 +32,7 @@ uniform float osg_SimulationTime; uniform int use_reflection; uniform int use_mask; uniform int use_wipers; +uniform int use_overlay; 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); @@ -45,17 +50,35 @@ texel *=gl_Color; frost_texel = texture2D(frost_texture, vertPos.xy * 7.0); 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_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 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)); 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 diff --git a/Shaders/glass-ALS.vert b/Shaders/glass-ALS.vert index 4ba636c28..ae6b7b2b8 100644 --- a/Shaders/glass-ALS.vert +++ b/Shaders/glass-ALS.vert @@ -7,6 +7,7 @@ varying vec3 light_diffuse; varying vec3 refl_vec; varying float splash_angle; varying float Mie; +varying float ambient_fraction; uniform float ground_scattering; 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(); diff --git a/Shaders/model-interior-ALS-base.frag b/Shaders/model-interior-ALS-base.frag index 4b5fc9aad..3d510ff1b 100644 --- a/Shaders/model-interior-ALS-base.frag +++ b/Shaders/model-interior-ALS-base.frag @@ -121,19 +121,20 @@ void main() vec4 opacity = textureCube(cube_texture, lookup_vec); - + vec4 diffuse = diffuse_term; 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) { - 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); if (gl_FrontMaterial.shininess > 0.0) specular.rgb = (gl_FrontMaterial.specular.rgb * light_specular.rgb * pow(NdotHV, gl_FrontMaterial.shininess)); } - color.a = diffuse_term.a; + color.a = diffuse.a; // This shouldn't be necessary, but our lighting becomes very // saturated. Clamping the color before modulating by the texture // is closer to what the OpenGL fixed function pipeline does. @@ -148,6 +149,5 @@ void main() gl_FragColor = fragColor; - }