From 5909285100a29df3f344c0489555be6c8ce6a143 Mon Sep 17 00:00:00 2001 From: Stuart Buchanan Date: Sat, 28 Apr 2012 22:51:05 +0100 Subject: [PATCH 01/19] Building effect for random buildings. --- Effects/building.eff | 59 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Effects/building.eff diff --git a/Effects/building.eff b/Effects/building.eff new file mode 100644 index 000000000..52b8abb69 --- /dev/null +++ b/Effects/building.eff @@ -0,0 +1,59 @@ + + + Effects/building + Effects/model-default + + + true + 2d + normalized + linear-mipmap-linear + clamp + clamp + + false + false + + true + 1 + 0.3 0.3 0.3 1.0 + 1.0 1.0 1.0 1.0 + 0.0 0.0 0.0 1.0 + 0.02 0.02 0.02 1.0 + 0.0 + ambient-and-diffuse + ambient-and-diffuse + + + 0 + + 0 + 0 + 0 + + flat + back + opaque + false + + + /environment/ground-visibility-m + + + /environment/visibility-m + + + /environment/ground-haze-thickness-m + + + /rendering/scene/scattering + + + /environment/terminator-relative-position-m + + + /sim/rendering/shaders/skydome + + + + From 76a11c2d48a7dcfd81e25f0b4f8b939af4242d52 Mon Sep 17 00:00:00 2001 From: Frederic Bouvier Date: Sun, 29 Apr 2012 13:35:30 +0200 Subject: [PATCH 02/19] Fix bug #750: allow cards or drivers not supporting dynamic indexing in fragment shaders to have simple shadows --- Effects/sunlight.eff | 120 +++++++++++++++++++++++++++++++-- Shaders/sunlight-noshadow.frag | 12 ++-- Shaders/sunlight-simple.frag | 74 ++++++++++++++++++++ Shaders/sunlight-simple.vert | 19 ++++++ 4 files changed, 210 insertions(+), 15 deletions(-) create mode 100644 Shaders/sunlight-simple.frag create mode 100644 Shaders/sunlight-simple.vert diff --git a/Effects/sunlight.eff b/Effects/sunlight.eff index 4a12ce705..1717de1ce 100644 --- a/Effects/sunlight.eff +++ b/Effects/sunlight.eff @@ -4,14 +4,26 @@ /sim/rendering/shadows/filtering - + /sim/rendering/shadows/enabled - - 1.0 - /sim/rendering/shadows/filtering - + + + 2.0 + /sim/rendering/shadows/filtering + + + + 1.0 + /sim/rendering/shadows/filtering + + + 1.0 + /sim/rendering/shadows/num-cascades + + + @@ -96,9 +108,16 @@ --> - + - /sim/rendering/shadows/enabled + + /sim/rendering/shadows/enabled + + + 1.0 + /sim/rendering/shadows/num-cascades + + false @@ -177,6 +196,92 @@ --> + + + /sim/rendering/shadows/enabled + + + false + + false + + + one + one + + + 1 + RenderBin + + + 0 + depth-buffer + + + 1 + normal-buffer + + + 2 + diffuse-buffer + + + 3 + spec-emis-buffer + + + 4 + shadow-buffer + + + Shaders/sunlight-simple.vert + Shaders/sunlight-simple.frag + Shaders/gbuffer-functions.frag + + + depth_tex + sampler-2d + 0 + + + normal_tex + sampler-2d + 1 + + + color_tex + sampler-2d + 2 + + + spec_emis_tex + sampler-2d + 3 + + + shadow_tex + sampler-2d + 4 + + + filtering + int + filtering + + + + false @@ -210,6 +315,7 @@ Shaders/sunlight.vert Shaders/sunlight-noshadow.frag + Shaders/gbuffer-functions.frag depth_tex diff --git a/Shaders/sunlight-noshadow.frag b/Shaders/sunlight-noshadow.frag index 79f5ea664..5e4abf0f2 100644 --- a/Shaders/sunlight-noshadow.frag +++ b/Shaders/sunlight-noshadow.frag @@ -8,23 +8,19 @@ uniform vec4 fg_SunSpecularColor; uniform vec3 fg_SunDirection; uniform vec3 fg_Planes; varying vec3 ray; + +vec3 normal_decode(vec2 enc); + void main() { vec2 coords = gl_TexCoord[0].xy; vec4 spec_emis = texture2D( spec_emis_tex, coords ); if ( spec_emis.a < 0.1 ) discard; - vec3 normal; - normal.xy = texture2D( normal_tex, coords ).rg * 2.0 - vec2(1.0,1.0); - normal.z = sqrt( 1.0 - dot( normal.xy, normal.xy ) ); + vec3 normal = normal_decode(texture2D( normal_tex, coords ).rg); float len = length(normal); normal /= len; vec3 viewDir = normalize(ray); - float depth = texture2D( depth_tex, coords ).r; - vec3 pos; - pos.z = - fg_Planes.y / (fg_Planes.x + depth * fg_Planes.z); - pos.xy = viewDir.xy / viewDir.z * pos.z; - vec4 tint; vec3 lightDir = (fg_ViewMatrix * vec4( fg_SunDirection, 0.0 )).xyz; lightDir = normalize( lightDir ); vec3 color = texture2D( color_tex, coords ).rgb; diff --git a/Shaders/sunlight-simple.frag b/Shaders/sunlight-simple.frag new file mode 100644 index 000000000..4a354c02b --- /dev/null +++ b/Shaders/sunlight-simple.frag @@ -0,0 +1,74 @@ +uniform mat4 fg_ViewMatrix; +uniform sampler2D depth_tex; +uniform sampler2D normal_tex; +uniform sampler2D color_tex; +uniform sampler2D spec_emis_tex; +uniform sampler2DShadow shadow_tex; +uniform vec4 fg_SunDiffuseColor; +uniform vec4 fg_SunSpecularColor; +uniform vec3 fg_SunDirection; +uniform vec3 fg_Planes; +uniform vec4 fg_ShadowDistances; +uniform int filtering; + +varying vec3 ray; +varying vec4 eyePlaneS; +varying vec4 eyePlaneT; +varying vec4 eyePlaneR; +varying vec4 eyePlaneQ; + +vec3 position( vec3 viewdir, float depth ); +vec3 normal_decode(vec2 enc); + +vec4 DynamicShadow( in vec4 ecPosition, out vec4 tint ) +{ + vec4 coords; + if (ecPosition.z > -fg_ShadowDistances.x) { + tint = vec4(0.0,1.0,0.0,1.0); + coords.s = dot( ecPosition, eyePlaneS ); + coords.t = dot( ecPosition, eyePlaneT ); + coords.p = dot( ecPosition, eyePlaneR ); + coords.q = dot( ecPosition, eyePlaneQ ); + } else { + return vec4(1.1,1.1,0.0,1.0); // outside, clamp to border + } + return coords; +} +void main() { + vec2 coords = gl_TexCoord[0].xy; + vec4 spec_emis = texture2D( spec_emis_tex, coords ); + if ( spec_emis.a < 0.1 ) + discard; + vec3 normal = normal_decode(texture2D( normal_tex, coords ).rg); + float len = length(normal); + normal /= len; + vec3 viewDir = normalize(ray); + vec3 pos = position( viewDir, texture2D( depth_tex, coords ).r ); + + vec4 tint; + float shadow; + if (filtering == 2) { + shadow += 0.333 * shadow2DProj( shadow_tex, DynamicShadow( vec4(pos, 1.0), tint ) ).r; + shadow += 0.166 * shadow2DProj( shadow_tex, DynamicShadow( vec4(pos + vec3(-0.003 * pos.z, -0.002 * pos.z, 0), 1.0), tint ) ).r; + shadow += 0.166 * shadow2DProj( shadow_tex, DynamicShadow( vec4(pos + vec3( 0.003 * pos.z, 0.002 * pos.z, 0), 1.0), tint ) ).r; + shadow += 0.166 * shadow2DProj( shadow_tex, DynamicShadow( vec4(pos + vec3(-0.003 * pos.z, 0.002 * pos.z, 0), 1.0), tint ) ).r; + shadow += 0.166 * shadow2DProj( shadow_tex, DynamicShadow( vec4(pos + vec3( 0.003 * pos.z, -0.002 * pos.z, 0), 1.0), tint ) ).r; + } else { + shadow = shadow2DProj( shadow_tex, DynamicShadow( vec4( pos, 1.0 ), tint ) ).r; + } + + vec3 lightDir = (fg_ViewMatrix * vec4( fg_SunDirection, 0.0 )).xyz; + lightDir = normalize( lightDir ); + vec3 color = texture2D( color_tex, coords ).rgb; + vec3 Idiff = clamp( dot( lightDir, normal ), 0.0, 1.0 ) * color * fg_SunDiffuseColor.rgb; + vec3 halfDir = lightDir - viewDir; + len = length( halfDir ); + vec3 Ispec = vec3(0.0); + vec3 Iemis = spec_emis.z * color; + if (len > 0.0001) { + halfDir /= len; + Ispec = pow( clamp( dot( halfDir, normal ), 0.0, 1.0 ), spec_emis.y * 128.0 ) * spec_emis.x * fg_SunSpecularColor.rgb; + } + gl_FragColor = vec4(mix(vec3(0.0), Idiff + Ispec, shadow) + Iemis, 1.0); +// gl_FragColor = mix(tint, vec4(mix(vec3(0.0), Idiff + Ispec, shadow) + Iemis, 1.0), 0.92); +} diff --git a/Shaders/sunlight-simple.vert b/Shaders/sunlight-simple.vert new file mode 100644 index 000000000..7e382596a --- /dev/null +++ b/Shaders/sunlight-simple.vert @@ -0,0 +1,19 @@ +//uniform mat4 fg_ViewMatrixInverse; +uniform mat4 fg_ProjectionMatrixInverse; +varying vec3 ray; +varying vec4 eyePlaneS; +varying vec4 eyePlaneT; +varying vec4 eyePlaneR; +varying vec4 eyePlaneQ; + +void main() { + gl_Position = gl_Vertex; + gl_TexCoord[0] = gl_MultiTexCoord0; +// ray = (fg_ViewMatrixInverse * vec4((fg_ProjectionMatrixInverse * gl_Vertex).xyz, 0.0)).xyz; + ray = (fg_ProjectionMatrixInverse * gl_Vertex).xyz; + + eyePlaneS = gl_EyePlaneS[1]; + eyePlaneT = gl_EyePlaneT[1]; + eyePlaneR = gl_EyePlaneR[1]; + eyePlaneQ = gl_EyePlaneQ[1]; +} From 9c7051d2ce238609bc87e73172b33a04e3e9f2dc Mon Sep 17 00:00:00 2001 From: BARANGER Emmanuel Date: Mon, 30 Apr 2012 01:09:49 +0200 Subject: [PATCH 03/19] Merge branch 'master' of git://gitorious.org/fg/fgdata From 4b1d51a801a07d7ddb17d7f0fa9307440cfc9808 Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Mon, 30 Apr 2012 19:22:00 +0200 Subject: [PATCH 04/19] Improve scenario dialog Support optional name for scenarios. Add explicit scenario enable/disable switch. --- gui/dialogs/scenario.xml | 32 ++++++++++++++++++++++++++++---- preferences.xml | 10 +++------- 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/gui/dialogs/scenario.xml b/gui/dialogs/scenario.xml index dc2749ff3..abc852a3a 100644 --- a/gui/dialogs/scenario.xml +++ b/gui/dialogs/scenario.xml @@ -30,7 +30,7 @@ true - + true @@ -49,8 +49,24 @@ + + left + + enable-ai-scenarios + /sim/ai/scenarios-enabled + + dialog-apply + enable-ai-scenarios + + + + + + + /sim/ai/scenarios-enabled + @@ -120,8 +136,12 @@ var scenarioN = rootN.getNode("scenario"); if( scenarioN == nil ) return; var descriptionN = rootN.getNode("description"); - if( descriptionN == nil ) - var descriptionN = scenarioN.getNode("description"); + var nameN = rootN.getNode("name"); + if( (descriptionN == nil)and(nameN == nil) ) + { + descriptionN = scenarioN.getNode("description"); + nameN = scenarioN.getNode("name"); + } var description = descriptionN != nil ? descriptionN.getValue() : ""; var propertyRoot = props.globals.getNode("sim/gui/dialogs/scenario",1).getChild( "scenario", nr, 1 ); propertyRoot.getNode("selected",1).setBoolValue(isEnabledScenario(file)); @@ -131,8 +151,12 @@ group.getNode("layout",1).setValue("hbox"); var cb = group.getNode("checkbox",1); cb.getNode("property",1).setValue(propertyRoot.getNode("selected").getPath()); - cb.getNode("label",1).setValue(file); + var label = string.replace(file, "_", " "); + if (nameN != nil) + label = nameN.getValue(); + cb.getNode("label",1).setValue(label); cb.getNode("name",1).setValue(file); + cb.getNode("enable/property",1).setValue("/sim/ai/scenarios-enabled"); group.getNode("empty",1).getNode("stretch",1).setValue("true"); } diff --git a/preferences.xml b/preferences.xml index ff39245ec..987dd0c9c 100644 --- a/preferences.xml +++ b/preferences.xml @@ -63,7 +63,7 @@ Started September 2000 by David Megginson, david@megginson.com summer - Materials/default/materials.xml + Materials/default/materials.xml false true false @@ -748,13 +748,9 @@ Started September 2000 by David Megginson, david@megginson.com true + true nimitz_demo - true - - - - - + true From 6be18a5c997b3cbe5ae2cbfb8b76480d879a8465 Mon Sep 17 00:00:00 2001 From: Frederic Bouvier Date: Tue, 1 May 2012 08:47:38 +0200 Subject: [PATCH 05/19] Add the ability to record depth in color buffer. This should solve depth buffer resolution problem for older NVidia cards. --- Effects/tree.eff | 1 + Shaders/deferred-gbuffer.frag | 16 ++++----- Shaders/deferred-gbuffer.vert | 8 ++--- Shaders/deferred-tree.frag | 8 ++--- Shaders/fog.frag | 8 ++--- Shaders/gbuffer-functions.frag | 57 ++++++++++++++++++++++++++++++- Shaders/light-point.frag | 4 +-- Shaders/light-spot.frag | 4 +-- Shaders/sunlight-nofiltering.frag | 4 +-- Shaders/sunlight-simple.frag | 4 +-- Shaders/sunlight.frag | 4 +-- Shaders/ubershader-gbuffer.frag | 6 ++-- Shaders/urban-gbuffer.frag | 7 ++-- preferences.xml | 1 + 14 files changed, 88 insertions(+), 44 deletions(-) diff --git a/Effects/tree.eff b/Effects/tree.eff index 18599aa5d..ad27ae4f4 100644 --- a/Effects/tree.eff +++ b/Effects/tree.eff @@ -67,6 +67,7 @@ Shaders/deferred-tree.vert Shaders/deferred-tree.frag + Shaders/gbuffer-functions.frag texture diff --git a/Shaders/deferred-gbuffer.frag b/Shaders/deferred-gbuffer.frag index e1d3b4cf9..3ffce50f1 100644 --- a/Shaders/deferred-gbuffer.frag +++ b/Shaders/deferred-gbuffer.frag @@ -1,15 +1,15 @@ #extension GL_EXT_gpu_shader4 : enable +// -*- mode: C; -*- +// Licence: GPL v2 +// Author: Frederic Bouvier. // -// attachment 0: normal.x | normal.x | normal.y | normal.y -// attachment 1: diffuse.r | diffuse.g | diffuse.b | material Id -// attachment 2: specular.l | shininess | emission.l | unused -// + varying vec3 ecNormal; varying float alpha; uniform int materialID; uniform sampler2D texture; -vec2 normal_encode(vec3 n); +void encode_gbuffer(vec3 normal, vec3 color, int mId, float specular, float shininess, float emission, float depth); void main() { vec4 texel = texture2D(texture, gl_TexCoord[0].st); @@ -19,8 +19,6 @@ void main() { float shininess = gl_FrontMaterial.shininess; float emission = dot( gl_FrontLightModelProduct.sceneColor.rgb, vec3( 0.3, 0.59, 0.11 ) ); - vec3 normal2 = normalize( (2.0 * gl_Color.a - 1.0) * ecNormal ); - gl_FragData[0] = vec4( normal_encode(normal2), 0.0, 1.0 ); - gl_FragData[1] = vec4( gl_Color.rgb * texel.rgb, float( materialID ) / 255.0 ); - gl_FragData[2] = vec4( specular, shininess / 128.0, emission, 1.0 ); + vec3 normal2 = normalize( (2.0 * gl_Color.a - 1.0) * ecNormal ); + encode_gbuffer(normal2, gl_Color.rgb * texel.rgb, materialID, specular, shininess, emission, gl_FragCoord.z); } diff --git a/Shaders/deferred-gbuffer.vert b/Shaders/deferred-gbuffer.vert index 4ab618936..ca8e4549d 100644 --- a/Shaders/deferred-gbuffer.vert +++ b/Shaders/deferred-gbuffer.vert @@ -1,8 +1,8 @@ +// -*- mode: C; -*- +// Licence: GPL v2 +// Author: Frederic Bouvier. // -// attachment 0: normal.x | normal.x | normal.y | normal.y -// attachment 1: diffuse.r | diffuse.g | diffuse.b | material Id -// attachment 2: specular.l | shininess | emission.l | unused -// + varying vec3 ecNormal; varying float alpha; void main() { diff --git a/Shaders/deferred-tree.frag b/Shaders/deferred-tree.frag index 8c416240c..5d94da809 100644 --- a/Shaders/deferred-tree.frag +++ b/Shaders/deferred-tree.frag @@ -6,6 +6,7 @@ // uniform int materialID; uniform sampler2D texture; +void encode_gbuffer(vec3 normal, vec3 color, int mId, float specular, float shininess, float emission, float depth); void main() { vec4 texel = texture2D(texture, gl_TexCoord[0].st); if (texel.a < 0.1) @@ -14,9 +15,6 @@ void main() { float shininess = 0.1; float emission = 0.0; - // Normal is straight towards the viewer. - vec3 normal2 = vec3(0.0, 0.0, 0.0); - gl_FragData[0] = vec4( 0.5, 0.5, 0.0, 1.0 ); - gl_FragData[1] = vec4( gl_Color.rgb * texel.rgb, float( materialID ) / 255.0 ); - gl_FragData[2] = vec4( specular, shininess / 255.0, emission, 1.0 ); + // Normal is straight towards the viewer. (FB: Are they really billboards ? ) + encode_gbuffer(vec3(0.5, 0.5, 0.0), gl_Color.rgb * texel.rgb, materialID, specular, shininess, emission, gl_FragCoord.z); } diff --git a/Shaders/fog.frag b/Shaders/fog.frag index 09280db14..3ae150fc5 100644 --- a/Shaders/fog.frag +++ b/Shaders/fog.frag @@ -7,7 +7,7 @@ uniform float fg_FogDensity; uniform vec3 fg_Planes; varying vec3 ray; -vec3 position( vec3 viewdir, float depth ); +vec3 position( vec3 viewDir, vec2 coords, sampler2D depth_tex ); void main() { vec2 coords = gl_TexCoord[0].xy; @@ -15,11 +15,7 @@ void main() { if ( initialized < 0.1 ) discard; vec3 normal; - normal.xy = texture2D( normal_tex, coords ).rg * 2.0 - vec2(1.0,1.0); - normal.z = sqrt( 1.0 - dot( normal.xy, normal.xy ) ); - float len = length(normal); - normal /= len; - vec3 pos = position( normalize(ray), texture2D( depth_tex, coords ).r ); + vec3 pos = position( normalize(ray), coords, depth_tex ); float fogFactor = 0.0; const float LOG2 = 1.442695; diff --git a/Shaders/gbuffer-functions.frag b/Shaders/gbuffer-functions.frag index 5b8addee6..871a209ef 100644 --- a/Shaders/gbuffer-functions.frag +++ b/Shaders/gbuffer-functions.frag @@ -1,4 +1,9 @@ +// -*- mode: C; -*- +// Licence: GPL v2 +// Author: Frederic Bouvier. + uniform vec3 fg_Planes; +uniform bool fg_DepthInColor; // normal compression functions from // http://aras-p.info/texts/CompactNormalStorage.html#method04spheremap @@ -19,10 +24,60 @@ vec3 normal_decode(vec2 enc) return n; } +// depth to color encoding and decoding functions from +// Deferred Shading Tutorial by Fabio Policarpo and Francisco Fonseca +// (corrected by Frederic Bouvier) +vec3 float_to_color(in float f) +{ + vec3 color; + f *= 255.0; + color.x = floor(f); + f = (f-color.x)*255.0; + color.y = floor(f); + color.z = f-color.y; + color.xy /= 255.0; + return color; +} + +float color_to_float(vec3 color) +{ + const vec3 byte_to_float = vec3(1.0, 1.0/255.0, 1.0/(255.0*255.0)); + return dot(color,byte_to_float); +} + vec3 position( vec3 viewDir, float depth ) { vec3 pos; pos.z = - fg_Planes.y / (fg_Planes.x + depth * fg_Planes.z); pos.xy = viewDir.xy / viewDir.z * pos.z; - return pos; + return pos; +} + +vec3 position( vec3 viewDir, vec3 depthColor ) +{ + return position( viewDir, color_to_float(depthColor) ); +} + +vec3 position( vec3 viewDir, vec2 coords, sampler2D depth_tex ) +{ + float depth; + if (fg_DepthInColor) + depth = color_to_float( texture2D( depth_tex, coords ).rgb ); + else + depth = texture2D( depth_tex, coords ).r; + return position( viewDir, depth ); +} + +// attachment 0: normal.x | normal.y | 0.0 | 1.0 +// attachment 1: diffuse.r | diffuse.g | diffuse.b | material Id +// attachment 2: specular.l | shininess | emission.l | unused +// attachment 3: ---------- depth ------------ | unused (optional) +// +void encode_gbuffer(vec3 normal, vec3 color, int mId, float specular, float shininess, float emission, float depth) +{ + gl_FragData[0] = vec4( normal_encode(normal), 0.0, 1.0 ); + gl_FragData[1] = vec4( color, float( mId ) / 255.0 ); + gl_FragData[2] = vec4( specular, shininess / 128.0, emission, 1.0 ); + if (fg_DepthInColor) + gl_FragData[3] = vec4(float_to_color(depth), 1.0); } diff --git a/Shaders/light-point.frag b/Shaders/light-point.frag index f71a40600..739017278 100644 --- a/Shaders/light-point.frag +++ b/Shaders/light-point.frag @@ -15,7 +15,7 @@ uniform float Far; varying vec4 ecPosition; -vec3 position( vec3 viewdir, float depth ); +vec3 position( vec3 viewDir, vec2 coords, sampler2D depth_tex ); vec3 normal_decode(vec2 enc); void main() { @@ -27,7 +27,7 @@ void main() { vec3 normal = normal_decode(texture2D( normal_tex, coords ).rg); vec4 spec_emis = texture2D( spec_emis_tex, coords ); - vec3 pos = position(viewDir, texture2D( depth_tex, coords ).r); + vec3 pos = position(viewDir, coords, depth_tex); if ( pos.z < ecPos3.z ) // Negative direction in z discard; // Don't light surface outside the light volume diff --git a/Shaders/light-spot.frag b/Shaders/light-spot.frag index 7371eec6f..a4bdd7231 100644 --- a/Shaders/light-spot.frag +++ b/Shaders/light-spot.frag @@ -19,7 +19,7 @@ uniform float Far; varying vec4 ecPosition; -vec3 position( vec3 viewdir, float depth ); +vec3 position( vec3 viewDir, vec2 coords, sampler2D depth_tex ); vec3 normal_decode(vec2 enc); void main() { @@ -31,7 +31,7 @@ void main() { vec3 normal = normal_decode(texture2D( normal_tex, coords ).rg); vec4 spec_emis = texture2D( spec_emis_tex, coords ); - vec3 pos = position(viewDir, texture2D( depth_tex, coords ).r); + vec3 pos = position(viewDir, coords, depth_tex); if ( pos.z < ecPos3.z ) // Negative direction in z discard; // Don't light surface outside the light volume diff --git a/Shaders/sunlight-nofiltering.frag b/Shaders/sunlight-nofiltering.frag index 80ea77f54..aacfd9d3c 100644 --- a/Shaders/sunlight-nofiltering.frag +++ b/Shaders/sunlight-nofiltering.frag @@ -12,7 +12,7 @@ uniform int fg_ShadowNumber; uniform vec4 fg_ShadowDistances; varying vec3 ray; -vec3 position( vec3 viewdir, float depth ); +vec3 position( vec3 viewDir, vec2 coords, sampler2D depth_tex ); vec3 normal_decode(vec2 enc); vec4 DynamicShadow( in vec4 ecPosition, out vec4 tint ) @@ -57,7 +57,7 @@ void main() { float len = length(normal); normal /= len; vec3 viewDir = normalize(ray); - vec3 pos = position( viewDir, texture2D( depth_tex, coords ).r ); + vec3 pos = position( viewDir, coords, depth_tex ); vec4 tint; float shadow = shadow2DProj( shadow_tex, DynamicShadow( vec4( pos, 1.0 ), tint ) ).r; diff --git a/Shaders/sunlight-simple.frag b/Shaders/sunlight-simple.frag index 4a354c02b..e6d38deb7 100644 --- a/Shaders/sunlight-simple.frag +++ b/Shaders/sunlight-simple.frag @@ -17,7 +17,7 @@ varying vec4 eyePlaneT; varying vec4 eyePlaneR; varying vec4 eyePlaneQ; -vec3 position( vec3 viewdir, float depth ); +vec3 position( vec3 viewDir, vec2 coords, sampler2D depth_tex ); vec3 normal_decode(vec2 enc); vec4 DynamicShadow( in vec4 ecPosition, out vec4 tint ) @@ -43,7 +43,7 @@ void main() { float len = length(normal); normal /= len; vec3 viewDir = normalize(ray); - vec3 pos = position( viewDir, texture2D( depth_tex, coords ).r ); + vec3 pos = position( viewDir, coords, depth_tex ); vec4 tint; float shadow; diff --git a/Shaders/sunlight.frag b/Shaders/sunlight.frag index 6f5578342..1d79c94db 100644 --- a/Shaders/sunlight.frag +++ b/Shaders/sunlight.frag @@ -14,7 +14,7 @@ uniform vec4 fg_ShadowDistances; uniform int filtering; varying vec3 ray; -vec3 position( vec3 viewdir, float depth ); +vec3 position( vec3 viewDir, vec2 coords, sampler2D depth_tex ); vec3 normal_decode(vec2 enc); vec4 DynamicShadow( in vec4 ecPosition, out vec4 tint ) @@ -59,7 +59,7 @@ void main() { float len = length(normal); normal /= len; vec3 viewDir = normalize(ray); - vec3 pos = position( viewDir, texture2D( depth_tex, coords ).r ); + vec3 pos = position( viewDir, coords, depth_tex ); vec4 tint; float shadow = 0.0; diff --git a/Shaders/ubershader-gbuffer.frag b/Shaders/ubershader-gbuffer.frag index ff6c48a3a..be75f8c96 100644 --- a/Shaders/ubershader-gbuffer.frag +++ b/Shaders/ubershader-gbuffer.frag @@ -56,7 +56,7 @@ uniform vec3 dirt_g_color; uniform vec3 dirt_b_color; //uniform vec4 fg_SunAmbientColor; -vec2 normal_encode(vec3 n); +void encode_gbuffer(vec3 normal, vec3 color, int mId, float specular, float shininess, float emission, float depth); ///fog include////////////////////// uniform int fogType; @@ -180,7 +180,5 @@ void main (void) // END lightmap ///////////////////////////////////////////////////////////////////// - gl_FragData[0]=vec4(normal_encode(N), 0.0, 1.0); - gl_FragData[1]=vec4(fragColor.rgb,1.0/255.0); - gl_FragData[2]=vec4(specular, gl_FrontMaterial.shininess/128.0, emission, 1.0); + encode_gbuffer(N, fragColor.rgb, 1, specular, gl_FrontMaterial.shininess, emission, gl_FragCoord.z); } \ No newline at end of file diff --git a/Shaders/urban-gbuffer.frag b/Shaders/urban-gbuffer.frag index c28959996..f182347ee 100644 --- a/Shaders/urban-gbuffer.frag +++ b/Shaders/urban-gbuffer.frag @@ -37,7 +37,7 @@ int linear_search_steps = 10; int GlobalIterationCount = 0; int gIterationCap = 64; -vec2 normal_encode(vec3 n); +void encode_gbuffer(vec3 normal, vec3 color, int mId, float specular, float shininess, float emission, float depth); void QDM(inout vec3 p, inout vec3 v) { @@ -190,7 +190,6 @@ void main (void) N.z = sqrt(1.0 - min(1.0,dot(N.xy, N.xy))); float Nz = N.z; N = normalize(N.x * tangent + N.y * binormal + N.z * normal); - gl_FragData[0] = vec4( normal_encode(N), 0.0, 1.0 ); vec4 ambient_light = constantColor + vec4(gl_Color.rgb, 1.0); @@ -216,9 +215,6 @@ void main (void) vec4 p = vec4( ecPos3 + tile_size * V * (d-1.0) * depth_factor / s.z, 1.0 ); - gl_FragData[1] = vec4( finalColor.rgb, 1.0 / 255.0 ); - gl_FragData[2] = vec4( dot(specular.xyz,vec3(0.3, 0.59, 0.11 )), specular.w/128.0, 0.0, 1.0 ); - if (dot(normal,-V) > 0.1) { vec4 iproj = gl_ProjectionMatrix * p; iproj /= iproj.w; @@ -226,4 +222,5 @@ void main (void) } else { gl_FragDepth = gl_FragCoord.z; } + encode_gbuffer(N, finalColor.rgb, 1, dot(specular.xyz,vec3(0.3, 0.59, 0.11 )), specular.w, 0.0, gl_FragDepth); } diff --git a/preferences.xml b/preferences.xml index 987dd0c9c..2e90f8e6a 100644 --- a/preferences.xml +++ b/preferences.xml @@ -68,6 +68,7 @@ Started September 2000 by David Megginson, david@megginson.com true false 1.0 + false false 5 8 From 6775ecdfd261dbbe28ede07e01a593f992304491 Mon Sep 17 00:00:00 2001 From: Frederic Bouvier Date: Tue, 1 May 2012 09:34:14 +0200 Subject: [PATCH 06/19] Display the depth buffer when stored in a color texture --- Shaders/display.frag | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/Shaders/display.frag b/Shaders/display.frag index 038369bc7..acb54c65e 100644 --- a/Shaders/display.frag +++ b/Shaders/display.frag @@ -7,6 +7,7 @@ uniform sampler2D lighting_tex; //uniform sampler2D ao_tex; uniform float exposure; uniform bool showBuffers; +uniform bool fg_DepthInColor; vec3 HDR(vec3 L) { L = L * exposure; @@ -19,22 +20,22 @@ vec3 HDR(vec3 L) { void main() { vec2 coords = gl_TexCoord[0].xy; vec4 color; - if (showBuffers) { - if (coords.x < 0.2 && coords.y < 0.2) { - color = texture2D( normal_tex, coords * 5.0 ); - } else if (coords.x >= 0.8 && coords.y >= 0.8) { - color = texture2D( specular_tex, (coords - vec2( 0.8, 0.8 )) * 5.0 ); - } else if (coords.x >= 0.8 && coords.y < 0.2) { - color = texture2D( color_tex, (coords - vec2( 0.8, 0.0 )) * 5.0 ); -// } else if (coords.x < 0.2 && coords.y >= 0.8) { -// color = texture2D( ao_tex, (coords - vec2( 0.0, 0.8 )) * 5.0 ); - } else { - color = texture2D( lighting_tex, coords ) /* + texture2D( bloom_tex, coords ) */; - //color = vec4( HDR( color.rgb ), 1.0 ); - } - } else { - color = texture2D( lighting_tex, coords ) /* + texture2D( bloom_tex, coords ) */; - //color = vec4( HDR( color.rgb ), 1.0 ); - } + if (showBuffers) { + if (coords.x < 0.2 && coords.y < 0.2) { + color = texture2D( normal_tex, coords * 5.0 ); + } else if (coords.x >= 0.8 && coords.y >= 0.8) { + color = texture2D( specular_tex, (coords - vec2( 0.8, 0.8 )) * 5.0 ); + } else if (coords.x >= 0.8 && coords.y < 0.2) { + color = texture2D( color_tex, (coords - vec2( 0.8, 0.0 )) * 5.0 ); + } else if (coords.x < 0.2 && coords.y >= 0.8 && fg_DepthInColor) { + color = texture2D( depth_tex, (coords - vec2( 0.0, 0.8 )) * 5.0 ); + } else { + color = texture2D( lighting_tex, coords ) /* + texture2D( bloom_tex, coords ) */; + //color = vec4( HDR( color.rgb ), 1.0 ); + } + } else { + color = texture2D( lighting_tex, coords ) /* + texture2D( bloom_tex, coords ) */; + //color = vec4( HDR( color.rgb ), 1.0 ); + } gl_FragColor = color; } From d51a79ba5bf9d28264a1a1945a8f566b9e108b9d Mon Sep 17 00:00:00 2001 From: ThorstenB Date: Tue, 1 May 2012 11:10:37 +0200 Subject: [PATCH 07/19] Improve MP dialog and add option to configure AI traffic --- Translations/de/menu.xml | 3 +- Translations/de/options.xml | 2 +- Translations/en/menu.xml | 3 +- gui/dialogs/multiplayer.xml | 68 +++++++++++++++++++++++++++++-------- gui/dialogs/scenario.xml | 30 ++++++++++------ gui/menubar.xml | 35 ++++++++----------- 6 files changed, 92 insertions(+), 49 deletions(-) diff --git a/Translations/de/menu.xml b/Translations/de/menu.xml index 8bcf5bff2..fc93df00a 100644 --- a/Translations/de/menu.xml +++ b/Translations/de/menu.xml @@ -59,10 +59,11 @@ KI + Flugverkehr und Szenarien + ATC Stationen in der Nähe Steuerung Flügelmann Steuerung Tanker Steuerung Flugzeugträger - Auswahl der KI Szenarien (Neustart notwendig) Steuerung Fluggastbrücke diff --git a/Translations/de/options.xml b/Translations/de/options.xml index d1cc453d5..a739b7012 100644 --- a/Translations/de/options.xml +++ b/Translations/de/options.xml @@ -1,6 +1,6 @@ - + diff --git a/Translations/en/menu.xml b/Translations/en/menu.xml index 215dfa733..8b6c4a0e6 100644 --- a/Translations/en/menu.xml +++ b/Translations/en/menu.xml @@ -62,10 +62,11 @@ AI + Traffic and Scenario Settings + ATC Services in Range Wingman Controls Tanker Controls Carrier Controls - Scenario Select (requires restart) Jetway Settings diff --git a/gui/dialogs/multiplayer.xml b/gui/dialogs/multiplayer.xml index ec3ee8742..2c68f7e80 100644 --- a/gui/dialogs/multiplayer.xml +++ b/gui/dialogs/multiplayer.xml @@ -51,16 +51,52 @@ + table center + - 00 + 0 + 0 + + right + + + 0 + 1 + 2 + left + hide-replay + + /sim/multiplay/freeze-on-replay + + dialog-apply + hide-replay + + + + + 1 + 1 + 2 + left + ai-traffic + + /sim/traffic-manager/enabled + + dialog-apply + ai-traffic + + + + + 20 right - 01 + 21 left /sim/multiplay/callsign @@ -69,19 +105,16 @@ + - 02 - left - - - - 10 + 30 right host - 11 + left + 31 2 350 /sim/multiplay/selected-server @@ -99,22 +132,23 @@ mpserver12.flightgear.org (Amsterdam, Netherlands) mpserver13.flightgear.org (Grenoble, France) - + + /sim/multiplay/online - 3 + 5 1 left - + - + /sim/multiplay/online - 3 + 5 1 left @@ -123,7 +157,8 @@ true - + + hbox @@ -160,6 +195,7 @@ mp + + +