OSDN Git Service

Filter Pass can now render its own depth buffer
authorremy.bouquet@gmail.com <remy.bouquet@gmail.com@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Thu, 25 Aug 2011 16:41:28 +0000 (16:41 +0000)
committerremy.bouquet@gmail.com <remy.bouquet@gmail.com@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Thu, 25 Aug 2011 16:41:28 +0000 (16:41 +0000)
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@8088 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

engine/src/core/com/jme3/post/Filter.java

index 87eff45..a6ae265 100644 (file)
@@ -99,14 +99,22 @@ public abstract class Filter implements Savable {
          * @param depthBufferFormat
          * @param numSamples 
          */
-        public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat, int numSamples) {
+        public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat, int numSamples, boolean renderDepth) {
             Collection<Caps> caps = renderer.getCaps();
             if (numSamples > 1 && caps.contains(Caps.FrameBufferMultisample) && caps.contains(Caps.OpenGL31)) {
                 renderFrameBuffer = new FrameBuffer(width, height, numSamples);
                 renderedTexture = new Texture2D(width, height, numSamples, textureFormat);
+                if(renderDepth){
+                    depthTexture = new Texture2D(width, height, numSamples, depthBufferFormat);
+                    renderFrameBuffer.setDepthTexture(depthTexture);
+                }
             } else {
                 renderFrameBuffer = new FrameBuffer(width, height, 1);
                 renderedTexture = new Texture2D(width, height, textureFormat);
+                if(renderDepth){
+                    depthTexture = new Texture2D(width, height, depthBufferFormat);
+                    renderFrameBuffer.setDepthTexture(depthTexture);
+                }
             }
 
             renderFrameBuffer.setColorTexture(renderedTexture);
@@ -125,6 +133,10 @@ public abstract class Filter implements Savable {
         public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat) {
             init(renderer, width, height, textureFormat, depthBufferFormat, 1);
         }
+        
+        public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat, int numSamples) {
+           init(renderer, width, height, textureFormat, depthBufferFormat, numSamples, false);
+        }
 
         /**
          *  init the pass called internally