X-Git-Url: https://gitweb.ps.run/subsurface_scattering/blobdiff_plain/7a181bdf261b620adb266a4f6b485a0afd1ed306..0a5e8172a6ee0e79c81eec21a9966bea9385b249:/shaders/fbo_frag.glsl diff --git a/shaders/fbo_frag.glsl b/shaders/fbo_frag.glsl index e199245..f92483e 100644 --- a/shaders/fbo_frag.glsl +++ b/shaders/fbo_frag.glsl @@ -16,19 +16,18 @@ void main() if (renderState == 0) { FragColor = texture(shadowmapTexture, TexCoords); } - // stencil buffer - else if (renderState == 1 || texture(irradianceTexture, TexCoords).rgb == vec3(0, 0, 0)) { + else if (renderState == 1) { FragColor = texture(irradianceTexture, TexCoords); } else if (renderState == 2) { - FragColor = texture(shadowmapTexture, TexCoords) * texture(irradianceTexture, TexCoords); - } - else if (renderState == 3) { + // sample calculated irradiance + // using Gaussian kernel to approximate light spread vec4 result = vec4(0, 0, 0, 1); for (int i = 0; i < 13; i++) { - float oneX = 1.0/screenWidth; - float oneY = 1.0/screenHeight; - vec4 sample = texture(irradianceTexture, TexCoords + samplePositions[i] * vec2(oneX, oneY)); + vec2 sampleCoords = TexCoords + samplePositions[i] * vec2(1.0/screenWidth, 1.0/screenHeight); + //vec4 sample = texture(irradianceTexture, sampleCoords) + // * texture(shadowmapTexture, sampleCoords); + vec4 sample = texture(irradianceTexture, sampleCoords); vec4 weight = vec4(sampleWeights[i], 1); result += sample * weight; }