GLSL pass setCamera()

:slight_smile:



Switching the camera associated to a pass (sketch, depht of field, bloom, motion blur) after it has been initialized:

(it's a revision of the 4059 jme version ( I don't have the internet at home, so it's not easy) hope it's ok  :slight_smile: )


Index: src/com/jmex/effects/glsl/MotionBlurRenderPass.java
===================================================================
--- src/com/jmex/effects/glsl/MotionBlurRenderPass.java   (revision 4059)
+++ src/com/jmex/effects/glsl/MotionBlurRenderPass.java   (working copy)
@@ -308,6 +308,14 @@
          }
       }
    }
+   
+   public void setCamera( Camera cam ) {
+      this.tRenderer.setCamera(cam);
+   }
+   
+   public void getCamera( Camera cam ) {
+      this.tRenderer.getCamera();
+   }
 
     public Texture getMainTexture() {
         return mainTexture;



Index: src/com/jmex/effects/glsl/DepthOfFieldRenderPass.java
===================================================================
--- src/com/jmex/effects/glsl/DepthOfFieldRenderPass.java   (revision 4059)
+++ src/com/jmex/effects/glsl/DepthOfFieldRenderPass.java   (working copy)
@@ -335,6 +335,14 @@
         r.draw(fullScreenQuad);
     }
 
+   public void setCamera( Camera cam ) {
+      this.tRenderer.setCamera(cam);
+   }
+   
+   public void getCamera( Camera cam ) {
+      this.tRenderer.getCamera();
+   }
+   
     /**
      * @return The throttle amount - or in other words, how much time in seconds
      *         must pass before the bloom effect is updated.



Index: src/com/jmex/effects/glsl/BloomRenderPass.java
===================================================================
--- src/com/jmex/effects/glsl/BloomRenderPass.java   (revision 4059)
+++ src/com/jmex/effects/glsl/BloomRenderPass.java   (working copy)
@@ -327,6 +327,14 @@
         r.draw(fullScreenQuad);
    }
 
+   public void setCamera( Camera cam ) {
+      this.tRenderer.setCamera(cam);
+   }
+   
+   public void getCamera( Camera cam ) {
+      this.tRenderer.getCamera();
+   }
+   
    /**
      * @return The throttle amount - or in other words, how much time in
      *         seconds must pass before the bloom effect is updated.



Index: src/com/jmex/effects/glsl/SketchRenderPass.java
===================================================================
--- src/com/jmex/effects/glsl/SketchRenderPass.java   (revision 4059)
+++ src/com/jmex/effects/glsl/SketchRenderPass.java   (working copy)
@@ -194,6 +194,14 @@
       r.draw(fullScreenQuad);
    }
 
+   public void setCamera( Camera cam ) {
+      this.tRendererDepth.setCamera(cam);
+   }
+   
+   public void getCamera( Camera cam ) {
+      this.tRendererDepth.getCamera();
+   }
+   
    /**
     * saves any states enforced by the user for replacement at the end of the
     * pass.



:)

What testing have you done with switching the camera after init?



(as always, your cat avatars makes me smile :))

Is it possible to combine them and turn on/off afterwards?

@basixs It's all tested, works in Bolidz for three months :slight_smile:


(as always, your cat avatars makes me smile smiley)



8)

@DarkPhoenixX You mean to combine the passes ? of course, disable them also :)

Robbing the KITTY??  What are you gonna get, his catnip stash??  :-o :-o



Unless anyone has any issues then, I think the patch(s) has been verified :).



Wanna submit it or shall I?

Can you do it, I can't for the moment …  :expressionless:



:slight_smile:


Hi there,



Can you please review your getters?

Yours:


+   public void getCamera( Camera cam ) {
+      this.tRendererDepth.getCamera();
+   }



Shouldnt it be


+   public Camera getCamera( ) {
+      return this.tRendererDepth.getCamera();
+   }


?

Greetz

nice one, didn't see that :wink:

yeah, nice catch alright…



kine, wanna remake your patches or should I just edit them?

I'll do that :slight_smile:






Hope they are correct this time :slight_smile:


Index: src/com/jmex/effects/glsl/BloomRenderPass.java
===================================================================
--- src/com/jmex/effects/glsl/BloomRenderPass.java   (revision 4059)
+++ src/com/jmex/effects/glsl/BloomRenderPass.java   (working copy)
@@ -399,4 +399,12 @@
     public boolean isUseSeparateConvolution() {
         return useSeparateConvolution;
     }
+   
+    public void setCamera(Camera camera) {
+      this.tRenderer.setCamera(camera);
+   }
+   
+    public Camera getCamera(Camera camera) {
+       return this.tRenderer.getCamera();
+   }
 }



Index: src/com/jmex/effects/glsl/DepthOfFieldRenderPass.java
===================================================================
--- src/com/jmex/effects/glsl/DepthOfFieldRenderPass.java   (revision 4059)
+++ src/com/jmex/effects/glsl/DepthOfFieldRenderPass.java   (working copy)
@@ -471,4 +471,12 @@
             draw(r);
         }
     }
+   
+   public void setCamera(Camera camera) {
+      this.tRenderer.setCamera(camera);
+   }
+   
+   public Camera getCamera(Camera camera) {
+      return this.tRenderer.getCamera();
+   }
 }



Index: src/com/jmex/effects/glsl/MotionBlurRenderPass.java
===================================================================
--- src/com/jmex/effects/glsl/MotionBlurRenderPass.java   (revision 4059)
+++ src/com/jmex/effects/glsl/MotionBlurRenderPass.java   (working copy)
@@ -336,4 +336,13 @@
    public void setBlurStrength( float blurStrength ) {
       this.blurStrength = blurStrength;
    }
+   
+   public void setCamera(Camera camera) {
+      this.cam = camera;
+      this.tRenderer.setCamera(camera);
+   }
+
+   public Camera getCamera(Camera camera) {
+      return this.cam;
+   }
 }



Index: src/com/jmex/effects/glsl/SketchRenderPass.java
===================================================================
--- src/com/jmex/effects/glsl/SketchRenderPass.java   (revision 4059)
+++ src/com/jmex/effects/glsl/SketchRenderPass.java   (working copy)
@@ -236,4 +236,16 @@
    public void setOff(float off) {
       this.off = off;
    }
+   
+   public void setCamera(Camera camera) {
+      this.tRendererDepth.setCamera(camera);
+      normShader.clearUniforms();
+      normShader.setUniform("nearClip", camera.getFrustumNear());
+      normShader.setUniform("diffClip", camera.getFrustumFar() - camera.getFrustumNear());
+
+   }
+   
+   public Camera getCamera(Camera camera) {
+      return this.tRendererDepth.getCamera();
+   }
 }



:)

but but but


+ public Camera getCamera(Camera camera) {
+ return this.tRendererDepth.getCamera();
+ }


why pass a reference to a getter ?  :)

hehe,



thank god for ECLIPSE and "Generate Getters and Setters"  :slight_smile:

I'll commit it soon :slight_smile: