]> git.tdb.fi Git - libs/gl.git/blob - shaderlib/shadow.glsl
Move operators to their own file in the Blender exporter
[libs/gl.git] / shaderlib / shadow.glsl
1 import msp_interface;
2
3 uniform ShadowMap
4 {
5         float shadow_darkness;
6         mat4 shd_eye_matrix;
7 };
8
9 uniform sampler2DShadow shadow_map;
10
11 layout(constant_id=auto) const bool use_shadow_map = false;
12
13 #pragma MSP stage(vertex)
14 void shadow_transform(vec4 eye_vertex)
15 {
16         out vec3 shadow_coord = (shd_eye_matrix*eye_vertex).xyz;
17 }
18
19 #pragma MSP stage(fragment)
20 virtual float get_shadow_factor(int index)
21 {
22         if(use_shadow_map)
23         {
24                 float shadow_sample = texture(shadow_map, shadow_coord);
25                 return mix(1.0, shadow_sample, shadow_darkness);
26         }
27         else
28                 return 1.0;
29 }