diff --git a/Effects/runway.eff b/Effects/runway.eff
index 562460dca..b107b744c 100644
--- a/Effects/runway.eff
+++ b/Effects/runway.eff
@@ -85,6 +85,332 @@
6
7
+
+
+
+ /sim/rendering/shaders/generic
+ /sim/rendering/rembrandt/enabled
+
+
+ 2.0
+
+
+
+ GL_ARB_shader_objects
+ GL_ARB_shading_language_100
+ GL_ARB_vertex_shader
+ GL_ARB_fragment_shader
+
+
+ GL_EXT_gpu_shader4
+
+
+
+
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 2
+ noise
+
+
+
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 6
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 7
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ambient-and-diffuse
+
+ back
+
+ Shaders/reflect-bump-spec.vert
+ Shaders/runway-gbuffer.frag
+ Shaders/gbuffer-functions.frag
+ Shaders/gbuffer-encode.frag
+
+ tangent
+ 6
+
+
+ binormal
+ 7
+
+
+
+ BaseTex
+ sampler-2d
+ 0
+
+
+
+ Map
+ sampler-2d
+ 1
+
+
+
+ Noise
+ sampler-3d
+ 2
+
+
+
+ NormalTex
+ sampler-2d
+ 4
+
+
+
+ Environment
+ sampler-cube
+ 5
+
+
+
+ Rainbow
+ sampler-2d
+ 6
+
+
+
+ Fresnel
+ sampler-2d
+ 7
+
+
+
+
+ rainbowiness
+ float
+
+
+
+
+
+
+
+ fresneliness
+ float
+
+
+
+
+
+
+
+ noisiness
+ float
+
+
+
+
+
+
+
+ spec_adjust
+ float
+
+
+
+
+
+
+
+ ambient_correction
+ float
+
+
+
+
+
+
+
+ reflect_map
+ float
+
+
+
+
+
+
+
+ normalmap_dds
+ float
+
+
+
+
+
+
+ visibility
+ float
+
+
+
+
+
+ avisibility
+ float
+
+
+
+
+
+ hazeLayerAltitude
+ float
+
+
+
+
+
+ scattering
+ float
+
+
+
+
+
+ terminator
+ float
+
+
+
+
+
+ fogType
+ int
+
+
+
+
+
+
@@ -232,7 +558,7 @@
Shaders/reflect-bump-spec.vert
Shaders/include_fog.frag
- Shaders/runway-reflect-bump-spec.frag
+ Shaders/runway.frag
tangent
6
diff --git a/Shaders/runway-gbuffer.frag b/Shaders/runway-gbuffer.frag
new file mode 100644
index 000000000..683ce2454
--- /dev/null
+++ b/Shaders/runway-gbuffer.frag
@@ -0,0 +1,107 @@
+// -*- mode: C; -*-
+// Licence: GPL v2
+// © Emilian Huminiuc and Vivian Meazza 2011
+
+#version 120
+
+varying vec3 rawpos;
+varying vec3 VNormal;
+varying vec3 VTangent;
+varying vec3 VBinormal;
+varying vec3 vViewVec;
+varying vec3 reflVec;
+
+varying vec4 Diffuse;
+varying float alpha;
+//varying float fogCoord;
+
+uniform samplerCube Environment;
+uniform sampler2D Rainbow;
+uniform sampler2D BaseTex;
+uniform sampler2D Fresnel;
+uniform sampler2D Map;
+uniform sampler2D NormalTex;
+uniform sampler3D Noise;
+
+uniform float spec_adjust;
+uniform float rainbowiness;
+uniform float fresneliness;
+uniform float noisiness;
+uniform float ambient_correction;
+uniform float normalmap_dds;
+
+void encode_gbuffer(vec3 normal, vec3 color, int mId, float specular, float shininess, float emission, float depth);
+
+void main (void)
+{
+
+ vec4 texel = texture2D(BaseTex, gl_TexCoord[0].st);
+ vec4 nmap = texture2D(NormalTex, gl_TexCoord[0].st * 8.0);
+ vec4 map = texture2D(Map, gl_TexCoord[0].st * 8.0);
+ vec4 specNoise = texture3D(Noise, rawpos.xyz * 0.0045);
+ vec4 noisevec = texture3D(Noise, rawpos.xyz);
+ vec3 ambient = vec3(0.85,0.85,0.9);//placeholder for sun ambient
+ vec3 N;
+ float emission = dot( gl_FrontLightModelProduct.sceneColor.rgb + gl_FrontMaterial.emission.rgb,
+ vec3( 0.3, 0.59, 0.11 ) );
+
+ N = nmap.rgb * 2.0 - 1.0;
+ N = normalize(N.x * VTangent + N.y * VBinormal + N.z * VNormal);
+ if (normalmap_dds > 0)
+ N = -N;
+
+
+ // calculate the specular light
+ float refl_correction = spec_adjust * 1.9 - 1.0;
+ float shininess = max (0.35, refl_correction) * nmap.a;
+
+ float specular = dot(vec3(0.5*shininess), vec3( 0.3, 0.59, 0.11 ));
+
+ vec4 color = vec4(1.0);
+
+ color.a = texel.a * alpha;
+ color = clamp(color, 0.0, 1.0);
+
+ vec3 viewVec = normalize(vViewVec);
+
+ // Map a rainbowish color
+ float v = dot(viewVec, normalize(VNormal));
+ vec4 rainbow = texture2D(Rainbow, vec2(v, 0.0));
+
+ // Map a fresnel effect
+ vec4 fresnel = texture2D(Fresnel, vec2(v, 0.0));
+
+ // map the refection of the environment
+ vec4 reflection = textureCube(Environment, reflVec * dot(N,VNormal));
+
+
+ // set the user shininess offset
+ float transparency_offset = clamp(refl_correction, -1.0, 1.0);
+ float reflFactor = 0.0;
+
+ float MixFactor = specNoise.r * specNoise.g * specNoise.b * 350.0;
+
+ MixFactor = 0.75 * smoothstep(0.0, 1.0, MixFactor);
+
+ reflFactor = max(map.a * (texel.r + texel.g), 1.0 - MixFactor) * (1.0- N.z) + transparency_offset ;
+ reflFactor =0.75 * smoothstep(0.05, 1.0, reflFactor);
+
+ // set ambient adjustment to remove bluiness with user input
+ float ambient_offset = clamp(ambient_correction, -1.0, 1.0);
+ vec3 ambient_Correction = vec3(ambient.rg, ambient.b * 0.6) * ambient_offset;
+ ambient_Correction = clamp(ambient_Correction, -1.0, 1.0);
+
+ // add fringing fresnel and rainbow effects and modulate by reflection
+ vec4 reflcolor = mix(reflection, rainbow, rainbowiness * v);
+
+ vec4 reflfrescolor = mix(reflcolor, fresnel, fresneliness * v);
+ vec4 noisecolor = mix(reflfrescolor, noisevec, noisiness);
+ vec4 raincolor = vec4(noisecolor.rgb * reflFactor, 1.0);
+
+ vec4 mixedcolor = mix(texel, raincolor, reflFactor);
+
+ // the final reflection
+ vec4 fragColor = vec4(color.rgb * mixedcolor.rgb + ambient_Correction, color.a);
+
+ encode_gbuffer(N, fragColor.rgb, 1, specular, shininess, emission, gl_FragCoord.z);
+}
\ No newline at end of file
diff --git a/Shaders/runway-reflect-bump-spec.frag b/Shaders/runway.frag
similarity index 61%
rename from Shaders/runway-reflect-bump-spec.frag
rename to Shaders/runway.frag
index 8f3c67bf3..463c1246b 100644
--- a/Shaders/runway-reflect-bump-spec.frag
+++ b/Shaders/runway.frag
@@ -45,53 +45,46 @@ void main (void)
//vec3 halfV;
//float NdotL, NdotHV;
- vec4 texel = texture2D(BaseTex, gl_TexCoord[0].st);
- vec4 nmap = texture2D(NormalTex, gl_TexCoord[0].st * 8.0);
- vec4 map = texture2D(Map, gl_TexCoord[0].st * 8.0);
- vec4 specNoise = texture3D(Noise, rawpos.xyz * 0.0045);
- vec4 noisevec = texture3D(Noise, rawpos.xyz);
+ vec4 texel = texture2D(BaseTex, gl_TexCoord[0].st);
+ vec4 nmap = texture2D(NormalTex, gl_TexCoord[0].st * 8.0);
+ vec4 map = texture2D(Map, gl_TexCoord[0].st * 8.0);
+ vec4 specNoise = texture3D(Noise, rawpos.xyz * 0.0045);
+ vec4 noisevec = texture3D(Noise, rawpos.xyz);
vec3 lightDir = gl_LightSource[0].position.xyz;
vec3 halfVector = gl_LightSource[0].halfVector.xyz;
- vec3 N;
- float pf;
+ vec3 N;
+ float pf;
- // vec4 color = gl_Color;
- //vec4 specular = vec4(0.0);
-
- N = nmap.rgb * 2.0 - 1.0;
- N = normalize(N.x * VTangent + N.y * VBinormal + N.z * VNormal);
- if (normalmap_dds > 0)
- N = -N;
+ N = nmap.rgb * 2.0 - 1.0;
+ N = normalize(N.x * VTangent + N.y * VBinormal + N.z * VNormal);
+ if (normalmap_dds > 0)
+ N = -N;
// calculate the specular light
- float refl_correction = spec_adjust * 1.9 - 1.0;
- float shininess = max (0.35, refl_correction);
+ float refl_correction = spec_adjust * 1.9 - 1.0;
+ float shininess = max (0.35, refl_correction);
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)));
- if (nDotVP == 0.0)
- pf = 0.0;
- else
- pf = pow(nDotHV, /*gl_FrontMaterial.*/shininess);
+ if (nDotVP == 0.0)
+ pf = 0.0;
+ else
+ pf = pow(nDotHV, /*gl_FrontMaterial.*/shininess);
- vec4 Diffuse = gl_LightSource[0].diffuse * nDotVP;
- vec4 Specular = /*gl_FrontMaterial.specular*/ vec4(vec3(0.5*shininess), 1.0)* gl_LightSource[0].specular * pf;
+ vec4 Diffuse = gl_LightSource[0].diffuse * nDotVP;
+ vec4 Specular = vec4(vec3(0.5*shininess), 1.0)* gl_LightSource[0].specular * pf;
- vec4 color = gl_Color + Diffuse * gl_FrontMaterial.diffuse;
- color += Specular * /*gl_FrontMaterial.specular*/ vec4(vec3(0.5*shininess), 1.0) * nmap.a;
-
- //color.a = alpha;
-
- //vec4 texelcolor = color * texel + specular;
+ vec4 color = gl_Color + Diffuse * gl_FrontMaterial.diffuse;
+ color += Specular * vec4(vec3(0.5*shininess), 1.0) * nmap.a;
color.a = texel.a * alpha;
color = clamp(color, 0.0, 1.0);
vec3 viewVec = normalize(vViewVec);
// Map a rainbowish color
- float v = dot(viewVec, normalize(VNormal));
+ float v = dot(viewVec, normalize(VNormal));
vec4 rainbow = texture2D(Rainbow, vec2(v, 0.0));
// Map a fresnel effect
@@ -105,14 +98,12 @@ void main (void)
float transparency_offset = clamp(refl_correction, -1.0, 1.0);
float reflFactor = 0.0;
- //vec4 specNoise1 = texture3D(Noise, rawpos.xyz*0.001);
+ float MixFactor = specNoise.r * specNoise.g * specNoise.b * 350.0;
- float MixFactor = specNoise.r * specNoise.g * specNoise.b * 350.0;
- //MixFactor *= specNoise1.r;
- MixFactor = 0.75 * smoothstep(0.0, 1.0, MixFactor);
+ MixFactor = 0.75 * smoothstep(0.0, 1.0, MixFactor);
reflFactor = max(map.a * (texel.r + texel.g), 1.0 - MixFactor) * (1.0- N.z) + transparency_offset ;
- //reflFactor = clamp(reflFactor, 0.0, 0.75);
+
reflFactor =0.75 * smoothstep(0.05, 1.0, reflFactor);
// set ambient adjustment to remove bluiness with user input
@@ -122,17 +113,17 @@ void main (void)
// add fringing fresnel and rainbow effects and modulate by reflection
vec4 reflcolor = mix(reflection, rainbow, rainbowiness * v);
- reflcolor += Specular * nmap.a;
+ reflcolor += Specular * nmap.a;
vec4 reflfrescolor = mix(reflcolor, fresnel, fresneliness * v);
vec4 noisecolor = mix(reflfrescolor, noisevec, noisiness);
vec4 raincolor = vec4(noisecolor.rgb * reflFactor, 1.0);
- raincolor += Specular * nmap.a;
+ raincolor += Specular * nmap.a;
vec4 mixedcolor = mix(texel, raincolor, reflFactor);
// the final reflection
vec4 fragColor = vec4(color.rgb * mixedcolor.rgb + ambient_Correction.rgb, color.a);
- fragColor += Specular * nmap.a;
+ fragColor += Specular * nmap.a;
fragColor.rgb = fog_Func(fragColor.rgb, fogType);
gl_FragColor = fragColor;