From e6fb203302be5528b7ccf3eb9d8351aca6e6d76a Mon Sep 17 00:00:00 2001 From: Vivian Meazza Date: Sun, 25 Sep 2011 10:59:30 +0100 Subject: [PATCH] Add light map to reflect shader. Signed-off-by: Vivian Meazza --- Effects/reflect.eff | 122 ++++++--- .../Logitech/wingman-interceptor.xml | 251 ++++++++++++++++++ Shaders/reflect.frag | 25 +- 3 files changed, 356 insertions(+), 42 deletions(-) create mode 100644 Input/Joysticks/Logitech/wingman-interceptor.xml diff --git a/Effects/reflect.eff b/Effects/reflect.eff index eabbe0722..f146cffc6 100644 --- a/Effects/reflect.eff +++ b/Effects/reflect.eff @@ -1,54 +1,66 @@ + Effects/reflect Effects/model-default + + + Aircraft/Generic/Effects/greymap.png + linear-mipmap-linear + repeat + repeat + normalized + + cubemap @@ -93,7 +105,9 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model 0.25 0.0 0.05 - 0 + 0 + 0 + 1 @@ -181,6 +195,19 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model + + 2 + + texture[2]/type + + + texture[2]/image + + linear-mipmap-linear + repeat + repeat + + 5 @@ -284,6 +311,12 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model 0 + + Lightmap + sampler-2d + 2 + + Environment sampler-cube @@ -314,6 +347,7 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model 9 + rainbowiness @@ -341,7 +375,7 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model - @@ -364,12 +398,30 @@ EXAMPLES: You can find examples of both usages in the Hunter and Lightning model reflect_map - float + int reflect_map + + + + light_map + int + + light_map + + + + + lightmap_factor + float + + factor + + + diff --git a/Input/Joysticks/Logitech/wingman-interceptor.xml b/Input/Joysticks/Logitech/wingman-interceptor.xml new file mode 100644 index 000000000..49ead4db4 --- /dev/null +++ b/Input/Joysticks/Logitech/wingman-interceptor.xml @@ -0,0 +1,251 @@ + + + + + + + Logitech WingMan Interceptor + + + Aileron + + property-scale + /controls/flight/aileron + true + + + + + Elevator + + property-scale + /controls/flight/elevator + -1.0 + true + + + + + Throttle + + nasal + + + + + + View Direction + + 4 + 6 + 4 + + + true + + property-adjust + /sim/current-view/goal-heading-offset-deg + 2.5 + + + + true + + property-adjust + /sim/current-view/goal-heading-offset-deg + -2.5 + + + + + + View Elevation + + 5 + 7 + 5 + + + true + + property-adjust + /sim/current-view/goal-pitch-offset-deg + 1.0 + + + + true + + property-adjust + /sim/current-view/goal-pitch-offset-deg + -1.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Shaders/reflect.frag b/Shaders/reflect.frag index 16a0d247d..e6f1ae527 100644 --- a/Shaders/reflect.frag +++ b/Shaders/reflect.frag @@ -1,6 +1,6 @@ // -*- mode: C; -*- // Licence: GPL v2 -// Author: Vivian Meazza. +// Author: Vivian Meazza. #version 120 @@ -20,13 +20,17 @@ uniform sampler2D BaseTex; uniform sampler2D Fresnel; uniform sampler2D Map; uniform sampler3D Noise; +uniform sampler2D Lightmap; uniform float refl_correction; uniform float rainbowiness; uniform float fresneliness; uniform float noisiness; uniform float ambient_correction; -uniform float reflect_map; +uniform float lightmap_factor; + +uniform int light_map; +uniform int reflect_map; void main (void) { @@ -52,7 +56,7 @@ void main (void) } vec4 texel = texture2D(BaseTex, gl_TexCoord[0].st); -// vec4 texelcolor = color * texel + specular; + // vec4 texelcolor = color * texel + specular; color.a = texel.a * alpha; color = clamp(color, 0.0, 1.0); @@ -81,14 +85,14 @@ void main (void) float transparency_offset = clamp(refl_correction, -1.0, 1.0); float reflFactor = 0.0; - if(reflect_map > 0.0){ - // map the shininess of the object with user input + if(reflect_map > 0){ + // map the shininess of the object with user input vec4 map = texture2D(Map, gl_TexCoord[0].st); //float pam = (map.a * -2) + 1; //reverse map reflFactor = map.a + transparency_offset; } else { - // set the reflectivity proportional to shininess with user - // input + // set the reflectivity proportional to shininess with user + // input reflFactor = (gl_FrontMaterial.shininess / 128.0) + transparency_offset; } @@ -115,5 +119,12 @@ void main (void) vec4 reflColor = vec4(color.rgb * mixedcolor.rgb + specular.rgb + ambient_Correction.rgb, color.a); reflColor = clamp(reflColor, 0.0, 1.0); + // add a lightmap + + if ( light_map >= 1 ) { + vec3 lightmapTexel = texture2D(Lightmap, gl_TexCoord[0].st).rgb * lightmap_factor; + reflColor.rgb = max(reflColor.rgb, lightmapTexel * gl_FrontMaterial.diffuse.rgb * mixedcolor.rgb); + } + gl_FragColor = mix(gl_Fog.color, reflColor, fogFactor); }