3 layout (location = 0) in vec3 pos;
\r
4 layout (location = 1) in vec3 normal;
\r
9 out float BacksideIrradiance;
\r
12 uniform sampler2D shadowmapTexture;
\r
13 uniform vec3 lightPos;
\r
14 uniform vec2 samplePositions[13];
\r
15 uniform vec3 sampleWeights[13];
\r
16 uniform int screenWidth;
\r
17 uniform int screenHeight;
\r
21 uniform mat4 lightView;
\r
22 uniform mat4 lightViewInv;
\r
23 uniform mat4 projection;
\r
24 uniform mat4 lightProjection;
\r
26 vec4 blur(sampler2D tex, vec2 uv, vec2 res) {
\r
27 float Pi = 6.28318530718; // Pi*2
\r
29 // GAUSSIAN BLUR SETTINGS {{{
\r
30 float Directions = 16.0; // BLUR DIRECTIONS (Default 16.0 - More is better but slower)
\r
31 float Quality = 4.0; // BLUR QUALITY (Default 4.0 - More is better but slower)
\r
32 float Size = 8.0; // BLUR SIZE (Radius)
\r
33 // GAUSSIAN BLUR SETTINGS }}}
\r
35 vec2 Radius = Size/res;
\r
38 vec4 Color = texture(tex, uv);
\r
40 // Blur calculations
\r
41 for( float d=0.0; d<Pi; d+=Pi/Directions) {
\r
42 for(float i=1.0/Quality; i<=1.0; i+=1.0/Quality) {
\r
43 Color += texture( tex, uv+vec2(cos(d),sin(d))*Radius*i);
\r
48 Color /= Quality * Directions - 15.0;
\r
54 gl_Position = projection * view * model * vec4(pos, 1.0);
\r
55 FragPos = vec3(model * vec4(pos, 1));
\r
59 vec4 lightSpace = lightProjection * lightView * model * vec4(pos, 1.0);
\r
60 lightSpace = lightSpace / lightSpace.w;
\r
61 vec2 shadowmapCoords = lightSpace.xy;
\r
62 shadowmapCoords = vec2(
\r
63 (shadowmapCoords.x * 0.99 + 1) / 2,
\r
64 (shadowmapCoords.y * 0.99 + 1) / 2
\r
69 vec4 t = texture(shadowmapTexture, shadowmapCoords);
\r
70 //vec4 t = blur(shadowmapTexture, shadowmapCoords, vec2(screenWidth, screenHeight));
\r
72 BacksideIrradiance = t.r; //*100 + t.g + t.b/100;
\r
74 vec3 lightDir = normalize(FragPos - lightPos);
\r
75 Backside = (lightPos + (lightDir * BacksideIrradiance));
\r
76 //Backside = texture(shadowmapTexture, shadowmapCoords).xyz*10;
\r