Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/GLSL120/BumpMapping/Example_BumpMappingShadowRcvFp.glsl @ 12187

Last change on this file since 12187 was 12115, checked in by wiesep, 6 years ago

Changed folder structure, deletet some unused files and cleaned up code

File size: 712 bytes
Line 
1#version 120
2
3// General functions
4
5// Expand a range-compressed vector
6vec3 expand(vec3 v)
7{
8        return (v - 0.5) * 2.0;
9}
10
11uniform sampler2D shadowMap;
12uniform sampler2D normalMap;
13uniform vec4 lightDiffuse;
14
15varying vec4 uvproj;
16varying vec4 oUv0;
17varying vec3 oTSLightDir;
18
19void main()
20{
21        // retrieve normalised light vector, expand from range-compressed
22        vec3 lightVec = expand(normalize(oTSLightDir).xyz);
23
24        // get bump map vector, again expand from range-compressed
25        vec3 bumpVec = expand(texture2D(normalMap, oUv0.xy).xyz);
26
27        // get shadow value
28        vec3 shadow = texture2DProj(shadowMap, uvproj).xyz;
29
30        // Calculate dot product
31        gl_FragColor = vec4(shadow * lightDiffuse.xyz * dot(bumpVec, lightVec), 1.0);
32}
Note: See TracBrowser for help on using the repository browser.