6 uniform sampler2D shadowmapTexture;
\r
7 uniform sampler2D irradianceTexture;
\r
8 uniform int screenWidth;
\r
9 uniform int screenHeight;
\r
10 uniform int renderState;
\r
11 uniform vec2 samplePositions[13];
\r
12 uniform vec3 sampleWeights[13];
\r
14 vec4 blur(sampler2D tex, vec2 uv, vec2 res) {
\r
15 float Pi = 6.28318530718; // Pi*2
\r
17 // GAUSSIAN BLUR SETTINGS {{{
\r
18 float Directions = 16.0; // BLUR DIRECTIONS (Default 16.0 - More is better but slower)
\r
19 float Quality = 4.0; // BLUR QUALITY (Default 4.0 - More is better but slower)
\r
20 float Size = 8.0; // BLUR SIZE (Radius)
\r
21 // GAUSSIAN BLUR SETTINGS }}}
\r
23 vec2 Radius = Size/res;
\r
26 vec4 Color = texture(tex, uv);
\r
28 // Blur calculations
\r
29 for( float d=0.0; d<Pi; d+=Pi/Directions) {
\r
30 for(float i=1.0/Quality; i<=1.0; i+=1.0/Quality) {
\r
31 Color += texture( tex, uv+vec2(cos(d),sin(d))*Radius*i);
\r
36 Color /= Quality * Directions - 15.0;
\r
42 if (renderState == 0) {
\r
43 FragColor = blur(shadowmapTexture, TexCoords, vec2(screenWidth, screenHeight));
\r
45 else if (renderState == 1) {
\r
46 FragColor = texture(shadowmapTexture, TexCoords);
\r
49 else if (renderState == 2) {
\r
50 FragColor = texture(irradianceTexture, TexCoords);
\r
52 else if (renderState == 3) {
\r
53 vec4 result = vec4(0, 0, 0, 1);
\r
54 for (int i = 0; i < 13; i++) {
\r
55 vec2 sampleCoords = TexCoords + samplePositions[i] * vec2(1.0/screenWidth, 1.0/screenHeight);
\r
56 //vec4 sample = texture(irradianceTexture, sampleCoords)
\r
57 // * texture(shadowmapTexture, sampleCoords);
\r
58 vec4 sample = texture(irradianceTexture, sampleCoords);
\r
59 vec4 weight = vec4(sampleWeights[i], 1);
\r
60 result += sample * weight;
\r