com.jmex.effects.glsl
Class DepthOfFieldRenderPass

java.lang.Object
  extended by com.jme.renderer.pass.Pass
      extended by com.jmex.effects.glsl.DepthOfFieldRenderPass
All Implemented Interfaces:
java.io.Serializable

public class DepthOfFieldRenderPass
extends Pass

GLSL Depth of Field effect pass. - Creating a depth texture with a root Spatial and its subspatials - Use it on full screen texture downsampled to blur it with stronger opacity and blurring on far away parts - render result (unblended) on the screen overwriting with the blurred parts.

Author:
Paul Illes - initial implementation of DepthOfFieldRenderPass for jME 1.0 based on partially MrCorder's shaders plus : about original Ogre DoF demo: "Depth of Field" demo for Ogre Copyright (C) 2006 Christian Lindequist Larsen This code is in the public domain. You may do whatever you want with it. - Used from that part the depth shader with some modifications., (MrCoder) - initial implementation of BloomRenderPass (original pass), Joshua Slack - Enhancements and reworking to use a single texrenderer, ability to reuse existing back buffer, faster blur, throttling speed-up, etc.
See Also:
Serialized Form

Field Summary
 float blurrinessCutoff
          The cut off point where we stop blurring
 float farBlurDepth
          The depth at which we're at full blur
 float focalPlaneDepth
          The depth at which the viewer is focussing
 float nearBlurDepth
          The depth at which blur starts
 
Fields inherited from class com.jme.renderer.pass.Pass
context, enabled, passStates, savedStates, spatials, zFactor, zOffset
 
Constructor Summary
DepthOfFieldRenderPass(Camera cam, int renderScale)
          Creates a new DOG renderpass
 
Method Summary
 void cleanup()
          Release pbuffers in TextureRenderer's.
 void doRender(Renderer r)
           
protected  void doUpdate(float tpf)
           
 float getBlurrinessCutoff()
          Get the blur cut off value
 float getBlurSize()
          Get the size of the blur kernal
 float getFarBlurDepth()
          Get the depth at which blur is at it's maximum
 float getFocalPlaneDepth()
          Get the focus depth of the viewer
 float getNearBlurDepth()
          Get the depth at which blur starts
 float getThrottle()
           
 boolean isSupported()
          Check if this pass is supported
protected  void replaceEnforcedStates()
          replaces any states enforced by the user at the end of the pass.
 void resetParameters()
          Reset bloom parameters to default
protected  void saveEnforcedStates()
          saves any states enforced by the user for replacement at the end of the pass.
 void setBlurrinessCutoff(float blurrinessCutoff)
          Set the cutoff depth at which blurring stops
 void setBlurSize(float blurSize)
          Set the size of the blur kernal
 void setFarBlurDepth(float farBlurDepth)
          Set the depth at which blur is at it's maximum
 void setFocalPlaneDepth(float focalPlaneDepth)
          Set the focus depth of the viewer
 void setNearBlurDepth(float nearBlurDepth)
          Set the depth at which blur starts
 void setThrottle(float throttle)
           
 
Methods inherited from class com.jme.renderer.pass.Pass
add, applyPassStates, cleanUp, clearPassState, clearPassState, clearPassStates, contains, get, getRenderState, getRenderState, getZFactor, getZOffset, isEnabled, remove, removeAll, renderPass, resetOldStates, setEnabled, setPassState, setZFactor, setZOffset, size, updatePass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nearBlurDepth

public float nearBlurDepth
The depth at which blur starts


focalPlaneDepth

public float focalPlaneDepth
The depth at which the viewer is focussing


farBlurDepth

public float farBlurDepth
The depth at which we're at full blur


blurrinessCutoff

public float blurrinessCutoff
The cut off point where we stop blurring

Constructor Detail

DepthOfFieldRenderPass

public DepthOfFieldRenderPass(Camera cam,
                              int renderScale)
Creates a new DOG renderpass

Parameters:
cam - Camera used for rendering the bloomsource
renderScale - Scale of bloom texture
Method Detail

resetParameters

public void resetParameters()
Reset bloom parameters to default


cleanup

public void cleanup()
Release pbuffers in TextureRenderer's. Preferably called from user cleanup method.


isSupported

public boolean isSupported()
Check if this pass is supported

Returns:
True if this render pass is supported

doUpdate

protected void doUpdate(float tpf)
Overrides:
doUpdate in class Pass

saveEnforcedStates

protected void saveEnforcedStates()
saves any states enforced by the user for replacement at the end of the pass.


replaceEnforcedStates

protected void replaceEnforcedStates()
replaces any states enforced by the user at the end of the pass.


doRender

public void doRender(Renderer r)
Specified by:
doRender in class Pass
See Also:
Pass.doRender(com.jme.renderer.Renderer)

getThrottle

public float getThrottle()
Returns:
The throttle amount - or in other words, how much time in seconds must pass before the bloom effect is updated.

setThrottle

public void setThrottle(float throttle)
Parameters:
throttle - The throttle amount - or in other words, how much time in seconds must pass before the bloom effect is updated.

getBlurSize

public float getBlurSize()
Get the size of the blur kernal

Returns:
The size of the blur kernal

setBlurSize

public void setBlurSize(float blurSize)
Set the size of the blur kernal

Parameters:
blurSize - The size of the blur kernal

getNearBlurDepth

public float getNearBlurDepth()
Get the depth at which blur starts

Returns:
The depth at which blur starts

setNearBlurDepth

public void setNearBlurDepth(float nearBlurDepth)
Set the depth at which blur starts

Parameters:
nearBlurDepth - The depth at which blur starts

getFocalPlaneDepth

public float getFocalPlaneDepth()
Get the focus depth of the viewer

Returns:
The focus depth of the viewer

setFocalPlaneDepth

public void setFocalPlaneDepth(float focalPlaneDepth)
Set the focus depth of the viewer


getFarBlurDepth

public float getFarBlurDepth()
Get the depth at which blur is at it's maximum

Returns:
The depth at which blur is at it's maximum

setFarBlurDepth

public void setFarBlurDepth(float farBlurDepth)
Set the depth at which blur is at it's maximum


getBlurrinessCutoff

public float getBlurrinessCutoff()
Get the blur cut off value

Returns:
The blur cut off value

setBlurrinessCutoff

public void setBlurrinessCutoff(float blurrinessCutoff)
Set the cutoff depth at which blurring stops

Parameters:
blurrinessCutoff - The depth at which blurring stops