From 224645d1071c14b4829dbb3ae35870868fcff85a Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 13 Feb 2018 23:00:10 -0500 Subject: Fixed inconsistent rendering failure The issue appears to have been caused by blending with unset alpha channels. Also included the re-ordered player character sprite image. The CMake file has been updated to include linking against some Apple libraries that are usually already included in GLFW3. refs #1 --- shaders/bloom1.fragment | 11 ++++++----- shaders/bloom2.fragment | 26 ++++++++++++++------------ shaders/fill.fragment | 4 ++-- shaders/final.fragment | 4 ++-- shaders/ntsc.fragment | 4 ++-- 5 files changed, 26 insertions(+), 23 deletions(-) (limited to 'shaders') diff --git a/shaders/bloom1.fragment b/shaders/bloom1.fragment index 0a89ea1..ed9e10d 100644 --- a/shaders/bloom1.fragment +++ b/shaders/bloom1.fragment @@ -2,15 +2,16 @@ in vec2 UV; -out vec3 color; +out vec4 color; uniform vec2 offset; uniform sampler2D inTex; void main() { - color = vec3(0.0); - color += (5.0/16.0) * texture(inTex, UV - offset).rgb; - color += (6.0/16.0) * texture(inTex, UV).rgb; - color += (5.0/16.0) * texture(inTex, UV + offset).rgb; + vec3 mval = vec3(0.0); + mval += (5.0/16.0) * texture(inTex, UV - offset).rgb; + mval += (6.0/16.0) * texture(inTex, UV).rgb; + mval += (5.0/16.0) * texture(inTex, UV + offset).rgb; + color = vec4(mval, 1.0); } diff --git a/shaders/bloom2.fragment b/shaders/bloom2.fragment index 4c50e86..6723c2c 100644 --- a/shaders/bloom2.fragment +++ b/shaders/bloom2.fragment @@ -2,7 +2,7 @@ in vec2 UV; -out vec3 color; +out vec4 color; uniform sampler2D clearTex; uniform sampler2D blurTex; @@ -15,19 +15,21 @@ float nrand(vec2 n) void main() { - color = vec3(0.0); - color += texture(clearTex, UV).rgb / 2.0; - color += texture(blurTex, UV).rgb; - color = max(vec3(0.0), color - 0.5); - color *= color; - + vec3 mval = vec3(0.0); + mval += texture(clearTex, UV).rgb / 2.0; + mval += texture(blurTex, UV).rgb; + mval = max(vec3(0.0), mval - 0.5); + mval *= mval; + float flicker = 0.5 + nrand(vec2(iGlobalTime)); flicker *= (flicker); //flicker = sqrt(flicker); //flicker = pow(flicker, 1.0/8.0); - //color *= flicker; - color *= mix(vec3(0.0), color, flicker); - - color += texture(clearTex, UV).rgb; - color = clamp(color, vec3(0.0), vec3(1.0)); + //mval *= flicker; + mval *= mix(vec3(0.0), mval, flicker); + + mval += texture(clearTex, UV).rgb; + mval = clamp(mval, vec3(0.0), vec3(1.0)); + + color = vec4(mval, 1.0); } diff --git a/shaders/fill.fragment b/shaders/fill.fragment index ab7d9c9..81443c4 100644 --- a/shaders/fill.fragment +++ b/shaders/fill.fragment @@ -1,10 +1,10 @@ #version 330 core -out vec3 color; +out vec4 color; uniform vec3 vecColor; void main() { - color = vecColor; + color = vec4(vecColor, 1.0); } diff --git a/shaders/final.fragment b/shaders/final.fragment index a3ee243..9a39597 100644 --- a/shaders/final.fragment +++ b/shaders/final.fragment @@ -5,7 +5,7 @@ in vec3 normIn; in vec3 camDirIn; in vec3 lightDirIn; -out vec3 color; +out vec4 color; uniform sampler2D rendertex; uniform sampler2D scanlinestex; @@ -71,5 +71,5 @@ void main() vec4 nearfinal = colorfres + colordiff + colorspec + emissive; //vec4 final = nearfinal * mix(vec4(1,1,1,1), vec4(0,0,0, 0), Tuning_Dimming); - color = nearfinal.rgb; + color = nearfinal; } diff --git a/shaders/ntsc.fragment b/shaders/ntsc.fragment index 56fb1c4..d6ae904 100644 --- a/shaders/ntsc.fragment +++ b/shaders/ntsc.fragment @@ -2,7 +2,7 @@ in vec2 UV; -out vec3 color; +out vec4 color; uniform sampler2D curFrameSampler; uniform sampler2D NTSCArtifactSampler; @@ -61,5 +61,5 @@ void main() Cur_Local = clamp(Cur_Local + (offset * Tuning_Sharp * mix(vec4(1,1,1,1), NTSCArtifact, Tuning_NTSC)), vec4(0,0,0,0), vec4(1,1,1,1)); Cur_Local = clamp(max(Cur_Local, Tuning_Persistence * (1.0 / (1.0 + (2.0 * Tuning_Bleed))) * (Prev_Local + ((Prev_Left + Prev_Right) * Tuning_Bleed))), vec4(0,0,0,0), vec4(1,1,1,1)); - color = Cur_Local.xyz; + color = vec4(Cur_Local.rgb, 1.0); } -- cgit 1.4.1