1
0
Fork 0

Merge branch 'master' of git://gitorious.org/fg/fgdata

This commit is contained in:
BARANGER Emmanuel 2012-05-01 21:40:34 +02:00
commit 4182174502
23 changed files with 276 additions and 160 deletions

View file

@ -67,6 +67,7 @@
<program> <program>
<vertex-shader>Shaders/deferred-tree.vert</vertex-shader> <vertex-shader>Shaders/deferred-tree.vert</vertex-shader>
<fragment-shader>Shaders/deferred-tree.frag</fragment-shader> <fragment-shader>Shaders/deferred-tree.frag</fragment-shader>
<fragment-shader>Shaders/gbuffer-functions.frag</fragment-shader>
</program> </program>
<uniform> <uniform>
<name>texture</name> <name>texture</name>

View file

@ -1,15 +1,15 @@
#extension GL_EXT_gpu_shader4 : enable #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 vec3 ecNormal;
varying float alpha; varying float alpha;
uniform int materialID; uniform int materialID;
uniform sampler2D texture; 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() { void main() {
vec4 texel = texture2D(texture, gl_TexCoord[0].st); vec4 texel = texture2D(texture, gl_TexCoord[0].st);
@ -20,7 +20,5 @@ void main() {
float emission = dot( gl_FrontLightModelProduct.sceneColor.rgb, vec3( 0.3, 0.59, 0.11 ) ); 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 ); vec3 normal2 = normalize( (2.0 * gl_Color.a - 1.0) * ecNormal );
gl_FragData[0] = vec4( normal_encode(normal2), 0.0, 1.0 ); encode_gbuffer(normal2, gl_Color.rgb * texel.rgb, materialID, specular, shininess, emission, gl_FragCoord.z);
gl_FragData[1] = vec4( gl_Color.rgb * texel.rgb, float( materialID ) / 255.0 );
gl_FragData[2] = vec4( specular, shininess / 128.0, emission, 1.0 );
} }

View file

