diff --git a/Aircraft/Instruments-3d/garmin196/README b/Aircraft/Instruments-3d/garmin196/README old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/airports_atis.xml b/Aircraft/Instruments-3d/garmin196/airports_atis.xml old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/cities.xml b/Aircraft/Instruments-3d/garmin196/cities.xml old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/coque.png b/Aircraft/Instruments-3d/garmin196/coque.png old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/description.jpg b/Aircraft/Instruments-3d/garmin196/doc/description.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/doc-en.htm b/Aircraft/Instruments-3d/garmin196/doc/doc-en.htm old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/doc-fr.htm b/Aircraft/Instruments-3d/garmin196/doc/doc-fr.htm old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/dto_aviation_01.jpg b/Aircraft/Instruments-3d/garmin196/doc/dto_aviation_01.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/dto_aviation_02.jpg b/Aircraft/Instruments-3d/garmin196/doc/dto_aviation_02.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/dto_aviation_03.jpg b/Aircraft/Instruments-3d/garmin196/doc/dto_aviation_03.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/dto_aviation_04.jpg b/Aircraft/Instruments-3d/garmin196/doc/dto_aviation_04.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/dto_recent_01.jpg b/Aircraft/Instruments-3d/garmin196/doc/dto_recent_01.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/dto_user_01.jpg b/Aircraft/Instruments-3d/garmin196/doc/dto_user_01.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/eteint.jpg b/Aircraft/Instruments-3d/garmin196/doc/eteint.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/garmin196.jpg b/Aircraft/Instruments-3d/garmin196/doc/garmin196.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/luminosite.jpg b/Aircraft/Instruments-3d/garmin196/doc/luminosite.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/mappage.jpg b/Aircraft/Instruments-3d/garmin196/doc/mappage.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/menu_aircraft_01.jpg b/Aircraft/Instruments-3d/garmin196/doc/menu_aircraft_01.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/menu_aircraft_02.jpg b/Aircraft/Instruments-3d/garmin196/doc/menu_aircraft_02.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/menu_e6b.jpg b/Aircraft/Instruments-3d/garmin196/doc/menu_e6b.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/menu_flights_01.jpg b/Aircraft/Instruments-3d/garmin196/doc/menu_flights_01.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/menu_flights_02.jpg b/Aircraft/Instruments-3d/garmin196/doc/menu_flights_02.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/menu_gps.jpg b/Aircraft/Instruments-3d/garmin196/doc/menu_gps.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/menu_map.jpg b/Aircraft/Instruments-3d/garmin196/doc/menu_map.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/menu_points_01.jpg b/Aircraft/Instruments-3d/garmin196/doc/menu_points_01.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/menu_points_02.jpg b/Aircraft/Instruments-3d/garmin196/doc/menu_points_02.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/menu_routes_01.jpg b/Aircraft/Instruments-3d/garmin196/doc/menu_routes_01.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/menu_routes_01_bis.jpg b/Aircraft/Instruments-3d/garmin196/doc/menu_routes_01_bis.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/menu_routes_02.jpg b/Aircraft/Instruments-3d/garmin196/doc/menu_routes_02.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/menu_routes_02_bis.jpg b/Aircraft/Instruments-3d/garmin196/doc/menu_routes_02_bis.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/menu_routes_03.jpg b/Aircraft/Instruments-3d/garmin196/doc/menu_routes_03.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/menu_routes_04.jpg b/Aircraft/Instruments-3d/garmin196/doc/menu_routes_04.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/menu_setup_01.jpg b/Aircraft/Instruments-3d/garmin196/doc/menu_setup_01.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/menu_setup_02.jpg b/Aircraft/Instruments-3d/garmin196/doc/menu_setup_02.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/nrst_airport_01.jpg b/Aircraft/Instruments-3d/garmin196/doc/nrst_airport_01.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/panelpage.jpg b/Aircraft/Instruments-3d/garmin196/doc/panelpage.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/positionpage.jpg b/Aircraft/Instruments-3d/garmin196/doc/positionpage.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/doc/startup.jpg b/Aircraft/Instruments-3d/garmin196/doc/startup.jpg old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/garmin196.ac b/Aircraft/Instruments-3d/garmin196/garmin196.ac old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/garmin196.nas b/Aircraft/Instruments-3d/garmin196/garmin196.nas old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/garmin196.xml b/Aircraft/Instruments-3d/garmin196/garmin196.xml old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/garmin196_dto_display.xml b/Aircraft/Instruments-3d/garmin196/garmin196_dto_display.xml old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/garmin196_map_symbols.ac b/Aircraft/Instruments-3d/garmin196/garmin196_map_symbols.ac old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/garmin196_map_symbols.xml b/Aircraft/Instruments-3d/garmin196/garmin196_map_symbols.xml old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/garmin196_nrst_display.xml b/Aircraft/Instruments-3d/garmin196/garmin196_nrst_display.xml old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/garmin196_support1.xml b/Aircraft/Instruments-3d/garmin196/garmin196_support1.xml old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/screens.png b/Aircraft/Instruments-3d/garmin196/screens.png old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/support1.ac b/Aircraft/Instruments-3d/garmin196/support1.ac old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/support1.png b/Aircraft/Instruments-3d/garmin196/support1.png old mode 100755 new mode 100644 diff --git a/Aircraft/Instruments-3d/garmin196/symbols.png b/Aircraft/Instruments-3d/garmin196/symbols.png old mode 100755 new mode 100644 diff --git a/Docs/README.materials b/Docs/README.materials index 7a83db0c9..42ada3a5b 100644 --- a/Docs/README.materials +++ b/Docs/README.materials @@ -155,14 +155,12 @@ Random Buildings Random Buildings come in three sizes, with individual constraints. -Small buildings, which may have pitched roofs. They have different front, back and -side textures. Small buildings are never deeper than they are wide. +Small buildings. These have different textures on the sides compared to the front and back. +Small buildings are never deeper than they are wide. -Medium buildings, which have flat roofs. They have different front and side textures. -They are never taller than they are wide. +Medium buildings, which are never taller than they are wide. -Large buildings, which have flat roofs. They have different front and size textures. There -are no constraints on their width, depth or height. +Large buildings. There are no constraints on their width, depth or height. building-coverage : The coverage of random buildings in areas marked for random objects in m^2. A lower number means a higher density of buildings. A value of @@ -212,5 +210,8 @@ building-large-max-width-m : Maximum width of large buildings. (default 75) building-large-min-depth-m : Minimum depth of large buildings. (default 50) building-large-max-depth-m : Maximum depty of large buildings. (default 75) -texture : The texture used for all buildings. See Docs/buildings.png for details. +building-texture : The texture used for all buildings. See Docs/buildings.png for details. (default Texture/buildings.png) + +building-lightmap: Emissive texture for all buildings, which is faded in at night to provide +illusion of lit windows. Same texture coordinates and format at building-texture above. diff --git a/Effects/building.eff b/Effects/building.eff new file mode 100644 index 000000000..c46cf6bd7 --- /dev/null +++ b/Effects/building.eff @@ -0,0 +1,145 @@ + + + Effects/building + Effects/model-default + + + true + 2d + normalized + linear-mipmap-linear + clamp + clamp + + + true + 2d + normalized + linear-mipmap-linear + clamp + clamp + + false + + true + 1 + 0.6 0.6 0.6 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 + + + + /sim/time/sun-angle-rad + + + + + + + + + Shaders/terrain-haze.vert + Shaders/terrain-haze.frag + + + + + + + + + + Shaders/deferred-gbuffer.vert + Shaders/deferred-gbuffer.frag + Shaders/gbuffer-functions.frag + Shaders/gbuffer-encode.frag + + + + + + + + + + 1 + + + texture[1]/type + + + texture[1]/image + + + texture[1]/filter + + + texture[1]/wrap-s + + + texture[1]/wrap-t + + + + + + + Shaders/default.vert + Shaders/include_fog.frag + + Shaders/building-default.frag + + + lightmap + sampler-2d + 1 + + + sunangle + float + + sun-angle + + + + + diff --git a/Effects/landmass.eff b/Effects/landmass.eff index b4f49161d..aaa0d920e 100644 --- a/Effects/landmass.eff +++ b/Effects/landmass.eff @@ -258,7 +258,7 @@ - Shaders/include_fog.vert + Shaders/landmass-g.vert Shaders/landmass.geom Shaders/include_fog.frag @@ -457,7 +457,7 @@ - Shaders/include_fog.vert + Shaders/landmass.vert Shaders/include_fog.frag Shaders/landmass.frag diff --git a/Effects/model-combined-deferred.eff b/Effects/model-combined-deferred.eff index 3897332e2..d0121ec7a 100644 --- a/Effects/model-combined-deferred.eff +++ b/Effects/model-combined-deferred.eff @@ -53,8 +53,7 @@ the objects that use it, and replaces it with the default shader. Shaders/ubershader.vert Shaders/ubershader-gbuffer.frag Shaders/gbuffer-functions.frag - + Shaders/gbuffer-encode.frag diff --git a/Effects/model-default.eff b/Effects/model-default.eff index 6fe714462..5bc396735 100644 --- a/Effects/model-default.eff +++ b/Effects/model-default.eff @@ -119,6 +119,13 @@ float scattering + + terminator + float + + terminator + + texture sampler-2d @@ -188,6 +195,7 @@ Shaders/deferred-gbuffer.vert Shaders/deferred-gbuffer.frag Shaders/gbuffer-functions.frag + Shaders/gbuffer-encode.frag texture @@ -296,7 +304,7 @@ vertex-program-two-side - Shaders/include_fog.vert + Shaders/default.vert Shaders/include_fog.frag 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/Effects/terrain-default.eff b/Effects/terrain-default.eff index 240232f1d..10e1549e7 100644 --- a/Effects/terrain-default.eff +++ b/Effects/terrain-default.eff @@ -465,6 +465,7 @@ Shaders/deferred-gbuffer.vert Shaders/deferred-gbuffer.frag Shaders/gbuffer-functions.frag + Shaders/gbuffer-encode.frag texture diff --git a/Effects/tree.eff b/Effects/tree.eff index 18599aa5d..f3c028286 100644 --- a/Effects/tree.eff +++ b/Effects/tree.eff @@ -67,6 +67,8 @@ Shaders/deferred-tree.vert Shaders/deferred-tree.frag + Shaders/gbuffer-functions.frag + Shaders/gbuffer-encode.frag texture @@ -161,7 +163,7 @@ - + true @@ -194,7 +196,7 @@ clamp - Shaders/include_fog.vert + Shaders/tree.vert Shaders/include_fog.frag Shaders/tree.frag diff --git a/Effects/urban.eff b/Effects/urban.eff index 4ed75d233..d0bbbbdb7 100644 --- a/Effects/urban.eff +++ b/Effects/urban.eff @@ -159,6 +159,7 @@ Shaders/urban-gbuffer.vert Shaders/urban-gbuffer.frag Shaders/gbuffer-functions.frag + Shaders/gbuffer-encode.frag tangent 6 @@ -323,6 +324,7 @@ Shaders/urban-gbuffer.vert Shaders/urban-gbuffer.frag Shaders/gbuffer-functions.frag + Shaders/gbuffer-encode.frag tangent 6 @@ -735,7 +737,7 @@ noise - Shaders/include_fog.vert + Shaders/urban.vert Shaders/include_fog.frag Shaders/urban.frag diff --git a/Materials/default/materials.xml b/Materials/default/materials.xml index aba566e06..129ff8105 100644 --- a/Materials/default/materials.xml +++ b/Materials/default/materials.xml @@ -2195,6 +2195,16 @@ + + signcase + Signs/signs_case.png + + 0.1 + 0.1 + 0.1 + + cover 0.00000 0.625 + YellowSign.unlighted diff --git a/Nasal/view.nas b/Nasal/view.nas index bbfe8834b..6af58faa2 100644 --- a/Nasal/view.nas +++ b/Nasal/view.nas @@ -292,6 +292,8 @@ var fly_by_view_handler = { } else { # use actual distance dist = me.last.distance_to(pos); + # reset when too far (i.e. position changed due to skipping time in replay mode) + if (dist>5000) return me.reset(); } # check if the aircraft has moved enough diff --git a/Shaders/building-default.frag b/Shaders/building-default.frag new file mode 100644 index 000000000..2e9c15345 --- /dev/null +++ b/Shaders/building-default.frag @@ -0,0 +1,63 @@ +// -*-C++-*- + +// Ambient term comes in gl_Color.rgb. +#version 120 + +varying vec4 diffuse_term; +varying vec3 normal; + +uniform sampler2D texture; +uniform sampler2D lightmap; +uniform float sunangle; + +////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); +} + +void main() +{ + vec3 n; + float NdotL, NdotHV, fogFactor; + vec4 color = gl_Color; + vec3 lightDir = gl_LightSource[0].position.xyz; + vec3 halfVector = gl_LightSource[0].halfVector.xyz; + vec4 texel; + vec4 emissive; + vec4 fragColor; + vec4 specular = vec4(0.0); + + // If gl_Color.a == 0, this is a back-facing polygon and the + // normal should be reversed. + n = (2.0 * gl_Color.a - 1.0) * normal; + n = normalize(n); + + NdotL = dot(n, lightDir); + if (NdotL > 0.0) { + color += diffuse_term * NdotL; + NdotHV = max(dot(n, halfVector), 0.0); + if (gl_FrontMaterial.shininess > 0.0) + specular.rgb = (gl_FrontMaterial.specular.rgb + * gl_LightSource[0].specular.rgb + * pow(NdotHV, gl_FrontMaterial.shininess)); + } + color.a = diffuse_term.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. + color = clamp(color, 0.0, 1.0); + texel = texture2D(texture, gl_TexCoord[0].st); + emissive = texture2D(lightmap, gl_TexCoord[0].st); + + // The lights are only switched on when the sun is below the horizon + fragColor = color * texel + specular + smoothstep(1.6, 1.8, sunangle) * emissive; + fragColor.rgb = fog_Func(fragColor.rgb, fogType); + + gl_FragColor = fragColor; +} 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/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; } 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-encode.frag b/Shaders/gbuffer-encode.frag new file mode 100644 index 000000000..a3ced2d89 --- /dev/null +++ b/Shaders/gbuffer-encode.frag @@ -0,0 +1,24 @@ +// -*- mode: C; -*- +// Licence: GPL v2 +// Author: Frederic Bouvier. + +uniform bool fg_DepthInColor; + +vec2 normal_encode(vec3 n); +vec3 float_to_color(in float f); + +// 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 ); + vec3 dcol = vec3(1.0, 1.0, 1.0); + if (fg_DepthInColor) + dcol = float_to_color(depth); + gl_FragData[3] = vec4(dcol, 1.0); +} diff --git a/Shaders/gbuffer-functions.frag b/Shaders/gbuffer-functions.frag index 5b8addee6..2c057a4eb 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,46 @@ 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 ); } 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-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..e6d38deb7 --- /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, vec2 coords, sampler2D depth_tex ); +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, coords, depth_tex ); + + 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]; +} 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..905fd40c2 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; @@ -76,7 +76,8 @@ void main (void) //vec3 ambient = fg_SunAmbientColor.rgb; vec3 N; vec3 dotN; - float emission = dot( gl_FrontLightModelProduct.sceneColor.rgb + gl_FrontMaterial.emission , vec3( 0.3, 0.59, 0.11 ) ); + float emission = dot( gl_FrontLightModelProduct.sceneColor.rgb + gl_FrontMaterial.emission, + vec3( 0.3, 0.59, 0.11 ) ); float pf; ///BEGIN bump @@ -108,9 +109,9 @@ void main (void) reflFactor = reflmap.a + transparency_offset; } else if (nmap_enabled > 0) { // set the reflectivity proportional to shininess with user input - reflFactor = (gl_FrontMaterial.shininess / 128.0) * nmap.a + transparency_offset; + reflFactor = gl_FrontMaterial.shininess * 0.0078125 * nmap.a + transparency_offset; } else { - reflFactor = gl_FrontMaterial.shininess/128.0 + transparency_offset; + reflFactor = gl_FrontMaterial.shininess * 0.0078125 + transparency_offset; } reflFactor = clamp(reflFactor, 0.0, 1.0); @@ -130,17 +131,16 @@ void main (void) ////////////////////////////////////////////////////////////////////// //begin DIRT ////////////////////////////////////////////////////////////////////// - if (dirt_enabled > 0.0){ - float dirtFactorR = reflmap.r * dirt_r_factor; - dirtFactorR = smoothstep(0.0, 1.0, dirtFactorR); - mixedcolor.rgb = mix(mixedcolor.rgb, dirt_r_color, dirtFactorR); + if (dirt_enabled > 0.0){ + vec3 dirtFactorIn = vec3 (dirt_r_factor, dirt_g_factor, dirt_b_factor); + vec3 dirtFactor = reflmap.rgb * dirtFactorIn.rgb; + //dirtFactor.r = smoothstep(0.0, 1.0, dirtFactor.r); + mixedcolor.rgb = mix(mixedcolor.rgb, dirt_r_color, smoothstep(0.0, 1.0, dirtFactor.r)); if (dirt_multi > 0) { - float dirtFactorG = reflmap.g * dirt_g_factor; - float dirtFactorB = reflmap.b * dirt_b_factor; - dirtFactorG = smoothstep(0.0, 1.0, dirtFactorG); - dirtFactorB = smoothstep(0.0, 1.0, dirtFactorB); - mixedcolor.rgb = mix(mixedcolor.rgb, dirt_g_color, dirtFactorG); - mixedcolor.rgb = mix(mixedcolor.rgb, dirt_b_color, dirtFactorB); + //dirtFactor.g = smoothstep(0.0, 1.0, dirtFactor.g); + //dirtFactor.b = smoothstep(0.0, 1.0, dirtFactor.b); + mixedcolor.rgb = mix(mixedcolor.rgb, dirt_g_color, smoothstep(0.0, 1.0, dirtFactor.g)); + mixedcolor.rgb = mix(mixedcolor.rgb, dirt_b_color, smoothstep(0.0, 1.0, dirtFactor.b)); } } ////////////////////////////////////////////////////////////////////// @@ -162,25 +162,27 @@ void main (void) ////////////////////////////////////////////////////////////////////// if ( lightmap_enabled >= 1 ) { vec3 lightmapcolor; + vec4 lightmapFactor = vec4(lightmap_r_factor, lightmap_g_factor, lightmap_b_factor, lightmap_a_factor); + lightmapFactor = lightmapFactor * lightmapTexel; if (lightmap_multi >0 ){ - lightmapcolor = lightmap_r_color * lightmap_r_factor * lightmapTexel.r + - lightmap_g_color * lightmap_g_factor * lightmapTexel.g + - lightmap_b_color * lightmap_b_factor * lightmapTexel.b + - lightmap_a_color * lightmap_a_factor * lightmapTexel.a ; - emission = max(max(lightmap_r_factor * lightmapTexel.r, lightmap_g_factor * lightmapTexel.g),max( lightmap_b_factor * lightmapTexel.b, lightmap_a_factor * lightmapTexel.a)); + lightmapcolor = lightmap_r_color * lightmapFactor.r + + lightmap_g_color * lightmapFactor.g + + lightmap_b_color * lightmapFactor.b + + lightmap_a_color * lightmapFactor.a ; + emission = max(max(lightmapFactor.r * lightmapTexel.r, lightmapFactor.g * lightmapTexel.g), + max( lightmapFactor.b * lightmapTexel.b, lightmapFactor.a * lightmapTexel.a)); } else { - lightmapcolor = lightmapTexel.r * lightmap_r_color * lightmap_r_factor; - emission = lightmapTexel.r * lightmap_r_factor; + lightmapcolor = lightmapTexel.rgb * lightmap_r_color * lightmapFactor.r; + emission = lightmapTexel.r * lightmapFactor.r; } //fragColor.rgb = max(fragColor.rgb, lightmapcolor * gl_FrontMaterial.diffuse.rgb * mixedcolor); emission = length(lightmapcolor); - fragColor.rgb = max(fragColor.rgb * (1.0 - emission), lightmapcolor * gl_FrontMaterial.diffuse.rgb * mixedcolor); + fragColor.rgb = max(fragColor.rgb * (1.0 - emission), + lightmapcolor * gl_FrontMaterial.diffuse.rgb * mixedcolor); } ////////////////////////////////////////////////////////////////////// // 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/ubershader.frag b/Shaders/ubershader.frag index cf9bbc0e2..206615a5a 100644 --- a/Shaders/ubershader.frag +++ b/Shaders/ubershader.frag @@ -78,7 +78,7 @@ void main (void) N = nmap.rgb * 2.0 - 1.0; N = normalize(N.x * VTangent + N.y * VBinormal + N.z * VNormal); if (nmap_dds > 0) - N = -N; + N = -N; } else { N = normalize(VNormal); } @@ -92,7 +92,8 @@ void main (void) float nDotVP = max(0.0, dot(N, normalize(gl_LightSource[0].position.xyz))); float nDotHV = max(0.0, dot(N, normalize(gl_LightSource[0].halfVector.xyz))); //glare on the backside of tranparent objects - if ((gl_FrontMaterial.diffuse.a < 1.0 || texel.a < 1.0) && dot(N, normalize(gl_LightSource[0].position.xyz)) < 0.0) { + if ((gl_FrontMaterial.diffuse.a < 1.0 || texel.a < 1.0) + && dot(N, normalize(gl_LightSource[0].position.xyz)) < 0.0) { nDotVP = max(0.0, dot(-N, normalize(gl_LightSource[0].position.xyz))); nDotHV = max(0.0, dot(-N, normalize(gl_LightSource[0].halfVector.xyz))); } @@ -122,9 +123,9 @@ void main (void) reflFactor = reflmap.a + transparency_offset; } else if (nmap_enabled > 0 && shader_qual > 2) { // set the reflectivity proportional to shininess with user input - reflFactor = (gl_FrontMaterial.shininess / 128.0) * nmap.a + transparency_offset; + reflFactor = gl_FrontMaterial.shininess * 0.0078125 * nmap.a + transparency_offset; } else { - reflFactor = gl_FrontMaterial.shininess/128.0 + transparency_offset; + reflFactor = gl_FrontMaterial.shininess* 0.0078125 + transparency_offset; } reflFactor = clamp(reflFactor, 0.0, 1.0); @@ -148,16 +149,15 @@ void main (void) //begin DIRT ////////////////////////////////////////////////////////////////////// if (dirt_enabled > 0.0){ - float dirtFactorR = reflmap.r * dirt_r_factor; - dirtFactorR = smoothstep(0.0, 1.0, dirtFactorR); - mixedcolor.rgb = mix(mixedcolor.rgb, dirt_r_color, dirtFactorR); + vec3 dirtFactorIn = vec3 (dirt_r_factor, dirt_g_factor, dirt_b_factor); + vec3 dirtFactor = reflmap.rgb * dirtFactorIn.rgb; + //dirtFactor.r = smoothstep(0.0, 1.0, dirtFactor.r); + mixedcolor.rgb = mix(mixedcolor.rgb, dirt_r_color, smoothstep(0.0, 1.0, dirtFactor.r)); if (dirt_multi > 0) { - float dirtFactorG = reflmap.g * dirt_g_factor; - float dirtFactorB = reflmap.b * dirt_b_factor; - dirtFactorG = smoothstep(0.0, 1.0, dirtFactorG); - dirtFactorB = smoothstep(0.0, 1.0, dirtFactorB); - mixedcolor.rgb = mix(mixedcolor.rgb, dirt_g_color, dirtFactorG); - mixedcolor.rgb = mix(mixedcolor.rgb, dirt_b_color, dirtFactorB); + //dirtFactor.g = smoothstep(0.0, 1.0, dirtFactor.g); + //dirtFactor.b = smoothstep(0.0, 1.0, dirtFactor.b); + mixedcolor.rgb = mix(mixedcolor.rgb, dirt_g_color, smoothstep(0.0, 1.0, dirtFactor.g)); + mixedcolor.rgb = mix(mixedcolor.rgb, dirt_b_color, smoothstep(0.0, 1.0, dirtFactor.b)); } } ////////////////////////////////////////////////////////////////////// @@ -167,7 +167,8 @@ void main (void) // set ambient adjustment to remove bluiness with user input float ambient_offset = clamp(amb_correction, -1.0, 1.0); - vec4 ambient_Correction = vec4(gl_LightSource[0].ambient.rg, gl_LightSource[0].ambient.b * 0.6, 0.5) * ambient_offset ; + vec4 ambient_Correction = vec4(gl_LightSource[0].ambient.rg, gl_LightSource[0].ambient.b * 0.6, 0.5) + * ambient_offset ; ambient_Correction = clamp(ambient_Correction, -1.0, 1.0); color.a = texel.a * alpha; @@ -182,13 +183,16 @@ void main (void) ////////////////////////////////////////////////////////////////////// if ( lightmap_enabled >= 1 ) { vec3 lightmapcolor; + vec4 lightmapFactor = vec4(lightmap_r_factor, lightmap_g_factor, + lightmap_b_factor, lightmap_a_factor); + lightmapFactor = lightmapFactor * lightmapTexel; if (lightmap_multi >0 ){ - lightmapcolor = lightmap_r_color * lightmap_r_factor * lightmapTexel.r + - lightmap_g_color * lightmap_g_factor * lightmapTexel.g + - lightmap_b_color * lightmap_b_factor * lightmapTexel.b + - lightmap_a_color * lightmap_a_factor * lightmapTexel.a ; + lightmapcolor = lightmap_r_color * lightmapFactor.r + + lightmap_g_color * lightmapFactor.g + + lightmap_b_color * lightmapFactor.b + + lightmap_a_color * lightmapFactor.a ; } else { - lightmapcolor = lightmapTexel.rgb * lightmap_r_color * lightmap_r_factor; + lightmapcolor = lightmapTexel.rgb * lightmap_r_color * lightmapFactor.r; } fragColor.rgb = max(fragColor.rgb, lightmapcolor * gl_FrontMaterial.diffuse.rgb * mixedcolor); } diff --git a/Shaders/ubershader.vert b/Shaders/ubershader.vert index 2329b9059..b20c211fc 100644 --- a/Shaders/ubershader.vert +++ b/Shaders/ubershader.vert @@ -30,7 +30,7 @@ uniform int rembrandt_enabled; void rotationMatrixPR(in float sinRx, in float cosRx, in float sinRy, in float cosRy, out mat4 rotmat) { - rotmat = mat4( cosRy , sinRx * sinRy, cosRx * sinRy , 0.0, + rotmat = mat4( cosRy , sinRx * sinRy , cosRx * sinRy, 0.0, 0.0 , cosRx , -sinRx * cosRx, 0.0, -sinRy, sinRx * cosRy, cosRx * cosRy , 0.0, 0.0 , 0.0 , 0.0 , 1.0 ); @@ -39,9 +39,9 @@ void rotationMatrixPR(in float sinRx, in float cosRx, in float sinRy, in float c void rotationMatrixH(in float sinRz, in float cosRz, out mat4 rotmat) { rotmat = mat4( cosRz, -sinRz, 0.0, 0.0, - sinRz, cosRz , 0.0, 0.0, - 0.0 , 0.0 , 1.0, 0.0, - 0.0 , 0.0 , 0.0, 1.0 ); + sinRz, cosRz, 0.0, 0.0, + 0.0 , 0.0 , 1.0, 0.0, + 0.0 , 0.0 , 0.0, 1.0 ); } void main(void) @@ -103,7 +103,8 @@ void main(void) } if(rembrandt_enabled < 1){ - gl_FrontColor = gl_FrontMaterial.emission + gl_Color * (gl_LightModel.ambient + gl_LightSource[0].ambient); + gl_FrontColor = gl_FrontMaterial.emission + gl_Color + * (gl_LightModel.ambient + gl_LightSource[0].ambient); } else { gl_FrontColor = gl_Color; } 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/Textures/Signs/signs_case.png b/Textures/Signs/signs_case.png new file mode 100644 index 000000000..6b4746f83 Binary files /dev/null and b/Textures/Signs/signs_case.png differ diff --git a/Textures/buildings-lightmap.png b/Textures/buildings-lightmap.png new file mode 100644 index 000000000..fbf3bd250 Binary files /dev/null and b/Textures/buildings-lightmap.png differ 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 + + +