Add code to make normal maps work. Joerg: don't worry about this change being done near a release, we have no track atm using this feature, so this code will remain sleeping until, probably, 0.8

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@10070 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria
2011-11-01 01:52:10 +00:00
parent f3532da9cd
commit 35aa87674d
4 changed files with 120 additions and 10 deletions

View File

@@ -0,0 +1,23 @@
// By http://content.gpwiki.org/index.php/OpenGL:Tutorials:GLSL_Bump_Mapping
// Released under GNU FDL license, without invariant (so DFSG-compliant, see
// http://wiki.debian.org/DFSGLicenses#Exception)
uniform sampler2D BumpTex; //The bump-map
uniform sampler2D DecalTex; //The texture
varying vec4 passcolor; //Receiving the vertex color from the vertex shader
varying vec3 LightDir; //Receiving the transformed light direction
void main()
{
//Get the color of the bump-map
vec3 BumpNorm = vec3(texture2D(BumpTex, gl_TexCoord[0].xy));
//Get the color of the texture
vec3 DecalCol = vec3(texture2D(DecalTex, gl_TexCoord[0].xy));
//Expand the bump-map into a normalized signed vector
BumpNorm = (BumpNorm -0.5) * 2.0;
//Find the dot product between the light direction and the normal
float NdotL = max(dot(BumpNorm, LightDir), 0.0) / 3.0 * 2.1 + 0.5;
//Calculate the final color gl_FragColor
vec3 diffuse = NdotL * passcolor.xyz * DecalCol;
//Set the color of the fragment... If you want specular lighting or other types add it here
gl_FragColor = vec4(diffuse, passcolor.w);
}