Browse Source

Filter Pass can now render its own depth buffer

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8088 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
rem..om 14 years ago
parent
commit
27c5b3cfb0
1 changed files with 13 additions and 1 deletions
  1. 13 1
      engine/src/core/com/jme3/post/Filter.java

+ 13 - 1
engine/src/core/com/jme3/post/Filter.java

@@ -99,14 +99,22 @@ public abstract class Filter implements Savable {
          * @param depthBufferFormat
          * @param depthBufferFormat
          * @param numSamples 
          * @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();
             Collection<Caps> caps = renderer.getCaps();
             if (numSamples > 1 && caps.contains(Caps.FrameBufferMultisample) && caps.contains(Caps.OpenGL31)) {
             if (numSamples > 1 && caps.contains(Caps.FrameBufferMultisample) && caps.contains(Caps.OpenGL31)) {
                 renderFrameBuffer = new FrameBuffer(width, height, numSamples);
                 renderFrameBuffer = new FrameBuffer(width, height, numSamples);
                 renderedTexture = new Texture2D(width, height, numSamples, textureFormat);
                 renderedTexture = new Texture2D(width, height, numSamples, textureFormat);
+                if(renderDepth){
+                    depthTexture = new Texture2D(width, height, numSamples, depthBufferFormat);
+                    renderFrameBuffer.setDepthTexture(depthTexture);
+                }
             } else {
             } else {
                 renderFrameBuffer = new FrameBuffer(width, height, 1);
                 renderFrameBuffer = new FrameBuffer(width, height, 1);
                 renderedTexture = new Texture2D(width, height, textureFormat);
                 renderedTexture = new Texture2D(width, height, textureFormat);
+                if(renderDepth){
+                    depthTexture = new Texture2D(width, height, depthBufferFormat);
+                    renderFrameBuffer.setDepthTexture(depthTexture);
+                }
             }
             }
 
 
             renderFrameBuffer.setColorTexture(renderedTexture);
             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) {
         public void init(Renderer renderer, int width, int height, Format textureFormat, Format depthBufferFormat) {
             init(renderer, width, height, textureFormat, depthBufferFormat, 1);
             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
          *  init the pass called internally