]> gitweb.ps.run Git - subsurface_scattering/blobdiff - shaders/fbo_frag.glsl
add PDF and exes
[subsurface_scattering] / shaders / fbo_frag.glsl
index e199245cec69ff67c2d8a394449ecb399e3b4c94..8ffc0ce64cd5565fc5d4911cecaa7f55e5e76416 100644 (file)
@@ -13,25 +13,16 @@ uniform vec3 sampleWeights[13];
 \r
 void main()\r
 {\r
-    if (renderState == 0) {\r
-        FragColor = texture(shadowmapTexture, TexCoords);\r
-    }\r
-    // stencil buffer\r
-    else if (renderState == 1 || texture(irradianceTexture, TexCoords).rgb == vec3(0, 0, 0)) {\r
-        FragColor = texture(irradianceTexture, TexCoords);\r
-    }\r
-    else if (renderState == 2) {\r
-        FragColor = texture(shadowmapTexture, TexCoords) * texture(irradianceTexture, TexCoords);\r
-    }\r
-    else if (renderState == 3) {\r
-        vec4 result = vec4(0, 0, 0, 1);\r
-        for (int i = 0; i < 13; i++) {\r
-            float oneX = 1.0/screenWidth;\r
-            float oneY = 1.0/screenHeight;\r
-            vec4 sample = texture(irradianceTexture, TexCoords + samplePositions[i] * vec2(oneX, oneY));\r
-            vec4 weight = vec4(sampleWeights[i], 1);\r
-            result += sample * weight;\r
-        }\r
-        FragColor = result;\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 sample = texture(irradianceTexture, sampleCoords)\r
+        //            * texture(shadowmapTexture, sampleCoords);\r
+        vec4 sample = texture(irradianceTexture, sampleCoords);\r
+        vec4 weight = vec4(sampleWeights[i], 1);\r
+        result += sample * weight;\r
     }\r
+    FragColor = result;\r
 }\r