@ -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 vec3 ecNormal;
varying float alpha; varying float alpha;
void main() { void main() {

View file

@ -6,6 +6,7 @@
// //
uniform int materialID; uniform int materialID;
uniform sampler2D texture; uniform sampler2D texture;
void encode_gbuffer(vec3 normal, vec3 color, int mId, float specular, float shininess, float emission, float depth);
void main() { void main() {
vec4 texel = texture2D(texture, gl_TexCoord[0].st); vec4 texel = texture2D(texture, gl_TexCoord[0].st);
if (texel.a < 0.1) if (texel.a < 0.1)
@ -14,9 +15,6 @@ void main() {
float shininess = 0.1; float shininess = 0.1;
float emission = 0.0; float emission = 0.0;
// Normal is straight towards the viewer. // Normal is straight towards the viewer. (FB: Are they really billboards ? )
vec3 normal2 = vec3(0.0, 0.0, 0.0); encode_gbuffer(vec3(0.5, 0.5, 0.0), gl_Color.rgb * texel.rgb, materialID, specular, shininess, emission, gl_FragCoord.z);
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 );
} }

View file

@ -7,6 +7,7 @@ uniform sampler2D lighting_tex;
//uniform sampler2D ao_tex; //uniform sampler2D ao_tex;
uniform float exposure; uniform float exposure;
uniform bool showBuffers; uniform bool showBuffers;
uniform bool fg_DepthInColor;
vec3 HDR(vec3 L) { vec3 HDR(vec3 L) {
L = L * exposure; L = L * exposure;
@ -26,8 +27,8 @@ void main() {
color = texture2D( specular_tex, (coords - vec2( 0.8, 0.8 )) * 5.0 ); color = texture2D( specular_tex, (coords - vec2( 0.8, 0.8 )) * 5.0 );
} else if (coords.x >= 0.8 && coords.y < 0.2) { } else if (coords.x >= 0.8 && coords.y < 0.2) {
color = texture2D( color_tex, (coords - vec2( 0.8, 0.0 )) * 5.0 ); color = texture2D( color_tex, (coords - vec2( 0.8, 0.0 )) * 5.0 );
// } else if (coords.x < 0.2 && coords.y >= 0.8) { } else if (coords.x < 0.2 && coords.y >= 0.8 && fg_DepthInColor) {
// color = texture2D( ao_tex, (coords - vec2( 0.0, 0.8 )) * 5.0 ); color = texture2D( depth_tex, (coords - vec2( 0.0, 0.8 )) * 5.0 );
} else { } else {
color = texture2D( lighting_tex, coords ) /* + texture2D( bloom_tex, coords ) */; color = texture2D( lighting_tex, coords ) /* + texture2D( bloom_tex, coords ) */;
//color = vec4( HDR( color.rgb ), 1.0 ); //color = vec4( HDR( color.rgb ), 1.0 );

View file

@ -7,7 +7,7 @@ uniform float fg_FogDensity;
uniform vec3 fg_Planes; uniform vec3 fg_Planes;
varying vec3 ray; varying vec3 ray;
vec3 position( vec3 viewdir, float depth ); vec3 position( vec3 viewDir, vec2 coords, sampler2D depth_tex );
void main() { void main() {
vec2 coords = gl_TexCoord[0].xy; vec2 coords = gl_TexCoord[0].xy;
@ -15,11 +15,7 @@ void main() {
if ( initialized < 0.1 ) if ( initialized < 0.1 )
discard; discard;
vec3 normal; vec3 normal;
normal.xy = texture2D( normal_tex, coords ).rg * 2.0 - vec2(1.0,1.0); vec3 pos = position( normalize(ray), coords, depth_tex );
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 );
float fogFactor = 0.0; float fogFactor = 0.0;
const float LOG2 = 1.442695; const float LOG2 = 1.442695;

View file

@ -1,4 +1,9 @@
// -*- mode: C; -*-
// Licence: GPL v2
// Author: Frederic Bouvier.
uniform vec3 fg_Planes; uniform vec3 fg_Planes;
uniform bool fg_DepthInColor;
// normal compression functions from // normal compression functions from
// http://aras-p.info/texts/CompactNormalStorage.html#method04spheremap // http://aras-p.info/texts/CompactNormalStorage.html#method04spheremap
@ -19,6 +24,27 @@ vec3 normal_decode(vec2 enc)
return n; 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 position( vec3 viewDir, float depth )
{ {
vec3 pos; vec3 pos;
@ -26,3 +52,32 @@ vec3 position( vec3 viewDir, float depth )
pos.xy = viewDir.xy / viewDir.z * pos.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);
}

View file

@ -15,7 +15,7 @@ uniform float Far;
varying vec4 ecPosition; varying vec4 ecPosition;
vec3 position( vec3 viewdir, float depth ); vec3 position( vec3 viewDir, vec2 coords, sampler2D depth_tex );
vec3 normal_decode(vec2 enc); vec3 normal_decode(vec2 enc);
void main() { void main() {
@ -27,7 +27,7 @@ void main() {
vec3 normal = normal_decode(texture2D( normal_tex, coords ).rg); vec3 normal = normal_decode(texture2D( normal_tex, coords ).rg);
vec4 spec_emis = texture2D( spec_emis_tex, coords ); 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 if ( pos.z < ecPos3.z ) // Negative direction in z
discard; // Don't light surface outside the light volume discard; // Don't light surface outside the light volume

View file

@ -19,7 +19,7 @@ uniform float Far;
varying vec4 ecPosition; varying vec4 ecPosition;
vec3 position( vec3 viewdir, float depth ); vec3 position( vec3 viewDir, vec2 coords, sampler2D depth_tex );
vec3 normal_decode(vec2 enc); vec3 normal_decode(vec2 enc);
void main() { void main() {
@ -31,7 +31,7 @@ void main() {
vec3 normal = normal_decode(texture2D( normal_tex, coords ).rg); vec3 normal = normal_decode(texture2D( normal_tex, coords ).rg);
vec4 spec_emis = texture2D( spec_emis_tex, coords ); 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 if ( pos.z < ecPos3.z ) // Negative direction in z
discard; // Don't light surface outside the light volume discard; // Don't light surface outside the light volume

View file

@ -12,7 +12,7 @@ uniform int fg_ShadowNumber;
uniform vec4 fg_ShadowDistances; uniform vec4 fg_ShadowDistances;
varying vec3 ray; varying vec3 ray;
vec3 position( vec3 viewdir, float depth ); vec3 position( vec3 viewDir, vec2 coords, sampler2D depth_tex );
vec3 normal_decode(vec2 enc); vec3 normal_decode(vec2 enc);
vec4 DynamicShadow( in vec4 ecPosition, out vec4 tint ) vec4 DynamicShadow( in vec4 ecPosition, out vec4 tint )
@ -57,7 +57,7 @@ void main() {
float len = length(normal); float len = length(normal);
normal /= len; normal /= len;
vec3 viewDir = normalize(ray); vec3 viewDir = normalize(ray);
vec3 pos = position( viewDir, texture2D( depth_tex, coords ).r ); vec3 pos = position( viewDir, coords, depth_tex );
vec4 tint; vec4 tint;
float shadow = shadow2DProj( shadow_tex, DynamicShadow( vec4( pos, 1.0 ), tint ) ).r; float shadow = shadow2DProj( shadow_tex, DynamicShadow( vec4( pos, 1.0 ), tint ) ).r;

View file

@ -17,7 +17,7 @@ varying vec4 eyePlaneT;
varying vec4 eyePlaneR; varying vec4 eyePlaneR;
varying vec4 eyePlaneQ; varying vec4 eyePlaneQ;
vec3 position( vec3 viewdir, float depth ); vec3 position( vec3 viewDir, vec2 coords, sampler2D depth_tex );
vec3 normal_decode(vec2 enc); vec3 normal_decode(vec2 enc);
vec4 DynamicShadow( in vec4 ecPosition, out vec4 tint ) vec4 DynamicShadow( in vec4 ecPosition, out vec4 tint )
@ -43,7 +43,7 @@ void main() {
float len = length(normal); float len = length(normal);
normal /= len; normal /= len;
vec3 viewDir = normalize(ray); vec3 viewDir = normalize(ray);
vec3 pos = position( viewDir, texture2D( depth_tex, coords ).r ); vec3 pos = position( viewDir, coords, depth_tex );
vec4 tint; vec4 tint;
float shadow; float shadow;

View file

@ -14,7 +14,7 @@ uniform vec4 fg_ShadowDistances;
uniform int filtering; uniform int filtering;
varying vec3 ray; varying vec3 ray;
vec3 position( vec3 viewdir, float depth ); vec3 position( vec3 viewDir, vec2 coords, sampler2D depth_tex );
vec3 normal_decode(vec2 enc); vec3 normal_decode(vec2 enc);
vec4 DynamicShadow( in vec4 ecPosition, out vec4 tint ) vec4 DynamicShadow( in vec4 ecPosition, out vec4 tint )
@ -59,7 +59,7 @@ void main() {
float len = length(normal); float len = length(normal);
normal /= len; normal /= len;
vec3 viewDir = normalize(ray); vec3 viewDir = normalize(ray);
vec3 pos = position( viewDir, texture2D( depth_tex, coords ).r ); vec3 pos = position( viewDir, coords, depth_tex );
vec4 tint; vec4 tint;
float shadow = 0.0; float shadow = 0.0;

View file

@ -56,7 +56,7 @@ uniform vec3 dirt_g_color;
uniform vec3 dirt_b_color; uniform vec3 dirt_b_color;
//uniform vec4 fg_SunAmbientColor; //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////////////////////// ///fog include//////////////////////
uniform int fogType; uniform int fogType;
@ -76,7 +76,8 @@ void main (void)
//vec3 ambient = fg_SunAmbientColor.rgb; //vec3 ambient = fg_SunAmbientColor.rgb;
vec3 N; vec3 N;
vec3 dotN; 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; float pf;
///BEGIN bump ///BEGIN bump
@ -108,9 +109,9 @@ void main (void)
reflFactor = reflmap.a + transparency_offset; reflFactor = reflmap.a + transparency_offset;
} else if (nmap_enabled > 0) { } else if (nmap_enabled > 0) {
// set the reflectivity proportional to shininess with user input // 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 { } else {
reflFactor = gl_FrontMaterial.shininess/128.0 + transparency_offset; reflFactor = gl_FrontMaterial.shininess * 0.0078125 + transparency_offset;
} }
reflFactor = clamp(reflFactor, 0.0, 1.0); reflFactor = clamp(reflFactor, 0.0, 1.0);
@ -131,16 +132,15 @@ void main (void)
//begin DIRT //begin DIRT
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
if (dirt_enabled > 0.0){ if (dirt_enabled > 0.0){
float dirtFactorR = reflmap.r * dirt_r_factor; vec3 dirtFactorIn = vec3 (dirt_r_factor, dirt_g_factor, dirt_b_factor);
dirtFactorR = smoothstep(0.0, 1.0, dirtFactorR); vec3 dirtFactor.rgb = reflmap.rgb * dirtFactorIn.rgb;
mixedcolor.rgb = mix(mixedcolor.rgb, dirt_r_color, dirtFactorR); //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) { if (dirt_multi > 0) {
float dirtFactorG = reflmap.g * dirt_g_factor; //dirtFactor.g = smoothstep(0.0, 1.0, dirtFactor.g);
float dirtFactorB = reflmap.b * dirt_b_factor; //dirtFactor.b = smoothstep(0.0, 1.0, dirtFactor.b);
dirtFactorG = smoothstep(0.0, 1.0, dirtFactorG); mixedcolor.rgb = mix(mixedcolor.rgb, dirt_g_color, smoothstep(0.0, 1.0, dirtFactor.g));
dirtFactorB = smoothstep(0.0, 1.0, dirtFactorB); mixedcolor.rgb = mix(mixedcolor.rgb, dirt_b_color, smoothstep(0.0, 1.0, dirtFactor.b));
mixedcolor.rgb = mix(mixedcolor.rgb, dirt_g_color, dirtFactorG);
mixedcolor.rgb = mix(mixedcolor.rgb, dirt_b_color, dirtFactorB);
} }
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -162,25 +162,27 @@ void main (void)
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
if ( lightmap_enabled >= 1 ) { if ( lightmap_enabled >= 1 ) {
vec3 lightmapcolor; vec3 lightmapcolor;
vec4 lightmapFactor = vec4(lightmap_r_factor, lightmap_g_factor, lightmap_b_factor, lightmap_a_factor);
lightmapFactor = lightmapFactor * lightmapTexel;
if (lightmap_multi >0 ){ if (lightmap_multi >0 ){
lightmapcolor = lightmap_r_color * lightmap_r_factor * lightmapTexel.r + lightmapcolor = lightmap_r_color * lightmapFactor.r +
lightmap_g_color * lightmap_g_factor * lightmapTexel.g + lightmap_g_color * lightmapFactor.g +
lightmap_b_color * lightmap_b_factor * lightmapTexel.b + lightmap_b_color * lightmapFactor.b +
lightmap_a_color * lightmap_a_factor * lightmapTexel.a ; lightmap_a_color * lightmapFactor.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)); emission = max(max(lightmapFactor.r * lightmapTexel.r, lightmapFactor.g * lightmapTexel.g),
max( lightmapFactor.b * lightmapTexel.b, lightmapFactor.a * lightmapTexel.a));
} else { } else {
lightmapcolor = lightmapTexel.r * lightmap_r_color * lightmap_r_factor; lightmapcolor = lightmapTexel.rgb * lightmap_r_color * lightmapFactor.r;
emission = lightmapTexel.r * lightmap_r_factor; emission = lightmapTexel.r * lightmapFactor.r;
} }
//fragColor.rgb = max(fragColor.rgb, lightmapcolor * gl_FrontMaterial.diffuse.rgb * mixedcolor); //fragColor.rgb = max(fragColor.rgb, lightmapcolor * gl_FrontMaterial.diffuse.rgb * mixedcolor);
emission = length(lightmapcolor); 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 // END lightmap
///////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////
gl_FragData[0]=vec4(normal_encode(N), 0.0, 1.0); encode_gbuffer(N, fragColor.rgb, 1, specular, gl_FrontMaterial.shininess, emission, gl_FragCoord.z);
gl_FragData[1]=vec4(fragColor.rgb,1.0/255.0);
gl_FragData[2]=vec4(specular, gl_FrontMaterial.shininess/128.0, emission, 1.0);
} }

View file

@ -92,7 +92,8 @@ void main (void)
float nDotVP = max(0.0, dot(N, normalize(gl_LightSource[0].position.xyz))); 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))); float nDotHV = max(0.0, dot(N, normalize(gl_LightSource[0].halfVector.xyz)));
//glare on the backside of tranparent objects //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))); nDotVP = max(0.0, dot(-N, normalize(gl_LightSource[0].position.xyz)));
nDotHV = max(0.0, dot(-N, normalize(gl_LightSource[0].halfVector.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; reflFactor = reflmap.a + transparency_offset;
} else if (nmap_enabled > 0 && shader_qual > 2) { } else if (nmap_enabled > 0 && shader_qual > 2) {
// set the reflectivity proportional to shininess with user input // 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 { } else {
reflFactor = gl_FrontMaterial.shininess/128.0 + transparency_offset; reflFactor = gl_FrontMaterial.shininess* 0.0078125 + transparency_offset;
} }
reflFactor = clamp(reflFactor, 0.0, 1.0); reflFactor = clamp(reflFactor, 0.0, 1.0);
@ -148,16 +149,15 @@ void main (void)
//begin DIRT //begin DIRT
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
if (dirt_enabled > 0.0){ if (dirt_enabled > 0.0){
float dirtFactorR = reflmap.r * dirt_r_factor; vec3 dirtFactorIn = vec3 (dirt_r_factor, dirt_g_factor, dirt_b_factor);
dirtFactorR = smoothstep(0.0, 1.0, dirtFactorR); vec3 dirtFactor = reflmap.rgb * dirtFactorIn.rgb;
mixedcolor.rgb = mix(mixedcolor.rgb, dirt_r_color, dirtFactorR); //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) { if (dirt_multi > 0) {
float dirtFactorG = reflmap.g * dirt_g_factor; //dirtFactor.g = smoothstep(0.0, 1.0, dirtFactor.g);
float dirtFactorB = reflmap.b * dirt_b_factor; //dirtFactor.b = smoothstep(0.0, 1.0, dirtFactor.b);
dirtFactorG = smoothstep(0.0, 1.0, dirtFactorG); mixedcolor.rgb = mix(mixedcolor.rgb, dirt_g_color, smoothstep(0.0, 1.0, dirtFactor.g));
dirtFactorB = smoothstep(0.0, 1.0, dirtFactorB); mixedcolor.rgb = mix(mixedcolor.rgb, dirt_b_color, smoothstep(0.0, 1.0, dirtFactor.b));
mixedcolor.rgb = mix(mixedcolor.rgb, dirt_g_color, dirtFactorG);
mixedcolor.rgb = mix(mixedcolor.rgb, dirt_b_color, dirtFactorB);
} }
} }
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
@ -167,7 +167,8 @@ void main (void)
// set ambient adjustment to remove bluiness with user input // set ambient adjustment to remove bluiness with user input
float ambient_offset = clamp(amb_correction, -1.0, 1.0); 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); ambient_Correction = clamp(ambient_Correction, -1.0, 1.0);
color.a = texel.a * alpha; color.a = texel.a * alpha;
@ -182,13 +183,16 @@ void main (void)
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
if ( lightmap_enabled >= 1 ) { if ( lightmap_enabled >= 1 ) {
vec3 lightmapcolor; vec3 lightmapcolor;
vec4 lightmapFactor = vec4(lightmap_r_factor, lightmap_g_factor,
lightmap_b_factor, lightmap_a_factor);
lightmapFactor = lightmapFactor * lightmapTexel;
if (lightmap_multi >0 ){ if (lightmap_multi >0 ){
lightmapcolor = lightmap_r_color * lightmap_r_factor * lightmapTexel.r + lightmapcolor = lightmap_r_color * lightmapFactor.r +
lightmap_g_color * lightmap_g_factor * lightmapTexel.g + lightmap_g_color * lightmapFactor.g +
lightmap_b_color * lightmap_b_factor * lightmapTexel.b + lightmap_b_color * lightmapFactor.b +
lightmap_a_color * lightmap_a_factor * lightmapTexel.a ; lightmap_a_color * lightmapFactor.a ;
} else { } 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); fragColor.rgb = max(fragColor.rgb, lightmapcolor * gl_FrontMaterial.diffuse.rgb * mixedcolor);
} }

View file

@ -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) 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, 0.0 , cosRx , -sinRx * cosRx, 0.0,
-sinRy, sinRx * cosRy, cosRx * cosRy , 0.0, -sinRy, sinRx * cosRy, cosRx * cosRy , 0.0,
0.0 , 0.0 , 0.0 , 1.0 ); 0.0 , 0.0 , 0.0 , 1.0 );
@ -39,7 +39,7 @@ 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) void rotationMatrixH(in float sinRz, in float cosRz, out mat4 rotmat)
{ {
rotmat = mat4( cosRz, -sinRz, 0.0, 0.0, rotmat = mat4( cosRz, -sinRz, 0.0, 0.0,
sinRz, cosRz , 0.0, 0.0, sinRz, cosRz, 0.0, 0.0,
0.0 , 0.0 , 1.0, 0.0, 0.0 , 0.0 , 1.0, 0.0,
0.0 , 0.0 , 0.0, 1.0 ); 0.0 , 0.0 , 0.0, 1.0 );
} }
@ -103,7 +103,8 @@ void main(void)
} }
if(rembrandt_enabled < 1){ 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 { } else {
gl_FrontColor = gl_Color; gl_FrontColor = gl_Color;
} }

View file

@ -37,7 +37,7 @@ int linear_search_steps = 10;
int GlobalIterationCount = 0; int GlobalIterationCount = 0;
int gIterationCap = 64; 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) 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))); N.z = sqrt(1.0 - min(1.0,dot(N.xy, N.xy)));
float Nz = N.z; float Nz = N.z;
N = normalize(N.x * tangent + N.y * binormal + N.z * normal); 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); 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 ); 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) { if (dot(normal,-V) > 0.1) {
vec4 iproj = gl_ProjectionMatrix * p; vec4 iproj = gl_ProjectionMatrix * p;
iproj /= iproj.w; iproj /= iproj.w;
@ -226,4 +222,5 @@ void main (void)
} else { } else {
gl_FragDepth = gl_FragCoord.z; 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);
} }

