Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Example/GLSL150/Example_BumpMappingShadowRcvFp.glsl @ 12083

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

Reorganised shader programs

File size: 747 bytes
Line 
1#version 150
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
15in vec4 uvproj;
16in vec4 oUv0;
17in vec3 oTSLightDir;
18
19out vec4 fragColour;
20
21void main()
22{
23        // retrieve normalised light vector, expand from range-compressed
24        vec3 lightVec = expand(normalize(oTSLightDir).xyz);
25
26        // get bump map vector, again expand from range-compressed
27        vec3 bumpVec = expand(texture(normalMap, oUv0.xy).xyz);
28
29        // get shadow value
30        vec3 shadow = textureProj(shadowMap, uvproj).xyz;
31
32        // Calculate dot product
33        fragColour = vec4(shadow * lightDiffuse.xyz * dot(bumpVec, lightVec), 1.0);
34}
Note: See TracBrowser for help on using the repository browser.