From ee8d70b3bf2d26bf6c78eae7c202d84466adb205 Mon Sep 17 00:00:00 2001 From: Frederic Bouvier Date: Tue, 21 Sep 2010 09:17:07 +0200 Subject: [PATCH] Use specular factor of bumpspec map (alpha channel) to modulate reflection factor --- Shaders/reflect-bump-spec.frag | 8 ++++---- Shaders/reflect-bump-spec.vert | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Shaders/reflect-bump-spec.frag b/Shaders/reflect-bump-spec.frag index 5ca1a0fae..075e48497 100644 --- a/Shaders/reflect-bump-spec.frag +++ b/Shaders/reflect-bump-spec.frag @@ -39,9 +39,9 @@ void main (void) float NdotL, NdotHV; vec4 color = constantColor; vec4 specular = vec4(0.0); - vec4 ns = texture2D(NormalTex, gl_TexCoord[0].st); - vec3 n = ns.rgb * 2.0 - 1.0; - n = normalize(n.x * VTangent + n.y * VBinormal + n.z * VNormal); + vec4 ns = texture2D(NormalTex, gl_TexCoord[0].st); + vec3 n = ns.rgb * 2.0 - 1.0; + n = normalize(n.x * VTangent + n.y * VBinormal + n.z * VNormal); NdotL = max(0.0, dot(n, lightDir)); // calculate the specular light @@ -97,7 +97,7 @@ void main (void) reflFactor = (gl_FrontMaterial.shininess / 128) + transparency_offset; } - reflFactor = clamp(reflFactor, 0.0, 1.0); + reflFactor = clamp(reflFactor, 0.0, 1.0) * ns.a; // set ambient adjustment to remove bluiness with user input float ambient_offset = clamp(ambient_correction, -1.0, 1.0); diff --git a/Shaders/reflect-bump-spec.vert b/Shaders/reflect-bump-spec.vert index f15fa4221..d2b7e9ff2 100644 --- a/Shaders/reflect-bump-spec.vert +++ b/Shaders/reflect-bump-spec.vert @@ -5,8 +5,8 @@ varying vec4 rawpos; varying vec4 ecPosition; varying vec3 VNormal; -varying vec3 VTangent;////////////// -varying vec3 VBinormal;///////////// +varying vec3 VTangent; +varying vec3 VBinormal; varying vec3 Normal; varying vec4 constantColor; varying vec3 vViewVec;