View file

@ -59,10 +59,11 @@
<!-- AI menu --> <!-- AI menu -->
<ai>KI</ai> <ai>KI</ai>
<scenario>Flugverkehr und Szenarien</scenario>
<atc-in-range>ATC Stationen in der Nähe</atc-in-range>
<wingman>Steuerung Flügelmann</wingman> <wingman>Steuerung Flügelmann</wingman>
<tanker>Steuerung Tanker</tanker> <tanker>Steuerung Tanker</tanker>
<carrier>Steuerung Flugzeugträger</carrier> <carrier>Steuerung Flugzeugträger</carrier>
<scenario>Auswahl der KI Szenarien (Neustart notwendig)</scenario>
<jetway>Steuerung Fluggastbrücke</jetway> <jetway>Steuerung Fluggastbrücke</jetway>
<!-- Equipment --> <!-- Equipment -->

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1" ?> <?xml version="1.0" encoding="ISO-8859-1" ?>
<!-- FlightGear options translations for German --> <!-- FlightGear options: German language resource -->
<PropertyList> <PropertyList>
<!-- Fall back --> <!-- Fall back -->

View file

@ -62,10 +62,11 @@
<!-- AI menu --> <!-- AI menu -->
<ai>AI</ai> <ai>AI</ai>
<scenario>Traffic and Scenario Settings</scenario>
<atc-in-range>ATC Services in Range</atc-in-range>
<wingman>Wingman Controls</wingman> <wingman>Wingman Controls</wingman>
<tanker>Tanker Controls</tanker> <tanker>Tanker Controls</tanker>
<carrier>Carrier Controls</carrier> <carrier>Carrier Controls</carrier>
<scenario>Scenario Select (requires restart)</scenario>
<jetway>Jetway Settings</jetway> <jetway>Jetway Settings</jetway>
<!-- Multiplayer menu --> <!-- Multiplayer menu -->

