From 4df2af2cef0f35c39bde5d18d2670015a3cdc40c Mon Sep 17 00:00:00 2001 From: Emilian Huminiuc Date: Tue, 14 Feb 2012 18:38:18 +0200 Subject: [PATCH] SHADERS:fix "unified" fog function. Signed-off-by: Emilian Huminiuc --- Effects/bowwave.eff | 4 +- Effects/crop.eff | 5 +- Effects/flutter.eff | 10 ++-- Effects/forest.eff | 2 +- Effects/glacier.eff | 2 +- Effects/herbtundra.eff | 2 +- Effects/landmass.eff | 6 +-- Effects/lightmap.eff | 67 ++++++++++++++++++++++++++- Effects/model-combined.eff | 4 +- Effects/model-default.eff | 2 +- Effects/reflect-bump-spec.eff | 10 ++-- Effects/reflect.eff | 16 +++---- Effects/runway.eff | 8 ++-- Effects/terrain-default.eff | 2 +- Effects/transition.eff | 8 ++-- Effects/urban.eff | 6 +-- Effects/water-inland.eff | 49 +++++++++++++++++++- Effects/water.eff | 6 +-- Shaders/bumpspec.frag | 23 +++++---- Shaders/bumpspec.vert | 6 +-- Shaders/crop.frag | 22 ++++++--- Shaders/default.vert | 8 ++-- Shaders/flutter.vert | 10 ++-- Shaders/forest.vert | 12 ++--- Shaders/include_fog.frag | 9 ++-- Shaders/landmass-g.vert | 8 ++-- Shaders/landmass.vert | 16 +++---- Shaders/light-cone.frag | 8 +++- Shaders/light-cone.vert | 6 +-- Shaders/lightmap.frag | 21 ++++++--- Shaders/lightmap.vert | 6 +-- Shaders/mat-anim.frag | 15 ++++-- Shaders/mat-anim.vert | 9 ++-- Shaders/mode-diffuse.vert | 1 + Shaders/mode-off.vert | 1 + Shaders/model-default.frag | 14 ++++-- Shaders/model-default.vert | 7 +-- Shaders/rain-layer.vert | 2 +- Shaders/reflect-bump-spec.frag | 24 ++++++---- Shaders/reflect-bump-spec.vert | 12 ++--- Shaders/reflect.frag | 24 ++++++---- Shaders/reflect.vert | 4 +- Shaders/runway-reflect-bump-spec.frag | 2 +- Shaders/terrain-default.frag | 18 +++++-- Shaders/transition.frag | 5 +- Shaders/transition.vert | 12 ++--- Shaders/tree.vert | 16 +++---- Shaders/ubershader.vert | 6 +-- Shaders/urban.vert | 10 ++-- Shaders/wake.vert | 10 ++-- Shaders/water-inland.frag | 30 +++++++----- Shaders/water-orig.frag | 35 ++++++++------ Shaders/water.frag | 16 +++---- Shaders/water.vert | 8 ++-- Shaders/water_sine.frag | 8 ++-- 55 files changed, 427 insertions(+), 226 deletions(-) diff --git a/Effects/bowwave.eff b/Effects/bowwave.eff index e6abff1b1..3a388555d 100644 --- a/Effects/bowwave.eff +++ b/Effects/bowwave.eff @@ -316,7 +316,7 @@ - Shaders/include_fog.vert + Shaders/wake.vert Shaders/include_fog.frag Shaders/bowwave.frag @@ -445,7 +445,7 @@ sampler-3d 1 - + visibility diff --git a/Effects/crop.eff b/Effects/crop.eff index 2bcce657a..70d81313b 100644 --- a/Effects/crop.eff +++ b/Effects/crop.eff @@ -80,8 +80,9 @@ - Shaders/crop.vert - Shaders/crop.frag + Shaders/crop.vert + Shaders/include_fog.frag + Shaders/crop.frag NoiseTex diff --git a/Effects/flutter.eff b/Effects/flutter.eff index 238f1b41f..5971d5d19 100644 --- a/Effects/flutter.eff +++ b/Effects/flutter.eff @@ -146,10 +146,10 @@ vertex-program-two-side - Shaders/include_fog.vert - Shaders/flutter.vert - Shaders/include_fog.frag - Shaders/default.frag + + Shaders/flutter.vert + Shaders/include_fog.frag + Shaders/default.frag visibility diff --git a/Effects/forest.eff b/Effects/forest.eff index 10d565ee9..f146be789 100644 --- a/Effects/forest.eff +++ b/Effects/forest.eff @@ -148,7 +148,7 @@ - Shaders/include_fog.vert + Shaders/forest.vert Shaders/include_fog.frag Shaders/forest.frag diff --git a/Effects/glacier.eff b/Effects/glacier.eff index 69b856670..2dde50909 100644 --- a/Effects/glacier.eff +++ b/Effects/glacier.eff @@ -149,7 +149,7 @@ - Shaders/include_fog.vert + Shaders/forest.vert Shaders/include_fog.frag Shaders/forest.frag diff --git a/Effects/herbtundra.eff b/Effects/herbtundra.eff index 3003936fd..d4bb20d0b 100644 --- a/Effects/herbtundra.eff +++ b/Effects/herbtundra.eff @@ -149,7 +149,7 @@ - Shaders/include_fog.vert + Shaders/forest.vert Shaders/include_fog.frag Shaders/forest.frag diff --git a/Effects/landmass.eff b/Effects/landmass.eff index 4170f36fc..b4f49161d 100644 --- a/Effects/landmass.eff +++ b/Effects/landmass.eff @@ -110,7 +110,7 @@ - Shaders/include_fog.vert + Shaders/landmass-g.vert Shaders/landmass.geom Shaders/include_fog.frag @@ -140,7 +140,7 @@ 0 0 0 0 - + visibility @@ -185,7 +185,7 @@ - + true diff --git a/Effects/lightmap.eff b/Effects/lightmap.eff index 1e2535394..f62b028f9 100644 --- a/Effects/lightmap.eff +++ b/Effects/lightmap.eff @@ -11,6 +11,26 @@ /sim/rendering/shader/generic 1 + + + /environment/ground-visibility-m + + + /environment/visibility-m + + + /environment/ground-haze-thickness-m + + + /rendering/scene/scattering + + + /environment/terminator-relative-position-m + + + /sim/rendering/shaders/skydome + + @@ -83,7 +103,8 @@ Shaders/lightmap.vert - Shaders/lightmap.frag + Shaders/include_fog.frag + Shaders/lightmap.frag texture @@ -110,6 +131,50 @@ float factor + + + visibility + float + + visibility + + + + avisibility + float + + avisibility + + + + hazeLayerAltitude + float + + lthickness + + + + scattering + float + + scattering + + + + terminator + float + + terminator + + + + fogType + int + + fogtype + + + diff --git a/Effects/model-combined.eff b/Effects/model-combined.eff index 19b761da8..7c67b4fd5 100644 --- a/Effects/model-combined.eff +++ b/Effects/model-combined.eff @@ -366,7 +366,7 @@ please see Docs/README.model-combined.eff for documentation - Shaders/include_fog.vert + Shaders/ubershader.vert Shaders/include_fog.frag Shaders/ubershader.frag @@ -391,7 +391,7 @@ please see Docs/README.model-combined.eff for documentation sampler-3d 1 - + NormalTex sampler-2d diff --git a/Effects/model-default.eff b/Effects/model-default.eff index 33db40101..a332b8245 100644 --- a/Effects/model-default.eff +++ b/Effects/model-default.eff @@ -126,7 +126,7 @@ vertex-program-two-side - Shaders/include_fog.vert + Shaders/default.vert Shaders/include_fog.frag diff --git a/Effects/reflect-bump-spec.eff b/Effects/reflect-bump-spec.eff index be80df370..4ab41666f 100644 --- a/Effects/reflect-bump-spec.eff +++ b/Effects/reflect-bump-spec.eff @@ -215,7 +215,7 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model texture[0]/internal-format - + 1 @@ -314,10 +314,10 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model - Shaders/include_fog.vert - Shaders/reflect-bump-spec.vert - Shaders/include_fog.frag - Shaders/reflect-bump-spec.frag + + Shaders/reflect-bump-spec.vert + Shaders/include_fog.frag + Shaders/reflect-bump-spec.frag tangent 6 diff --git a/Effects/reflect.eff b/Effects/reflect.eff index 108580dcf..1681055dc 100644 --- a/Effects/reflect.eff +++ b/Effects/reflect.eff @@ -17,7 +17,7 @@ To use a reflection map set to 1,and the path to the map texture in - + To use a light map set to 1,and the path to the map texture in @@ -213,7 +213,7 @@ texture[8]/internal-format - + 2 @@ -226,12 +226,12 @@ repeat repeat - + 3 noise - + 5 @@ -288,7 +288,7 @@ - Shaders/include_fog.vert + Shaders/reflect.vert Shaders/include_fog.frag Shaders/reflect.frag @@ -317,7 +317,7 @@ sampler-2d 1 - + Lightmap sampler-2d @@ -329,7 +329,7 @@ sampler-3d 3 - + Environment sampler-cube @@ -402,7 +402,7 @@ reflect_map - + light_map diff --git a/Effects/runway.eff b/Effects/runway.eff index 8e9109f3c..20b474fd8 100644 --- a/Effects/runway.eff +++ b/Effects/runway.eff @@ -123,7 +123,7 @@ texture[1]/internal-format - + 1 @@ -147,7 +147,7 @@ 2 noise - + 4 @@ -230,7 +230,7 @@ - Shaders/include_fog.vert + Shaders/reflect-bump-spec.vert Shaders/include_fog.frag Shaders/runway-reflect-bump-spec.frag @@ -261,7 +261,7 @@ sampler-3d 2 - + NormalTex sampler-2d diff --git a/Effects/terrain-default.eff b/Effects/terrain-default.eff index 223c6e7b0..9f01dfa6d 100644 --- a/Effects/terrain-default.eff +++ b/Effects/terrain-default.eff @@ -123,7 +123,7 @@ - Shaders/include_fog.vert + Shaders/default.vert Shaders/include_fog.frag Shaders/terrain-nocolor.frag diff --git a/Effects/transition.eff b/Effects/transition.eff index 5ee37bfee..bf54a358f 100644 --- a/Effects/transition.eff +++ b/Effects/transition.eff @@ -229,10 +229,10 @@ parameters : - Shaders/include_fog.vert - Shaders/transition.vert - Shaders/include_fog.frag - Shaders/transition.frag + + Shaders/transition.vert + Shaders/include_fog.frag + Shaders/transition.frag diff --git a/Effects/urban.eff b/Effects/urban.eff index 42f8e9a46..ef4defa74 100644 --- a/Effects/urban.eff +++ b/Effects/urban.eff @@ -12,7 +12,7 @@ /sim/rendering/shaders/urban - + /environment/ground-visibility-m @@ -159,7 +159,7 @@ noise - Shaders/include_fog.vert + Shaders/urban.vert Shaders/include_fog.frag Shaders/urban.frag @@ -489,7 +489,7 @@ snow-level - + diff --git a/Effects/water-inland.eff b/Effects/water-inland.eff index 57f266baa..841dc5f41 100644 --- a/Effects/water-inland.eff +++ b/Effects/water-inland.eff @@ -195,10 +195,12 @@ - Shaders/include_fog.vert + Shaders/water.vert + Shaders/include_fog.frag Shaders/water-inland.frag + water_reflection sampler-2d @@ -360,6 +362,7 @@ Shaders/water-orig.vert + Shaders/include_fog.frag Shaders/water-orig.frag @@ -367,6 +370,50 @@ sampler-3d 0 + + + visibility + float + + visibility + + + + avisibility + float + + avisibility + + + + hazeLayerAltitude + float + + lthickness + + + + scattering + float + + scattering + + + + terminator + float + + terminator + + + + fogType + int + + fogtype + + + diff --git a/Effects/water.eff b/Effects/water.eff index 096033faf..ec71fe839 100644 --- a/Effects/water.eff +++ b/Effects/water.eff @@ -292,7 +292,7 @@ - Shaders/include_fog.vert + Shaders/water.vert Shaders/include_fog.frag Shaders/water_sine.frag @@ -449,7 +449,7 @@ - + visibility @@ -658,7 +658,7 @@ - Shaders/include_fog.vert + Shaders/water.vert Shaders/include_fog.frag Shaders/water.frag diff --git a/Shaders/bumpspec.frag b/Shaders/bumpspec.frag index 16f8d161c..74ee2cae3 100644 --- a/Shaders/bumpspec.frag +++ b/Shaders/bumpspec.frag @@ -2,7 +2,7 @@ // Licence: GPL v2 // Author: Frederic Bouvier -varying float fogCoord; +//varying float fogCoord; varying vec3 VNormal; varying vec3 VTangent; @@ -11,7 +11,13 @@ varying vec3 VBinormal; uniform sampler2D tex_color; uniform sampler2D tex_normal; -void main (void) +////fog "include" ///// +uniform int fogType; + +vec3 fog_Func(vec3 color, int type); +////////////////////// + +void main (void) { vec4 ns = texture2D(tex_normal, gl_TexCoord[0].st); vec3 N = ns.rgb * 2.0 - 1.0; @@ -36,11 +42,12 @@ void main (void) color = clamp( color, 0.0, 1.0 ); - float fogFactor; - const float LOG2 = 1.442695; - fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2); - fogFactor = clamp(fogFactor, 0.0, 1.0); +// float fogFactor; +// const float LOG2 = 1.442695; +// fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2); +// fogFactor = clamp(fogFactor, 0.0, 1.0); +// gl_FragColor = mix(gl_Fog.color, color, fogFactor); - - gl_FragColor = mix(gl_Fog.color, color, fogFactor); + color.rgb = fog_Func(fragColor.rgb, fogType); + gl_FragColor = color; } diff --git a/Shaders/bumpspec.vert b/Shaders/bumpspec.vert index d7b7a8974..26ea98173 100644 --- a/Shaders/bumpspec.vert +++ b/Shaders/bumpspec.vert @@ -2,7 +2,7 @@ // Licence: GPL v2 // Author: Frederic Bouvier -varying float fogCoord; +//varying float fogCoord; varying vec3 VNormal; varying vec3 VTangent; varying vec3 VBinormal; @@ -12,8 +12,8 @@ attribute vec3 binormal; void main (void) { - vec4 pos = gl_ModelViewMatrix * gl_Vertex; - fogCoord = pos.z / pos.w; +// vec4 pos = gl_ModelViewMatrix * gl_Vertex; +// fogCoord = pos.z / pos.w; VNormal = normalize(gl_NormalMatrix * gl_Normal); VTangent = normalize(gl_NormalMatrix * tangent); diff --git a/Shaders/crop.frag b/Shaders/crop.frag index c3534bc41..fb7a69e3b 100644 --- a/Shaders/crop.frag +++ b/Shaders/crop.frag @@ -18,12 +18,18 @@ const float scale = 1.0; #define BLA 1 #define BLA2 0 +////fog "include" ///// +uniform int fogType; + +vec3 fog_Func(vec3 color, int type); +////////////////////// + void main (void) { vec4 basecolor = texture2D(SampleTex, rawpos.xy*0.000144); basecolor = texture1D(ColorsTex, basecolor.r+0.00); - + vec4 noisevec = texture3D(NoiseTex, (rawpos.xyz)*0.01*scale); vec4 nvL = texture3D(NoiseTex, (rawpos.xyz)*0.00066*scale); @@ -51,10 +57,10 @@ void main (void) // good vec4 c1; c1 = basecolor * vec4(smoothstep(0.0, 1.15, n), smoothstep(0.0, 1.2, n), smoothstep(0.1, 1.3, n), 1.0); - + //"steep = gray" c1 = mix(vec4(n-0.42, n-0.44, n-0.51, 1.0), c1, smoothstep(0.970, 0.990, abs(normalize(Normal).z)+nvL[2]*1.3)); - + //"snow" c1 = mix(c1, clamp(n+nvL[2]*4.1+vec4(0.1, 0.1, nvL[2]*2.2, 1.0), 0.7, 1.0), smoothstep(snowlevel+300.0, snowlevel+360.0, (rawpos.z)+nvL[1]*3000.0)); @@ -64,8 +70,10 @@ void main (void) c1 *= ambient_light; vec4 finalColor = c1; - if(gl_Fog.density == 1.0) - fogFactor=1.0; - - gl_FragColor = mix(gl_Fog.color ,finalColor, fogFactor); +// if(gl_Fog.density == 1.0) +// fogFactor=1.0; +// +// gl_FragColor = mix(gl_Fog.color ,finalColor, fogFactor); + finalColor.rgb = fog_Func(finalColor.rgb, fogType); + gl_FragColor = finalColor; } diff --git a/Shaders/default.vert b/Shaders/default.vert index c3bdf00a6..1bc240585 100644 --- a/Shaders/default.vert +++ b/Shaders/default.vert @@ -22,9 +22,9 @@ varying vec3 normal; uniform int colorMode; ////fog "include"//////// -uniform int fogType; - -void fog_Func(int type); +//uniform int fogType; +// +//void fog_Func(int type); ///////////////////////// void main() @@ -57,5 +57,5 @@ void main() gl_FrontColor.rgb = constant_term.rgb; gl_FrontColor.a = 1.0; gl_BackColor.rgb = constant_term.rgb; gl_BackColor.a = 0.0; //fogCoord = abs(ecPosition.z / ecPosition.w); - fog_Func(fogType); + //fog_Func(fogType); } diff --git a/Shaders/flutter.vert b/Shaders/flutter.vert index 7aaf41300..4af662855 100644 --- a/Shaders/flutter.vert +++ b/Shaders/flutter.vert @@ -30,9 +30,9 @@ uniform float Offset, AmpFactor, WindE, WindN, spd, hdg; uniform sampler3D Noise; ////fog "include"//////// -uniform int fogType; - -void fog_Func(int type); +//uniform int fogType; +// +//void fog_Func(int type); ///////////////////////// /////// functions ///////// @@ -56,7 +56,7 @@ void relWind(out float rel_wind_speed_kts, out float rel_wind_from_rad) float rel_wind_speed_from_north_kts = WindN*fps2kts + speed_north_kts; //combine relative speeds north and east to get relative windspeed in kts - rel_wind_speed_kts = sqrt(pow(abs(rel_wind_speed_from_east_kts), 2) + rel_wind_speed_kts = sqrt(pow(abs(rel_wind_speed_from_east_kts), 2) + pow(abs(rel_wind_speed_from_north_kts), 2)); //calculate the relative wind direction @@ -138,6 +138,6 @@ void main() gl_BackColor.rgb = ambient_term.rgb; gl_FrontColor.a = 1.0; // fogCoord = abs(ecPosition.z / ecPosition.w); - fog_Func(fogType); + //fog_Func(fogType); } diff --git a/Shaders/forest.vert b/Shaders/forest.vert index c0a0d6f25..226ebb141 100644 --- a/Shaders/forest.vert +++ b/Shaders/forest.vert @@ -10,11 +10,11 @@ varying vec4 constantColor; attribute vec3 tangent; attribute vec3 binormal; -////fog "include"//////// -uniform int fogType; - -void fog_Func(int type); -///////////////////////// +// ////fog "include"//////// +// uniform int fogType; +// +// void fog_Func(int type); +// ///////////////////////// void main(void) { @@ -30,5 +30,5 @@ void main(void) + gl_FrontColor * (gl_LightModel.ambient + gl_LightSource[0].ambient); gl_Position = ftransform(); gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; - fog_Func(fogType); +// fog_Func(fogType); } diff --git a/Shaders/include_fog.frag b/Shaders/include_fog.frag index 58dcd24bd..69dc17257 100644 --- a/Shaders/include_fog.frag +++ b/Shaders/include_fog.frag @@ -1,15 +1,12 @@ //#define fog_FuncTION -//default fog -//varying float fogCoord; -varying vec3 PointPos; -//varying vec4 EyePos; +//varying vec3 PointPos; vec3 fog_Func(vec3 color, int type) { //if (type == 0){ const float LOG2 = 1.442695; - //vec3 EyePos = vec3(0.0); - float fogCoord =length(PointPos); + //float fogCoord =length(PointPos); + float fogCoord = gl_FragCoord.z / gl_FragCoord.w; float fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2); if(gl_Fog.density == 1.0) diff --git a/Shaders/landmass-g.vert b/Shaders/landmass-g.vert index 9a00317ef..199134a37 100644 --- a/Shaders/landmass-g.vert +++ b/Shaders/landmass-g.vert @@ -32,9 +32,9 @@ attribute vec3 binormal; uniform float canopy_height; ////fog "include"//////// -uniform int fogType; - -void fog_Func(int type); +// uniform int fogType; +// +// void fog_Func(int type); ///////////////////////// void main(void) @@ -55,5 +55,5 @@ void main(void) constantColorIn = gl_FrontMaterial.emission + gl_Color * (gl_LightModel.ambient + gl_LightSource[0].ambient); - fog_Func(fogType); +// fog_Func(fogType); } diff --git a/Shaders/landmass.vert b/Shaders/landmass.vert index 0fade1bec..f279dfcc8 100644 --- a/Shaders/landmass.vert +++ b/Shaders/landmass.vert @@ -9,12 +9,12 @@ varying vec4 constantColor; attribute vec3 tangent; attribute vec3 binormal; -////fog "include" ///// -uniform int fogType; - -void fog_Func(int type); - -////////////////////// +// ////fog "include" ///// +// uniform int fogType; +// +// void fog_Func(int type); +// +// ////////////////////// void main(void) { @@ -27,9 +27,9 @@ void main(void) gl_FrontColor = gl_Color; constantColor = gl_FrontMaterial.emission - + gl_FrontColor * (gl_LightModel.ambient + gl_LightSource[0].ambient); + + gl_FrontColor * (gl_LightModel.ambient + gl_LightSource[0].ambient); gl_Position = ftransform(); gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; - fog_Func(fogType); +// fog_Func(fogType); } diff --git a/Shaders/light-cone.frag b/Shaders/light-cone.frag index ef2b5f918..dcffce836 100644 --- a/Shaders/light-cone.frag +++ b/Shaders/light-cone.frag @@ -1,4 +1,10 @@ -varying float fogCoord; +#version 120 +//varying float fogCoord; +////fog "include" ///// +uniform int fogType; + +vec3 fog_Func(vec3 color, int type); +////////////////////// void main() { diff --git a/Shaders/light-cone.vert b/Shaders/light-cone.vert index 1102eaa22..fc6df0ca8 100644 --- a/Shaders/light-cone.vert +++ b/Shaders/light-cone.vert @@ -1,9 +1,9 @@ -varying float fogCoord; +// varying float fogCoord; void main() { - vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex); +// vec3 ecPosition = vec3(gl_ModelViewMatrix * gl_Vertex); gl_Position = ftransform(); - fogCoord = abs(ecPosition.z); +// fogCoord = abs(ecPosition.z); } diff --git a/Shaders/lightmap.frag b/Shaders/lightmap.frag index 3e9975a09..cb9240551 100644 --- a/Shaders/lightmap.frag +++ b/Shaders/lightmap.frag @@ -2,12 +2,12 @@ // Ambient term comes in gl_Color.rgb. // -// See http://wiki.flightgear.org/index.php/Howto:_Lightmap for details on +// See http://wiki.flightgear.org/index.php/Howto:_Lightmap for details on // how to use it. varying vec4 diffuse_term; varying vec3 normal; -varying float fogCoord; +//varying float fogCoord; uniform sampler2D texture; @@ -16,6 +16,13 @@ uniform float condition; uniform float lightmap_factor; uniform sampler2D lightmap_texture; +////fog "include" ///// +uniform int fogType; + +vec3 fog_Func(vec3 color, int type); +////////////////////// + + float luminance(vec3 color) { return dot(vec3(0.212671, 0.715160, 0.072169), color); @@ -53,13 +60,15 @@ void main() color = clamp(color, 0.0, 1.0); texel = texture2D(texture, gl_TexCoord[0].st); fragColor = color * texel + specular; - + // The lightmap function if ( condition >= 1.0 ) { vec3 lightmapTexel = texture2D(lightmap_texture, gl_TexCoord[0].st).rgb * lightmap_factor; fragColor.rgb = max(fragColor.rgb, lightmapTexel * gl_FrontMaterial.diffuse.rgb * texel.rgb); } - - fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord); - gl_FragColor = mix(gl_Fog.color, fragColor, fogFactor); + + // fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord); + // gl_FragColor = mix(gl_Fog.color, fragColor, fogFactor); + fragColor.rgb = fog_Func(fragColor.rgb, fogType); + gl_FragColor = fragColor; } \ No newline at end of file diff --git a/Shaders/lightmap.vert b/Shaders/lightmap.vert index 19f1ddc2d..5249721e1 100644 --- a/Shaders/lightmap.vert +++ b/Shaders/lightmap.vert @@ -8,7 +8,7 @@ // Diffuse colors come from the gl_Color, ambient from the material. This is // equivalent to osg::Material::DIFFUSE. // -// See http://wiki.flightgear.org/index.php/Howto:_Lightmap for details on +// See http://wiki.flightgear.org/index.php/Howto:_Lightmap for details on // how to use it. #define MODE_OFF 0 @@ -21,7 +21,7 @@ // bugs with gl_FrontFacing in the fragment shader. varying vec4 diffuse_term; varying vec3 normal; -varying float fogCoord; +//varying float fogCoord; uniform int colorMode; void main() @@ -54,5 +54,5 @@ void main() // gl_FrontFacing in the fragment shader. gl_FrontColor.rgb = constant_term.rgb; gl_FrontColor.a = 1.0; gl_BackColor.rgb = constant_term.rgb; gl_BackColor.a = 0.0; - fogCoord = abs(ecPosition.z / ecPosition.w); + //fogCoord = abs(ecPosition.z / ecPosition.w); } diff --git a/Shaders/mat-anim.frag b/Shaders/mat-anim.frag index a52daeec6..bde045d44 100644 --- a/Shaders/mat-anim.frag +++ b/Shaders/mat-anim.frag @@ -3,10 +3,17 @@ // Shader for use with material animations varying vec4 diffuse, constantColor, matSpecular; varying vec3 normal; -varying float fogCoord, alpha; +//varying float fogCoord, alpha; +varying float alpha; uniform sampler2D texture; +////fog "include" ///// +uniform int fogType; + +vec3 fog_Func(vec3 color, int type); +////////////////////// + void main() { vec3 n, halfV; @@ -37,6 +44,8 @@ void main() color = clamp(color, 0.0, 1.0); texel = texture2D(texture, gl_TexCoord[0].st); fragColor = color * texel + specular; - fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord); - gl_FragColor = mix(gl_Fog.color, fragColor, fogFactor); + //fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord); + //gl_FragColor = mix(gl_Fog.color, fragColor, fogFactor); + fragColor.rgb = fog_Func(fragColor.rgb, fogType); + gl_FragColor = fragColor; } diff --git a/Shaders/mat-anim.vert b/Shaders/mat-anim.vert index 3a3667d38..4098c3636 100644 --- a/Shaders/mat-anim.vert +++ b/Shaders/mat-anim.vert @@ -14,12 +14,13 @@ vec4 emissionColor(); varying vec4 diffuse, constantColor, matSpecular; varying vec3 normal; -varying float alpha, fogCoord; +//varying float alpha, fogCoord; +varying float alpha; void main() { - vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex; - vec3 ecPosition3 = vec3(gl_ModelViewMatrix * gl_Vertex) / ecPosition.w; + //vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex; + //vec3 ecPosition3 = vec3(gl_ModelViewMatrix * gl_Vertex) / ecPosition.w; gl_Position = ftransform(); gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; normal = gl_NormalMatrix * gl_Normal; @@ -32,6 +33,6 @@ void main() alpha = diffuse.a; constantColor = emissionColor() + ambientColor() * (gl_LightModel.ambient + gl_LightSource[0].ambient); - fogCoord = abs(ecPosition3.z); + //fogCoord = abs(ecPosition3.z); matSpecular = specularColor(); } diff --git a/Shaders/mode-diffuse.vert b/Shaders/mode-diffuse.vert index f972f6ebd..ed975a107 100644 --- a/Shaders/mode-diffuse.vert +++ b/Shaders/mode-diffuse.vert @@ -1,4 +1,5 @@ // -*-C++-*- +#version 120 vec4 ambientColor() { diff --git a/Shaders/mode-off.vert b/Shaders/mode-off.vert index 65429c5dd..82f99de09 100644 --- a/Shaders/mode-off.vert +++ b/Shaders/mode-off.vert @@ -1,4 +1,5 @@ // -*-C++-*- +#version 120 vec4 ambientColor() { diff --git a/Shaders/model-default.frag b/Shaders/model-default.frag index 2c94b92d0..6e53401b2 100644 --- a/Shaders/model-default.frag +++ b/Shaders/model-default.frag @@ -3,10 +3,16 @@ // Ambient term comes in gl_Color.rgb. varying vec4 diffuse_term; varying vec3 normal; -varying float fogCoord; +//varying float fogCoord; uniform sampler2D texture; +////fog "include" ///// +uniform int fogType; + +vec3 fog_Func(vec3 color, int type); +////////////////////// + float luminance(vec3 color) { return dot(vec3(0.212671, 0.715160, 0.072169), color); @@ -43,6 +49,8 @@ void main() color = clamp(color, 0.0, 1.0); texel = texture2D(texture, gl_TexCoord[0].st); fragColor = color * texel + specular; - fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord); - gl_FragColor = mix(gl_Fog.color, fragColor, fogFactor); + //fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord); + //gl_FragColor = mix(gl_Fog.color, fragColor, fogFactor); + fragColor.rgb = fog_Func(fragColor.rgb, fogType); + gl_FragColor = fragColor; } diff --git a/Shaders/model-default.vert b/Shaders/model-default.vert index 0202419e9..591b7e507 100644 --- a/Shaders/model-default.vert +++ b/Shaders/model-default.vert @@ -7,6 +7,7 @@ // // Diffuse colors come from the gl_Color, ambient from the material. This is // equivalent to osg::Material::DIFFUSE. +#version 120 #define MODE_OFF 0 #define MODE_DIFFUSE 1 @@ -18,13 +19,13 @@ // bugs with gl_FrontFacing in the fragment shader. varying vec4 diffuse_term; varying vec3 normal; -varying float fogCoord; +//varying float fogCoord; uniform int colorMode; void main() { - vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex; + //vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex; gl_Position = ftransform(); gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; normal = gl_NormalMatrix * gl_Normal; @@ -51,5 +52,5 @@ void main() // gl_FrontFacing in the fragment shader. gl_FrontColor.rgb = ambient_term.rgb; gl_FrontColor.a = 1.0; gl_BackColor.rgb = ambient_term.rgb; gl_FrontColor.a = 0.0; - fogCoord = abs(ecPosition.z / ecPosition.w); + //fogCoord = abs(ecPosition.z / ecPosition.w); } diff --git a/Shaders/rain-layer.vert b/Shaders/rain-layer.vert index ef72bf493..a0f677297 100644 --- a/Shaders/rain-layer.vert +++ b/Shaders/rain-layer.vert @@ -9,7 +9,7 @@ float shade = 0.8; float cloud_height = 1000.0; void main(void) -{ +{ gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; //gl_TexCoord[0] = gl_MultiTexCoord0 + vec4(textureIndexX, textureIndexY, 0.0, 0.0); diff --git a/Shaders/reflect-bump-spec.frag b/Shaders/reflect-bump-spec.frag index 4dfb052d6..5245f36ff 100644 --- a/Shaders/reflect-bump-spec.frag +++ b/Shaders/reflect-bump-spec.frag @@ -14,7 +14,7 @@ varying vec3 reflVec; varying vec4 Diffuse; varying float alpha; -varying float fogCoord; +//varying float fogCoord; uniform samplerCube Environment; uniform sampler2D Rainbow; @@ -32,6 +32,12 @@ uniform float ambient_correction; uniform float reflect_map; uniform float normalmap_dds; +////fog "include" ///// +uniform int fogType; + +vec3 fog_Func(vec3 color, int type); +////////////////////// + void main (void) { vec3 halfV; @@ -72,12 +78,12 @@ void main (void) color = clamp(color, 0.0, 1.0); // calculate the fog factor - const float LOG2 = 1.442695; - float fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2); - fogFactor = clamp(fogFactor, 0.0, 1.0); - - if(gl_Fog.density == 1.0) - fogFactor=1.0; +// const float LOG2 = 1.442695; +// float fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2); +// fogFactor = clamp(fogFactor, 0.0, 1.0); +// +// if(gl_Fog.density == 1.0) +// fogFactor=1.0; vec3 normal = normalize(VNormal); vec3 viewVec = normalize(vViewVec); @@ -129,5 +135,7 @@ void main (void) reflColor = clamp(reflColor, 0.0, 1.0); - gl_FragColor = mix(gl_Fog.color, reflColor, fogFactor); +// gl_FragColor = mix(gl_Fog.color, reflColor, fogFactor); + reflColor.rgb = fog_Func(reflColor.rgb, fogType); + gl_FragColor = reflColor; } \ No newline at end of file diff --git a/Shaders/reflect-bump-spec.vert b/Shaders/reflect-bump-spec.vert index a24c94d21..abaa415b9 100644 --- a/Shaders/reflect-bump-spec.vert +++ b/Shaders/reflect-bump-spec.vert @@ -19,10 +19,10 @@ uniform mat4 osg_ViewMatrixInverse; attribute vec3 tangent; attribute vec3 binormal; -////fog "include"//////// -uniform int fogType; - -void fog_Func(int type); +////fog "include"//////// +// uniform int fogType; +// +// void fog_Func(int type); ///////////////////////// void main(void) @@ -30,8 +30,8 @@ void main(void) rawpos = gl_Vertex.xyz / gl_Vertex.w; vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex; ecPosition.xyz = ecPosition.xyz / ecPosition.w; - fogCoord = ecPosition.z; - fog_Func(fogType); + //fogCoord = ecPosition.z; + //fog_Func(fogType); vec3 n = normalize(gl_Normal); vec3 t = cross(gl_Normal, vec3(1.0,0.0,0.0)); diff --git a/Shaders/reflect.frag b/Shaders/reflect.frag index 4fe4e0349..5cb6d5f3f 100644 --- a/Shaders/reflect.frag +++ b/Shaders/reflect.frag @@ -13,7 +13,7 @@ varying vec3 reflVec; varying vec4 Diffuse; varying float alpha; -varying float fogCoord; +//varying float fogCoord; uniform samplerCube Environment; uniform sampler2D Rainbow; @@ -33,6 +33,12 @@ uniform float lightmap_factor; uniform int light_map; uniform int reflect_map; +////fog "include" ///// +uniform int fogType; + +vec3 fog_Func(vec3 color, int type); +////////////////////// + void main (void) { vec3 n, halfV; @@ -62,12 +68,12 @@ void main (void) color = clamp(color, 0.0, 1.0); // calculate the fog factor - const float LOG2 = 1.442695; - float fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2); - fogFactor = clamp(fogFactor, 0.0, 1.0); - - if(gl_Fog.density == 1.0) - fogFactor=1.0; +// const float LOG2 = 1.442695; +// float fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2); +// fogFactor = clamp(fogFactor, 0.0, 1.0); +// +// if(gl_Fog.density == 1.0) +// fogFactor=1.0; vec3 normal = normalize(VNormal); vec3 viewVec = normalize(vViewVec); @@ -127,5 +133,7 @@ void main (void) reflColor.rgb = max(reflColor.rgb, lightmapTexel * gl_FrontMaterial.diffuse.rgb * mixedcolor.rgb); } - gl_FragColor = mix(gl_Fog.color, reflColor, fogFactor); +// gl_FragColor = mix(gl_Fog.color, reflColor, fogFactor); + reflColor.rgb = fog_Func(reflColor.rgb, fogType); + gl_FragColor = reflColor; } diff --git a/Shaders/reflect.vert b/Shaders/reflect.vert index 4c8928120..6c8beb6db 100644 --- a/Shaders/reflect.vert +++ b/Shaders/reflect.vert @@ -10,7 +10,7 @@ varying vec3 reflVec; varying vec4 Diffuse; varying float alpha; -varying float fogCoord; +//varying float fogCoord; uniform mat4 osg_ViewMatrixInverse; @@ -37,7 +37,7 @@ void main(void) else alpha = gl_Color.a; - fogCoord = abs(ecPosition.z); + //fogCoord = abs(ecPosition.z); // Vertex in eye coordinates vec3 vertVec = ecPosition.xyz; diff --git a/Shaders/runway-reflect-bump-spec.frag b/Shaders/runway-reflect-bump-spec.frag index 77263b807..8f3c67bf3 100644 --- a/Shaders/runway-reflect-bump-spec.frag +++ b/Shaders/runway-reflect-bump-spec.frag @@ -13,7 +13,7 @@ varying vec3 reflVec; varying vec4 Diffuse; varying float alpha; -varying float fogCoord; +//varying float fogCoord; uniform samplerCube Environment; uniform sampler2D Rainbow; diff --git a/Shaders/terrain-default.frag b/Shaders/terrain-default.frag index f3571459a..128b9e241 100644 --- a/Shaders/terrain-default.frag +++ b/Shaders/terrain-default.frag @@ -1,11 +1,18 @@ // -*-C++-*- - +#version 120 varying vec4 diffuse, constantColor; varying vec3 normal, lightDir, halfVector; -varying float fogCoord, alpha; +//varying float fogCoord, alpha; +varying float alpha; uniform sampler2D texture; +////fog "include" ///// +uniform int fogType; + +vec3 fog_Func(vec3 color, int type); +////////////////////// + float luminance(vec3 color) { return dot(vec3(0.212671, 0.715160, 0.072169), color); @@ -51,7 +58,8 @@ void main() fragColor.a = tex_lum * clamp(lum, 0.01, 1.0); } - fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord); - gl_FragColor = mix(gl_Fog.color, fragColor, fogFactor); - +// fogFactor = exp(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord); +// gl_FragColor = mix(gl_Fog.color, fragColor, fogFactor); + fragColor.rgb = fog_Func(fragColor.rgb, fogType); + gl_FragColor = fragColor; } diff --git a/Shaders/transition.frag b/Shaders/transition.frag index e6df6195e..523813936 100644 --- a/Shaders/transition.frag +++ b/Shaders/transition.frag @@ -8,7 +8,8 @@ varying vec4 diffuse_term, RawPos; varying vec3 Vnormal, normal; //varying float fogCoord; -uniform float SnowLevel, Transitions, InverseSlope, RainNorm, CloudCover0, CloudCover1, CloudCover2, CloudCover3, CloudCover4; +uniform float SnowLevel, Transitions, InverseSlope, RainNorm; +uniform float CloudCover0, CloudCover1, CloudCover2, CloudCover3, CloudCover4; uniform sampler2D BaseTex, SecondTex, ThirdTex, SnowTex; uniform sampler3D NoiseTex; @@ -143,4 +144,4 @@ void main() fragColor.rgb = fog_Func(fragColor.rgb, fogType); //gl_FragColor = mix(gl_Fog.color, fragColor, fogFactor); gl_FragColor = fragColor; - } + } diff --git a/Shaders/transition.vert b/Shaders/transition.vert index 77d526f28..bd9261742 100644 --- a/Shaders/transition.vert +++ b/Shaders/transition.vert @@ -22,11 +22,11 @@ varying vec3 normal, Vnormal; //varying float fogCoord; uniform int colorMode; -////fog "include"//////// -uniform int fogType; - -void fog_Func(int type); -///////////////////////// +// ////fog "include"//////// +// uniform int fogType; +// +// void fog_Func(int type); +// ///////////////////////// void main() { @@ -61,5 +61,5 @@ void main() gl_FrontColor.rgb = constant_term.rgb; gl_FrontColor.a = 1.0; gl_BackColor.rgb = constant_term.rgb; gl_BackColor.a = 0.0; //fogCoord = abs(ecPosition.z / ecPosition.w); - fog_Func(fogType); + //fog_Func(fogType); } diff --git a/Shaders/tree.vert b/Shaders/tree.vert index 51526f655..e12839292 100644 --- a/Shaders/tree.vert +++ b/Shaders/tree.vert @@ -5,13 +5,13 @@ // color - xyz of tree quad origin, replicated 4 times. #version 120 //varying float fogCoord; -varying vec3 PointPos; +// varying vec3 PointPos; //varying vec4 EyePos; -////fog "include"//////// -uniform int fogType; - -void fog_Func(int type); -///////////////////////// +// ////fog "include"//////// +// uniform int fogType; +// +// void fog_Func(int type); +// ///////////////////////// void main(void) { @@ -29,7 +29,7 @@ void main(void) position.xy = vec2(dot(position.xy, vec2(cr, sr)), dot(position.xy, vec2(-sr, cr))); position = position + gl_Color.xyz; gl_Position = gl_ModelViewProjectionMatrix * vec4(position,1.0); - vec3 ecPosition = vec3(gl_ModelViewMatrix * vec4(position, 1.0)); +// vec3 ecPosition = vec3(gl_ModelViewMatrix * vec4(position, 1.0)); float n = dot(normalize(gl_LightSource[0].position.xyz), normalize(-ecPosition)); @@ -41,6 +41,6 @@ void main(void) //fogFactor = exp( -gl_Fog.density * gl_Fog.density * fogCoord * fogCoord); //fogFactor = clamp(fogFactor, 0.0, 1.0); // fog_Func(fogType); - PointPos = ecPosition; +// PointPos = ecPosition; //EyePos = gl_ModelViewMatrixInverse * vec4(0.0,0.0,0.0,1.0); } diff --git a/Shaders/ubershader.vert b/Shaders/ubershader.vert index 8bca33c6d..d35d81abb 100644 --- a/Shaders/ubershader.vert +++ b/Shaders/ubershader.vert @@ -23,8 +23,8 @@ uniform int nmap_enabled; uniform int shader_qual; //////Fog Include/////////// -uniform int fogType; -void fog_Func(int type); +// uniform int fogType; +// void fog_Func(int type); //////////////////////////// void rotationMatrixPR(in float sinRx, in float cosRx, in float sinRy, in float cosRy, out mat4 rotmat) @@ -47,7 +47,7 @@ void main(void) { rawpos = gl_Vertex.xyz; vec4 ecPosition = gl_ModelViewMatrix * gl_Vertex; - fog_Func(fogType); + //fog_Func(fogType); VNormal = normalize(gl_NormalMatrix * gl_Normal); if (nmap_enabled > 0 && shader_qual > 2){ diff --git a/Shaders/urban.vert b/Shaders/urban.vert index 14254eb21..3e23e8ba5 100644 --- a/Shaders/urban.vert +++ b/Shaders/urban.vert @@ -13,9 +13,9 @@ varying vec4 constantColor; attribute vec3 tangent, binormal; ////fog "include"//////// -uniform int fogType; - -void fog_Func(int type); +// uniform int fogType; +// +// void fog_Func(int type); ///////////////////////// void main(void) @@ -28,8 +28,8 @@ void main(void) VBinormal = gl_NormalMatrix * binormal; gl_FrontColor = gl_Color; constantColor = gl_FrontMaterial.emission - + gl_Color * (gl_LightModel.ambient + gl_LightSource[0].ambient); + + gl_Color * (gl_LightModel.ambient + gl_LightSource[0].ambient); gl_Position = ftransform(); gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; - fog_Func(fogType); +// fog_Func(fogType); } diff --git a/Shaders/wake.vert b/Shaders/wake.vert index ee1029506..dbf2e2753 100644 --- a/Shaders/wake.vert +++ b/Shaders/wake.vert @@ -18,9 +18,9 @@ uniform float osg_SimulationTime; uniform float WindE, WindN, spd, hdg; ////fog "include"//////// -uniform int fogType; - -void fog_Func(int type); +// uniform int fogType; +// +// void fog_Func(int type); ///////////////////////// @@ -72,6 +72,6 @@ void main(void) gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; gl_Position = ftransform(); - - fog_Func(fogType); + +// fog_Func(fogType); } \ No newline at end of file diff --git a/Shaders/water-inland.frag b/Shaders/water-inland.frag index 6558b2011..09e12b654 100644 --- a/Shaders/water-inland.frag +++ b/Shaders/water-inland.frag @@ -15,11 +15,17 @@ uniform float CloudCover0, CloudCover1, CloudCover2, CloudCover3, CloudCover4; varying vec4 waterTex1; //moving texcoords varying vec4 waterTex2; //moving texcoords varying vec4 waterTex4; //viewts -varying vec4 ecPosition; +//varying vec4 ecPosition; varying vec3 viewerdir; varying vec3 lightdir; varying vec3 normal; +////fog "include" ///// +uniform int fogType; + +vec3 fog_Func(vec3 color, int type); +////////////////////// + void main(void) { const vec4 sca = vec4(0.005, 0.005, 0.005, 0.005); @@ -96,19 +102,19 @@ void main(void) //calculate fresnel vec4 invfres = vec4( dot(vNorm, viewt) ); - vec4 fres = vec4(1.0) + invfres; + vec4 fres = vec4(1.0) + invfres; refl *= fres; //calculate the fog factor - float fogFactor; - float fogCoord = ecPosition.z; - const float LOG2 = 1.442695; - fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2); +// float fogFactor; +// float fogCoord = ecPosition.z; +// const float LOG2 = 1.442695; +// fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2); +// +// if(gl_Fog.density == 1.0) +// fogFactor=1.0; - if(gl_Fog.density == 1.0) - fogFactor=1.0; - - //calculate final colour + //calculate final colour vec4 ambient_light = gl_LightSource[0].diffuse; vec4 finalColor; @@ -122,5 +128,7 @@ void main(void) finalColor *= ambient_light; - gl_FragColor = mix(gl_Fog.color, finalColor, fogFactor); +// gl_FragColor = mix(gl_Fog.color, finalColor, fogFactor); + finalColor.rgb = fog_Func(finalColor.rgb, fogType); + gl_FragColor = finalColor; } diff --git a/Shaders/water-orig.frag b/Shaders/water-orig.frag index 1b6896bb9..4262ac1c2 100644 --- a/Shaders/water-orig.frag +++ b/Shaders/water-orig.frag @@ -10,6 +10,11 @@ uniform sampler3D NoiseTex; uniform float osg_SimulationTime; //const float scale = 1.0; +////fog "include" ///// +uniform int fogType; + +vec3 fog_Func(vec3 color, int type); +////////////////////// void main (void) { @@ -19,18 +24,18 @@ void main (void) vec4 noisevec = texture3D(NoiseTex, (rawpos.xyz)*0.00423+vec3(0.0,0.0,osg_SimulationTime*0.035217)); vec4 nvL = texture3D(NoiseTex, (rawpos.xyz)*0.001223417+(0.0,0.0,osg_SimulationTime*-0.0212)); - float fogFactor; - if (gl_Fog.density == 1.0) - { - fogFactor=1.0; - } - else - { - float fogCoord = ecPosition.z; - const float LOG2 = 1.442695; - fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2); - fogFactor = clamp(fogFactor, 0.0, 1.0); - } +// float fogFactor; +// if (gl_Fog.density == 1.0) +// { +// fogFactor=1.0; +// } +// else +// { +// float fogCoord = ecPosition.z; +// const float LOG2 = 1.442695; +// fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2); +// fogFactor = clamp(fogFactor, 0.0, 1.0); +// } float a=1.0; float n=0.00; @@ -64,7 +69,7 @@ void main (void) c1 = asin(vec4(smoothstep(0.0, 2.2, n), smoothstep(-0.1, 2.10, n), smoothstep(-0.2, 2.0, n), 1.0)); vec3 Eye = normalize(-ecPosition.xyz); - vec3 Reflected = normalize(reflect(-normalize(lightVec), normalize(VNormal+vec3(0.0,0.0,na*0.10-0.24)))); + vec3 Reflected = normalize(reflect(-normalize(lightVec), normalize(VNormal+vec3(0.0,0.0,na*0.10-0.24)))); vec3 bump = normalize(VNormal+vec3(0.0, 0.0, na)-0.9); vec3 bumped = max(normalize(refract(lightVec, normalize(bump), 0.16)), 0.0); @@ -82,5 +87,7 @@ void main (void) c1 += gl_LightSource[0].specular * eyeFact * 4.0*bumpFact; vec4 finalColor = c1; - gl_FragColor = mix(gl_Fog.color, finalColor, fogFactor); +// gl_FragColor = mix(gl_Fog.color, finalColor, fogFactor); + finalColor.rgb = fog_Func(finalColor.rgb, fogType); + gl_FragColor = finalColor; } diff --git a/Shaders/water.frag b/Shaders/water.frag index f640f6958..3392a4ec5 100644 --- a/Shaders/water.frag +++ b/Shaders/water.frag @@ -181,13 +181,13 @@ void main(void) refl *= fres; //calculate the fog factor - float fogFactor; - float fogCoord = ecPosition.z; - const float LOG2 = 1.442695; - fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2); - - if(gl_Fog.density == 1.0) - fogFactor=1.0; +// float fogFactor; +// float fogCoord = ecPosition.z; +// const float LOG2 = 1.442695; +// fogFactor = exp2(-gl_Fog.density * gl_Fog.density * fogCoord * fogCoord * LOG2); +// +// if(gl_Fog.density == 1.0) +// fogFactor=1.0; //calculate final colour vec4 ambient_light = gl_LightSource[0].diffuse; @@ -203,7 +203,7 @@ void main(void) //float waveSlope = mix(N0.g, N1.g, 0.25); vec4 foam_texel = texture2D(sea_foam, vec2(waterTex2 * tscale) * 25.0); - float waveSlope = N.g; + float waveSlope = N.g; if (windEffect >= 8.0) if (waveSlope >= foamSlope){ diff --git a/Shaders/water.vert b/Shaders/water.vert index f268b7cc1..ab6e1b92c 100644 --- a/Shaders/water.vert +++ b/Shaders/water.vert @@ -20,9 +20,9 @@ uniform float osg_SimulationTime; uniform float WindE, WindN; ////fog "include"//////// -uniform int fogType; - -void fog_Func(int type); +// uniform int fogType; +// +// void fog_Func(int type); ///////////////////////// /////// functions ///////// @@ -66,6 +66,6 @@ void main(void) rotationmatrix(Angle, RotationMatrix); waterTex2 = gl_MultiTexCoord0 * RotationMatrix - t2 * windFactor; - fog_Func(fogType); +// fog_Func(fogType); gl_Position = ftransform(); } \ No newline at end of file diff --git a/Shaders/water_sine.frag b/Shaders/water_sine.frag index 36beb0690..4d075251a 100644 --- a/Shaders/water_sine.frag +++ b/Shaders/water_sine.frag @@ -24,7 +24,7 @@ uniform int Status; varying vec4 waterTex1; //moving texcoords varying vec4 waterTex2; //moving texcoords varying vec4 waterTex4; //viewts -varying vec4 ecPosition; +//varying vec4 ecPosition; varying vec3 viewerdir; varying vec3 lightdir; varying vec3 normal; @@ -263,7 +263,7 @@ void main(void) if(cover >= 1.5){ refl= normalize(refTex); - } + } else { refl = normalize(refTexGrey); @@ -291,7 +291,7 @@ void main(void) N0 *= windEffect_low; N1 *= windEffect_low; - N0.r += (ddx + ddx1 + ddx2 + ddx3); + N0.r += (ddx + ddx1 + ddx2 + ddx3); N0.g += (ddy + ddy1 + ddy2 + ddy3); vec3 N = normalize(mix(Normal + N0, Normal + N1, mixFactor) * waveRoughness); @@ -335,7 +335,7 @@ void main(void) //float waveSlope = mix(N0.g, N1.g, 0.25); vec4 foam_texel = texture2D(sea_foam, vec2(waterTex2 * tscale) * 25.0); - float waveSlope = N.g; + float waveSlope = N.g; if (windEffect >= 8.0) if (waveSlope >= foamSlope){