diff options
author | Samuel Fadel <samuelfadel@gmail.com> | 2016-01-07 15:46:35 +0100 |
---|---|---|
committer | Samuel Fadel <samuelfadel@gmail.com> | 2016-01-07 15:46:35 +0100 |
commit | 2732933ab21d2a7b43466a0c563182bc29611022 (patch) | |
tree | c44406a6596faf61307d04d7fdc572d1e5fe5e9e | |
parent | 04f9105bc10cd978adfcdce7a46673e1dc531c82 (diff) |
VoronoiSplat: rendering to transparent background, can now adapt to different backgrounds.
-rw-r--r-- | voronoisplat.cpp | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/voronoisplat.cpp b/voronoisplat.cpp index 4006af6..a0ac922 100644 --- a/voronoisplat.cpp +++ b/voronoisplat.cpp @@ -119,10 +119,7 @@ void main() { discard; else { vec4 accum = texelFetch(accumTex, ivec2(gl_FragCoord.xy), 0); - // 1.0 is extra-accumulated because of white background - float value = 0.0; - if (accum.g > 1.0) - value = (accum.r - 1) / (accum.g - 1); + float value = (accum.g == 0.0) ? 0.0 : accum.r / accum.g; fragColor.rgb = getRGB(value); fragColor.a = 1.0 - dt / rad_max; } @@ -250,14 +247,14 @@ bool VoronoiSplatTexture::updateTexture() gl.glEnable(GL_POINT_SPRITE); gl.glEnable(GL_PROGRAM_POINT_SIZE); gl.glEnable(GL_BLEND); - gl.glBlendFunc(GL_ONE, GL_ONE); + gl.glBlendFunc(GL_ONE, GL_ZERO); // First, we draw to an intermediate texture, which is used as input for the // second pass gl.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_textures[1], 0); - gl.glClearColor(1, 1, 1, 1); + gl.glClearColor(0, 0, 0, 1); gl.glClear(GL_COLOR_BUFFER_BIT); m_sitesVAO.bind(); @@ -286,7 +283,7 @@ bool VoronoiSplatTexture::updateTexture() gl.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_tex, 0); - glClearColor(1, 1, 1, 1); + glClearColor(0, 0, 0, 0); glClear(GL_COLOR_BUFFER_BIT); m_2ndPassVAO.bind(); |