View file

@ -51,16 +51,52 @@
</group> </group>
<hrule/> <hrule/>
<!-- main dialog area -->
<group> <group>
<layout>table</layout> <layout>table</layout>
<halign>center</halign> <halign>center</halign>
<text> <text>
<row>0</row><col>0</col> <row>0</row>
<col>0</col>
<label>Options:</label>
<halign>right</halign>
</text>
<checkbox>
<row>0</row>
<col>1</col>
<colspan>2</colspan>
<halign>left</halign>
<name>hide-replay</name>
<label>Hide replay sessions over MP (less annoying to other players)</label>
<property>/sim/multiplay/freeze-on-replay</property>
<binding>
<command>dialog-apply</command>
<object-name>hide-replay</object-name>
</binding>
</checkbox>
<checkbox>
<row>1</row>
<col>1</col>
<colspan>2</colspan>
<halign>left</halign>
<name>ai-traffic</name>
<label>Show AI Traffic (mixing MP and AI traffic may be confusing)</label>
<property>/sim/traffic-manager/enabled</property>
<binding>
<command>dialog-apply</command>
<object-name>ai-traffic</object-name>
</binding>
</checkbox>
<text>
<row>2</row><col>0</col>
<halign>right</halign> <halign>right</halign>
<label>Callsign:</label> <label>Callsign:</label>
</text> </text>
<input> <input>
<row>0</row><col>1</col> <row>2</row><col>1</col>
<halign>left</halign> <halign>left</halign>
<property>/sim/multiplay/callsign</property> <property>/sim/multiplay/callsign</property>
<enable> <enable>
@ -69,19 +105,16 @@
</not> </not>
</enable> </enable>
</input> </input>
<text> <text>
<row>0</row><col>2</col> <row>3</row><col>0</col>
<halign>left</halign>
<label>(requires reconnect)</label>
</text>
<text>
<row>1</row><col>0</col>
<halign>right</halign> <halign>right</halign>
<label>Server:</label> <label>Server:</label>
</text> </text>
<combo> <combo>
<name>host</name> <name>host</name>
<row>1</row><col>1</col> <halign>left</halign>
<row>3</row><col>1</col>
<colspan>2</colspan> <colspan>2</colspan>
<pref-width>350</pref-width> <pref-width>350</pref-width>
<property>/sim/multiplay/selected-server</property> <property>/sim/multiplay/selected-server</property>
@ -99,12 +132,13 @@
<value>mpserver12.flightgear.org (Amsterdam, Netherlands)</value> <value>mpserver12.flightgear.org (Amsterdam, Netherlands)</value>
<value>mpserver13.flightgear.org (Grenoble, France)</value> <value>mpserver13.flightgear.org (Grenoble, France)</value>
</combo> </combo>
<!-- status area --> <!-- status area -->
<text> <text>
<visible> <visible>
<not><property>/sim/multiplay/online</property></not> <not><property>/sim/multiplay/online</property></not>
</visible> </visible>
<row>3</row> <row>5</row>
<col>1</col> <col>1</col>
<halign>left</halign> <halign>left</halign>
<label>Not connected</label> <label>Not connected</label>
@ -114,7 +148,7 @@
<visible> <visible>
<property>/sim/multiplay/online</property> <property>/sim/multiplay/online</property>
</visible> </visible>
<row>3</row> <row>5</row>
<col>1</col> <col>1</col>
<halign>left</halign> <halign>left</halign>
<label>MMMMMMMMMMMMMMMMM</label> <label>MMMMMMMMMMMMMMMMM</label>
@ -124,6 +158,7 @@
</text> </text>
</group> </group>
<!-- button area -->
<hrule/> <hrule/>
<group> <group>
<layout>hbox</layout> <layout>hbox</layout>
@ -160,6 +195,7 @@
<subsystem>mp</subsystem> <subsystem>mp</subsystem>
</binding> </binding>
</button> </button>
<button> <button>
<legend>Disconnect</legend> <legend>Disconnect</legend>
<equal>true</equal> <equal>true</equal>
@ -180,6 +216,7 @@
<subsystem>mp</subsystem> <subsystem>mp</subsystem>
</binding> </binding>
</button> </button>
<button> <button>
<row>1</row><col>2</col> <row>1</row><col>2</col>
<legend>Server Status</legend> <legend>Server Status</legend>
@ -188,6 +225,7 @@
<path>http://mpmap01.flightgear.org/mpstatus/</path> <path>http://mpmap01.flightgear.org/mpstatus/</path>
</binding> </binding>
</button> </button>
<button> <button>
<legend>Close</legend> <legend>Close</legend>
<default>true</default> <default>true</default>

