From f8df2f00cc49909d5f4b6e96161001a13e6a9321 Mon Sep 17 00:00:00 2001 From: "sha..rd" Date: Wed, 6 Jul 2011 01:40:42 +0000 Subject: [PATCH] * Fixed syntax errors and crashes with shadow processor and filters git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7831 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../MatDefs/Shadow/PostShadowPSSM15.frag | 5 +-- .../Common/ShaderLib/MultiSample.glsllib | 34 +++++++++++-------- .../com/jme3/post/FilterPostProcessor.java | 3 -- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/engine/src/core-data/Common/MatDefs/Shadow/PostShadowPSSM15.frag b/engine/src/core-data/Common/MatDefs/Shadow/PostShadowPSSM15.frag index 18b4c816a..393a2b1fb 100644 --- a/engine/src/core-data/Common/MatDefs/Shadow/PostShadowPSSM15.frag +++ b/engine/src/core-data/Common/MatDefs/Shadow/PostShadowPSSM15.frag @@ -1,4 +1,5 @@ -#extension GL_ARB_texture_gather : enable +// Because gpu_shader5 is actually where those +// gather functions are declared to work on shadowmaps #extension GL_ARB_gpu_shader5 : enable #ifdef HARDWARE_SHADOWS @@ -82,7 +83,7 @@ float Shadow_DoBilinear_2x2(in SHADOWMAP tex, in vec4 projCoord){ return 1.0; ivec2 texSize = textureSize(tex, 0); - #ifdef GL_ARB_texture_gather + #ifdef GL_ARB_gpu_shader5 vec4 coord = vec4(projCoord.xyz / projCoord.w,0.0); vec4 gather = SHADOWGATHER(tex, coord); #else diff --git a/engine/src/core-data/Common/ShaderLib/MultiSample.glsllib b/engine/src/core-data/Common/ShaderLib/MultiSample.glsllib index f5936c008..e4d46b40d 100644 --- a/engine/src/core-data/Common/ShaderLib/MultiSample.glsllib +++ b/engine/src/core-data/Common/ShaderLib/MultiSample.glsllib @@ -1,4 +1,5 @@ #extension GL_ARB_texture_multisample : enable + uniform int m_NumSamples; uniform int m_NumSamplesDepth; @@ -14,6 +15,8 @@ uniform int m_NumSamplesDepth; #define DEPTHTEXTURE sampler2D #endif +// NOTE: Only define multisample functions if multisample is being used! +#ifdef GL_ARB_texture_multisample vec4 textureFetch(in sampler2DMS tex,in vec2 texC, in int numSamples){ ivec2 iTexC = ivec2(texC * textureSize(tex)); vec4 color = vec4(0.0); @@ -23,36 +26,37 @@ vec4 textureFetch(in sampler2DMS tex,in vec2 texC, in int numSamples){ return color / numSamples; } -vec4 fetchTextureSample(in sampler2D tex,in vec2 texC,in int sample){ - return texture2D(tex,texC); -} - vec4 fetchTextureSample(in sampler2DMS tex,in vec2 texC,in int sample){ ivec2 iTexC = ivec2(texC * textureSize(tex)); return texelFetch(tex, iTexC, sample); } -vec4 getColor(in sampler2D tex, in vec2 texC){ - return texture2D(tex,texC); -} - vec4 getColor(in sampler2DMS tex, in vec2 texC){ return textureFetch(tex, texC, m_NumSamples); } -vec4 getColorSingle(in sampler2D tex, in vec2 texC){ - return texture2D(tex, texC); -} - vec4 getColorSingle(in sampler2DMS tex, in vec2 texC){ ivec2 iTexC = ivec2(texC * textureSize(tex)); return texelFetch(tex, iTexC, 0); } -vec4 getDepth(in sampler2D tex,in vec2 texC){ +vec4 getDepth(in sampler2DMS tex,in vec2 texC){ + return textureFetch(tex,texC,m_NumSamplesDepth); +} +#endif + +vec4 fetchTextureSample(in sampler2D tex,in vec2 texC,in int sample){ return texture2D(tex,texC); } -vec4 getDepth(in sampler2DMS tex,in vec2 texC){ - return textureFetch(tex,texC,m_NumSamplesDepth); +vec4 getColor(in sampler2D tex, in vec2 texC){ + return texture2D(tex,texC); } + +vec4 getColorSingle(in sampler2D tex, in vec2 texC){ + return texture2D(tex, texC); +} + +vec4 getDepth(in sampler2D tex,in vec2 texC){ + return texture2D(tex,texC); +} \ No newline at end of file diff --git a/engine/src/core/com/jme3/post/FilterPostProcessor.java b/engine/src/core/com/jme3/post/FilterPostProcessor.java index cc7680343..3ee7a72cc 100644 --- a/engine/src/core/com/jme3/post/FilterPostProcessor.java +++ b/engine/src/core/com/jme3/post/FilterPostProcessor.java @@ -40,7 +40,6 @@ import com.jme3.export.InputCapsule; import com.jme3.export.OutputCapsule; import com.jme3.export.Savable; import com.jme3.material.Material; -import com.jme3.material.RenderState; import com.jme3.renderer.Camera; import com.jme3.renderer.Caps; import com.jme3.renderer.RenderManager; @@ -140,7 +139,6 @@ public class FilterPostProcessor implements SceneProcessor, Savable { Camera cam = vp.getCamera(); - //save view port diensions left = cam.getViewPortLeft(); right = cam.getViewPortRight(); @@ -150,7 +148,6 @@ public class FilterPostProcessor implements SceneProcessor, Savable { originalHeight = cam.getHeight(); //first call to reshape reshape(vp, cam.getWidth(), cam.getHeight()); - } /**