Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/avi_play/shaders/bump.frag @ 3703

Last change on this file since 3703 was 3556, checked in by bensch, 19 years ago

data/trunk: added bump-shader

File size: 891 bytes
Line 
1 uniform sampler2D BumpTex; //The bump-map
2 uniform sampler2D DecalTex; //The texture
3 varying vec4 passcolor; //Receiving the vertex color from the vertex shader
4 varying vec3 LightDir; //Receiving the transformed light direction
5 void main()
6 {
7   //Get the color of the bump-map
8   vec3 BumpNorm = vec3(texture2D(BumpTex, gl_TexCoord[0].xy));
9   //Get the color of the texture
10   vec3 DecalCol = vec3(texture2D(DecalTex, gl_TexCoord[0].xy));
11   //Expand the bump-map into a normalized unsigned vector float
12   BumpNorm = (BumpNorm -0.5) * 2.0;
13   //Find the dot product between the light direction and the normal
14   NdotL = max(dot(BumpNorm, LightDir), 0.0);
15   //Calculate the final color gl_FragColor
16   vec3 diffuse = NdotL * passcolor.xyz * DecalCol;
17   //Set the color of the fragment...  If you want specular lighting or other types add it here
18   vec4(diffuse, passcolor.w);
19 }
Note: See TracBrowser for help on using the repository browser.