View file

@ -30,7 +30,7 @@
<empty><stretch>true</stretch></empty> <empty><stretch>true</stretch></empty>
<text> <text>
<label>AI Scenario Select</label> <label>AI Traffic and Scenario Settings</label>
</text> </text>
<empty><stretch>true</stretch></empty> <empty><stretch>true</stretch></empty>
@ -49,13 +49,39 @@
<hrule/> <hrule/>
<checkbox>
<halign>left</halign>
<label>Enable AI traffic</label>
<name>enable-ai-traffic</name>
<property>/sim/traffic-manager/enabled</property>
<binding>
<command>dialog-apply</command>
<object-name>enable-ai-traffic</object-name>
</binding>
</checkbox>
<checkbox>
<halign>left</halign>
<label>Enable AI scenarios (requires restart)</label>
<name>enable-ai-scenarios</name>
<property>/sim/ai/scenarios-enabled</property>
<binding>
<command>dialog-apply</command>
<object-name>enable-ai-scenarios</object-name>
</binding>
</checkbox>
<text><label/></text>
<text> <text>
<label>Choose active scenario(s) for the next program start</label> <label>Choose active scenario(s) for the next program start</label>
<enable>
<property>/sim/ai/scenarios-enabled</property>
</enable>
</text> </text>
<hrule/> <hrule/>
<group> <group>
<layout>hbox</layout> <layout>hbox</layout>
@ -120,8 +146,12 @@
var scenarioN = rootN.getNode("scenario"); var scenarioN = rootN.getNode("scenario");
if( scenarioN == nil ) return; if( scenarioN == nil ) return;
var descriptionN = rootN.getNode("description"); var descriptionN = rootN.getNode("description");
if( descriptionN == nil ) var nameN = rootN.getNode("name");
var descriptionN = scenarioN.getNode("description"); if( (descriptionN == nil)and(nameN == nil) )
{
descriptionN = scenarioN.getNode("description");
nameN = scenarioN.getNode("name");
}
var description = descriptionN != nil ? descriptionN.getValue() : ""; var description = descriptionN != nil ? descriptionN.getValue() : "";
var propertyRoot = props.globals.getNode("sim/gui/dialogs/scenario",1).getChild( "scenario", nr, 1 ); var propertyRoot = props.globals.getNode("sim/gui/dialogs/scenario",1).getChild( "scenario", nr, 1 );
propertyRoot.getNode("selected",1).setBoolValue(isEnabledScenario(file)); propertyRoot.getNode("selected",1).setBoolValue(isEnabledScenario(file));
@ -131,8 +161,12 @@
group.getNode("layout",1).setValue("hbox"); group.getNode("layout",1).setValue("hbox");
var cb = group.getNode("checkbox",1); var cb = group.getNode("checkbox",1);
cb.getNode("property",1).setValue(propertyRoot.getNode("selected").getPath()); 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("name",1).setValue(file);
cb.getNode("enable/property",1).setValue("/sim/ai/scenarios-enabled");
group.getNode("empty",1).getNode("stretch",1).setValue("true"); group.getNode("empty",1).getNode("stretch",1).setValue("true");
} }

