]> gitweb.ps.run Git - subsurface_scattering/blobdiff - shaders/fbo_frag.glsl
SSSSS comments
[subsurface_scattering] / shaders / fbo_frag.glsl
index 11029923d8555e7017f756de2f733484597f0acc..f92483e3b55227d27f277a63edf9770e69e8d605 100644 (file)
@@ -11,45 +11,17 @@ uniform int renderState;
 uniform vec2 samplePositions[13];\r
 uniform vec3 sampleWeights[13];\r
 \r
 uniform vec2 samplePositions[13];\r
 uniform vec3 sampleWeights[13];\r
 \r
-vec4 blur(sampler2D tex, vec2 uv, vec2 res) {\r
-  float Pi = 6.28318530718; // Pi*2\r
-    \r
-  // GAUSSIAN BLUR SETTINGS {{{\r
-  float Directions = 16.0; // BLUR DIRECTIONS (Default 16.0 - More is better but slower)\r
-  float Quality = 4.0; // BLUR QUALITY (Default 4.0 - More is better but slower)\r
-  float Size = 8.0; // BLUR SIZE (Radius)\r
-  // GAUSSIAN BLUR SETTINGS }}}\r
-  \r
-  vec2 Radius = Size/res;\r
-  \r
-  // Pixel colour\r
-  vec4 Color = texture(tex, uv);\r
-  \r
-  // Blur calculations\r
-  for( float d=0.0; d<Pi; d+=Pi/Directions) {\r
-    for(float i=1.0/Quality; i<=1.0; i+=1.0/Quality) {\r
-      Color += texture( tex, uv+vec2(cos(d),sin(d))*Radius*i);         \r
-    }\r
-  }\r
-  \r
-  // Output to screen\r
-  Color /= Quality * Directions - 15.0;\r
-  return Color;\r
-}\r
-\r
 void main()\r
 {\r
     if (renderState == 0) {\r
 void main()\r
 {\r
     if (renderState == 0) {\r
-        FragColor = blur(shadowmapTexture, TexCoords, vec2(screenWidth, screenHeight));\r
-    }\r
-    else if (renderState == 1) {\r
         FragColor = texture(shadowmapTexture, TexCoords);\r
     }\r
         FragColor = texture(shadowmapTexture, TexCoords);\r
     }\r
-    // stencil buffer\r
-    else if (renderState == 2) {\r
+    else if (renderState == 1) {\r
         FragColor = texture(irradianceTexture, TexCoords);\r
     }\r
         FragColor = texture(irradianceTexture, TexCoords);\r
     }\r
-    else if (renderState == 3) {\r
+    else if (renderState == 2) {\r
+        // sample calculated irradiance\r
+        // using Gaussian kernel to approximate light spread\r
         vec4 result = vec4(0, 0, 0, 1);\r
         for (int i = 0; i < 13; i++) {\r
             vec2 sampleCoords = TexCoords + samplePositions[i] * vec2(1.0/screenWidth, 1.0/screenHeight);\r
         vec4 result = vec4(0, 0, 0, 1);\r
         for (int i = 0; i < 13; i++) {\r
             vec2 sampleCoords = TexCoords + samplePositions[i] * vec2(1.0/screenWidth, 1.0/screenHeight);\r