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/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-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..a39040583 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.rgb = 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/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 + + +