treesummaryrefslogcommitdiff
path: root/shaders/fbo_frag.glsl
diff options
context:
space:
mode:
authorPatrick2021-03-26 19:36:35 +0100
committerPatrick2021-03-26 19:36:35 +0100
commitc99ecda7bed596922125f6b1ef1ef2ae8f27703e (patch)
tree16b3a22483457d22fdd34c1e079fd25dabd84940 /shaders/fbo_frag.glsl
parent36fb27a899045de24d71d55b06648abda7547268 (diff)
downloadsubsurface_scattering-c99ecda7bed596922125f6b1ef1ef2ae8f27703e.tar.gz
subsurface_scattering-c99ecda7bed596922125f6b1ef1ef2ae8f27703e.zip
SSSSS comments
Diffstat (limited to 'shaders/fbo_frag.glsl')
-rw-r--r--shaders/fbo_frag.glsl36
1 files changed, 4 insertions, 32 deletions
diff --git a/shaders/fbo_frag.glsl b/shaders/fbo_frag.glsl
index 1102992..f92483e 100644
--- a/shaders/fbo_frag.glsl
+++ b/shaders/fbo_frag.glsl
@@ -11,45 +11,17 @@ uniform int renderState;
uniform vec2 samplePositions[13];
uniform vec3 sampleWeights[13];
-vec4 blur(sampler2D tex, vec2 uv, vec2 res) {
- float Pi = 6.28318530718; // Pi*2
-
- // GAUSSIAN BLUR SETTINGS {{{
- float Directions = 16.0; // BLUR DIRECTIONS (Default 16.0 - More is better but slower)
- float Quality = 4.0; // BLUR QUALITY (Default 4.0 - More is better but slower)
- float Size = 8.0; // BLUR SIZE (Radius)
- // GAUSSIAN BLUR SETTINGS }}}
-
- vec2 Radius = Size/res;
-
- // Pixel colour
- vec4 Color = texture(tex, uv);
-
- // Blur calculations
- for( float d=0.0; d<Pi; d+=Pi/Directions) {
- for(float i=1.0/Quality; i<=1.0; i+=1.0/Quality) {
- Color += texture( tex, uv+vec2(cos(d),sin(d))*Radius*i);
- }
- }
-
- // Output to screen
- Color /= Quality * Directions - 15.0;
- return Color;
-}
-
void main()
{
if (renderState == 0) {
- FragColor = blur(shadowmapTexture, TexCoords, vec2(screenWidth, screenHeight));
- }
- else if (renderState == 1) {
FragColor = texture(shadowmapTexture, TexCoords);
}
- // stencil buffer
- else if (renderState == 2) {
+ else if (renderState == 1) {
FragColor = texture(irradianceTexture, TexCoords);
}
- else if (renderState == 3) {
+ else if (renderState == 2) {
+ // sample calculated irradiance
+ // using Gaussian kernel to approximate light spread
vec4 result = vec4(0, 0, 0, 1);
for (int i = 0; i < 13; i++) {
vec2 sampleCoords = TexCoords + samplePositions[i] * vec2(1.0/screenWidth, 1.0/screenHeight);