View file

@ -22,14 +22,6 @@
<script>gui.save_flight()</script> <script>gui.save_flight()</script>
</binding> </binding>
</item> </item>
<item>
<label>Scenario</label>
<binding>
<command>dialog-show</command>
<dialog-name>scenario</dialog-name>
</binding>
</item>
--> -->
<item> <item>
<name>reset</name> <name>reset</name>
@ -39,8 +31,8 @@
<command>reset</command> <command>reset</command>
</binding> </binding>
</item> </item>
<!--
<!-- <item> <item>
<label>High-Res Snapshot</label> <label>High-Res Snapshot</label>
<enabled>false</enabled> <enabled>false</enabled>
<binding> <binding>
@ -60,6 +52,7 @@
</script> </script>
</binding> </binding>
</item> </item>
<item> <item>
<name>snap-shot-dir</name> <name>snap-shot-dir</name>
<label>Screenshot Directory</label> <label>Screenshot Directory</label>
@ -452,14 +445,23 @@
<menu> <menu>
<name>ai</name> <name>ai</name>
<label>AI</label> <label>AI</label>
<!-- Not working at present
<item> <item>
<label>ATC Services in range</label> <label>Traffic and Scenario Settings</label>
<name>scenario</name>
<binding>
<command>dialog-show</command>
<dialog-name>scenario</dialog-name>
</binding>
</item>
<item>
<label>ATC Services in Range</label>
<name>atc-in-range</name>
<binding> <binding>
<command>ATC-freq-search</command> <command>ATC-freq-search</command>
</binding> </binding>
</item> </item>
-->
<item> <item>
<label>Wingman Controls</label> <label>Wingman Controls</label>
@ -489,15 +491,6 @@
</binding> </binding>
</item> </item>
<item>
<label>Scenario Select (requires restart)</label>
<name>scenario</name>
<binding>
<command>dialog-show</command>
<dialog-name>scenario</dialog-name>
</binding>
</item>
<item> <item>
<label>Jetway Settings</label> <label>Jetway Settings</label>
<name>jetway</name> <name>jetway</name>
@ -598,7 +591,6 @@
</binding> </binding>
</item> </item>
<item> <item>
<name>reload-panel</name> <name>reload-panel</name>
<label>Reload Panel</label> <label>Reload Panel</label>

