From 21bf7f4df3794dd53257bcab5381393f0566dea9 Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 1 Mar 2016 11:03:16 +0100 Subject: [PATCH 1/2] Glow should now legit be working through transparency. --- resources/Shaders/ForwardPlus.frag.glsl | 8 ++++---- src/Engine/Rendering/DrawFinalPass.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 6fbc9c27..a3230eb1 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -169,8 +169,8 @@ void main() vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); - float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; - color_result = color_result * clamp(1/specularTexel, 0, 1)*2 + reflectionColor * clamp(specularTexel, 0, 1)/2; + //float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; + //color_result = color_result * clamp(1/specularTexel, 0, 1)*2 + reflectionColor * clamp(specularTexel, 0, 1)/2; //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; @@ -181,9 +181,9 @@ void main() } sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); //sceneColor = vec4(reflectionColor.xyz, 1); - color_result += glowTexel*GlowIntensity; + color_result.xyz += glowTexel.xyz*GlowIntensity; - bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), clamp(color_result.a, 0, 1)); + bloomColor = vec4(max(color_result.xyz - 1.0, 0.0), clamp(color_result.a, 0, 1)); //Tiled Debug Code /* diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 6cd2c1f1..d084b919 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -193,10 +193,12 @@ void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture) state->StencilMask(0x00); DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture); GLERROR("OpaqueObjects"); - state->BlendFunc(GL_ONE, GL_ONE); + //state->BlendFunc(GL_ONE, GL_ONE); + state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture); GLERROR("TransparentObjects"); - state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + //state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); DrawSprites(scene.Jobs.SpriteJob, scene); GLERROR("SpriteJobs"); From eaea6450682e01935acff5e2bb571d629db92803 Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 1 Mar 2016 11:19:44 +0100 Subject: [PATCH 2/2] Reflectance should now work as an inverse of the specular alpha value. --- resources/Shaders/ForwardPlus.frag.glsl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index a3230eb1..d88154ef 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -169,8 +169,9 @@ void main() vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); - //float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; - //color_result = color_result * clamp(1/specularTexel, 0, 1)*2 + reflectionColor * clamp(specularTexel, 0, 1)/2; + float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; + vec4 reflectionTotal = reflectionColor * (1-specularTexel.a) * color_result.a; + color_result = color_result * clamp(1/specularTexel.a, 0, 1) + reflectionTotal; //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color;