1 /**
2 * Shader to output depth for a shadowmap
3 */
4 module dash.graphics.shaders.glsl.shadowmap;
5 import dash.graphics.shaders.glsl;
6 
7 package:
8 
9 /// Vertex Shader for inaminate objects
10 immutable string shadowmapVS = glslVersion ~ q{
11     layout(location = 0) in vec3 vPosition_m;
12 
13     uniform mat4 worldViewProj;
14 
15     void main()
16     {
17         gl_Position = worldViewProj * vec4( vPosition_m, 1.0f );
18     }
19 
20 };
21 
22 /// Vertex shader for animated objects
23 immutable string animatedshadowmapVS = glslVersion ~ q{
24     layout(location = 0) in vec3 vPosition_m;
25     //layout(location = 1) in vec2 vUV;
26     //layout(location = 2) in vec3 vNormal_m;
27     //layout(location = 3) in vec3 vTangent_m;
28     layout(location = 4) in vec4 vBone_m;
29     layout(location = 5) in vec4 vWeight_m;
30 
31     uniform mat4 worldViewProj;
32     uniform mat4[100] bones;
33 
34     void main()
35     {
36         // Calculate vertex change from animation
37         mat4 boneTransform = bones[ int(vBone_m[ 0 ]) ] * vWeight_m[ 0 ];
38         boneTransform += bones[ int(vBone_m[ 1 ]) ] * vWeight_m[ 1 ];
39         boneTransform += bones[ int(vBone_m[ 2 ]) ] * vWeight_m[ 2 ];
40         boneTransform += bones[ int(vBone_m[ 3 ]) ] * vWeight_m[ 3 ];
41 
42         gl_Position = worldViewProj * ( boneTransform * vec4( vPosition_m, 1.0f ) );
43     }
44 };
45 
46 /// Fragment Shader, just output depth
47 immutable string shadowmapFS = glslVersion ~ q{
48     layout(location = 0) out float fragDepth;
49 
50     void main() { }
51 
52 };