From 109c5e80cf0645a5fef16f4aee89831cf5b9b302 Mon Sep 17 00:00:00 2001 From: Daniel Johansson Date: Thu, 24 Sep 2015 13:41:22 +0100 Subject: [PATCH] Fixed #316 where some post processing effects were not working when using OPENGL_3 renderer due to an error in the fragment shader. --- .../main/resources/Common/MatDefs/Post/CrossHatch15.frag | 6 ++++-- .../main/resources/Common/MatDefs/Post/DepthOfField15.frag | 6 ++++-- .../src/main/resources/Common/MatDefs/Post/Fade15.frag | 3 ++- .../src/main/resources/Common/MatDefs/Post/Fog15.frag | 3 ++- .../src/main/resources/Common/MatDefs/Post/Overlay15.frag | 3 ++- .../main/resources/Common/MatDefs/Post/Posterization15.frag | 5 +++-- .../main/resources/Common/MatDefs/Post/bloomFinal15.frag | 3 ++- .../src/main/resources/Common/MatDefs/SSAO/ssaoBlur15.frag | 3 ++- 8 files changed, 21 insertions(+), 11 deletions(-) diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/CrossHatch15.frag b/jme3-effects/src/main/resources/Common/MatDefs/Post/CrossHatch15.frag index 8daa4f7fd..842484604 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/CrossHatch15.frag +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/CrossHatch15.frag @@ -17,7 +17,9 @@ uniform float m_Luminance5; uniform float m_LineDistance; uniform float m_LineThickness; - + +out vec4 fragColor; + void main() { vec4 texVal = getColor(m_Texture, texCoord); float linePixel = 0; @@ -49,5 +51,5 @@ void main() { // Mix paper color with existing color information vec4 paperColor = mix(m_PaperColor, texVal, m_ColorInfluencePaper); - gl_FragColor = mix(paperColor, lineColor, linePixel); + fragColor = mix(paperColor, lineColor, linePixel); } \ No newline at end of file diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/DepthOfField15.frag b/jme3-effects/src/main/resources/Common/MatDefs/Post/DepthOfField15.frag index 80cf3c530..de3c586ae 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/DepthOfField15.frag +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/DepthOfField15.frag @@ -11,6 +11,8 @@ uniform float m_YScale; vec2 m_NearFar = vec2( 0.1, 1000.0 ); +out vec4 fragColor; + void main() { vec4 texVal = getColor( m_Texture, texCoord ); @@ -44,7 +46,7 @@ void main() { if( unfocus < 0.2 ) { // If we are mostly in focus then don't bother with the // convolution filter - gl_FragColor = texVal; + fragColor = texVal; } else { // Perform a wide convolution filter and we scatter it // a bit to avoid some texture look-ups. Instead of @@ -83,7 +85,7 @@ void main() { sum = sum / 12.0; - gl_FragColor = mix( texVal, sum, unfocus ); + fragColor = mix( texVal, sum, unfocus ); // I used this for debugging the range // gl_FragColor.r = unfocus; diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/Fade15.frag b/jme3-effects/src/main/resources/Common/MatDefs/Post/Fade15.frag index c99de34ad..7bd2d4882 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/Fade15.frag +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/Fade15.frag @@ -4,8 +4,9 @@ uniform COLORTEXTURE m_Texture; uniform float m_Value; in vec2 texCoord; +out vec4 fragColor; void main() { vec4 texVal = getColor(m_Texture, texCoord); - gl_FragColor = texVal * m_Value; + fragColor = texVal * m_Value; } \ No newline at end of file diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/Fog15.frag b/jme3-effects/src/main/resources/Common/MatDefs/Post/Fog15.frag index 65a340723..7a1f756be 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/Fog15.frag +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/Fog15.frag @@ -8,6 +8,7 @@ uniform float m_FogDensity; uniform float m_FogDistance; in vec2 texCoord; +out vec4 fragColor; vec2 m_FrustumNearFar=vec2(1.0,m_FogDistance); const float LOG2 = 1.442695; @@ -19,6 +20,6 @@ void main() { float fogFactor = exp2( -m_FogDensity * m_FogDensity * depth * depth * LOG2 ); fogFactor = clamp(fogFactor, 0.0, 1.0); - gl_FragColor =mix(m_FogColor,texVal,fogFactor); + fragColor =mix(m_FogColor,texVal,fogFactor); } \ No newline at end of file diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/Overlay15.frag b/jme3-effects/src/main/resources/Common/MatDefs/Post/Overlay15.frag index 7dc4d1e4b..d6609f38f 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/Overlay15.frag +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/Overlay15.frag @@ -3,9 +3,10 @@ uniform COLORTEXTURE m_Texture; uniform vec4 m_Color; in vec2 texCoord; +out vec4 fragColor; void main() { vec4 texVal = getColor(m_Texture, texCoord); - gl_FragColor = texVal * m_Color; + fragColor = texVal * m_Color; } diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/Posterization15.frag b/jme3-effects/src/main/resources/Common/MatDefs/Post/Posterization15.frag index f55ac5bf2..5d8d7072b 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/Posterization15.frag +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/Posterization15.frag @@ -2,7 +2,8 @@ uniform COLORTEXTURE m_Texture; in vec2 texCoord; - +out vec4 fragColor; + uniform int m_NumColors; uniform float m_Gamma; uniform float m_Strength; @@ -16,5 +17,5 @@ void main() { texVal = texVal / m_NumColors; texVal = pow(texVal, vec4(1.0/m_Gamma)); - gl_FragColor = mix(getColor(m_Texture, texCoord), texVal, m_Strength); + fragColor = mix(getColor(m_Texture, texCoord), texVal, m_Strength); } \ No newline at end of file diff --git a/jme3-effects/src/main/resources/Common/MatDefs/Post/bloomFinal15.frag b/jme3-effects/src/main/resources/Common/MatDefs/Post/bloomFinal15.frag index 34268c565..b8f322d11 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/Post/bloomFinal15.frag +++ b/jme3-effects/src/main/resources/Common/MatDefs/Post/bloomFinal15.frag @@ -6,10 +6,11 @@ uniform sampler2D m_BloomTex; uniform float m_BloomIntensity; in vec2 texCoord; +out vec4 fragColor; void main(){ vec4 colorRes = getColor(m_Texture,texCoord); vec4 bloom = texture2D(m_BloomTex, texCoord); - gl_FragColor = bloom * m_BloomIntensity + colorRes; + fragColor = bloom * m_BloomIntensity + colorRes; } diff --git a/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssaoBlur15.frag b/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssaoBlur15.frag index c1112b23b..be2e6bcde 100644 --- a/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssaoBlur15.frag +++ b/jme3-effects/src/main/resources/Common/MatDefs/SSAO/ssaoBlur15.frag @@ -10,6 +10,7 @@ uniform float m_YScale; uniform vec2 m_FrustumNearFar; in vec2 texCoord; +out vec4 fragColor; vec4 getResult(vec4 color){ @@ -125,7 +126,7 @@ float readDepth(in vec2 uv){ void main(){ // float depth =texture2D(m_DepthTexture,uv).r; - gl_FragColor=getResult(convolutionFilter()); + fragColor=getResult(convolutionFilter()); // gl_FragColor=getResult(bilateralFilter()); // gl_FragColor=getColor(m_SSAOMap,texCoord);