View file

@ -68,6 +68,7 @@ Started September 2000 by David Megginson, david@megginson.com
<show-buffers type="bool" userarchive="y">true</show-buffers> <show-buffers type="bool" userarchive="y">true</show-buffers>
<ambient-occlusion type="bool" userarchive="y">false</ambient-occlusion> <ambient-occlusion type="bool" userarchive="y">false</ambient-occlusion>
<exposure type="float" userarchive="y">1.0</exposure> <exposure type="float" userarchive="y">1.0</exposure>
<use-color-for-depth type="bool">false</use-color-for-depth>
<debug type="bool">false</debug> <debug type="bool">false</debug>
<realism type="int">5</realism> <realism type="int">5</realism>
<filtering type="int">8</filtering> <filtering type="int">8</filtering>
@ -748,13 +749,9 @@ Started September 2000 by David Megginson, david@megginson.com
<ai> <ai>
<enabled type="bool">true</enabled> <enabled type="bool">true</enabled>
<scenarios-enabled type="bool" userarchive="y">true</scenarios-enabled>
<scenario>nimitz_demo</scenario> <scenario>nimitz_demo</scenario>
<groundnet-cache type="bool">true</groundnet-cache> <groundnet-cache type="bool">true</groundnet-cache>
<!-- <scenario>balloon_demo</scenario> -->
<!-- <scenario>aircraft_demo</scenario> -->
<!-- <scenario>refueling_demo</scenario> -->
<!-- <scenario>lead_aircraft</scenario> -->
<!-- <scenario>vinson_demo</scenario> -->
</ai> </ai>
<multiplay preserve="y"> <multiplay preserve="y">