Package com.jme3.post.filters
Class DepthOfFieldFilter
java.lang.Object
com.jme3.post.Filter
com.jme3.post.filters.DepthOfFieldFilter
- All Implemented Interfaces:
- Savable
A post-processing filter that performs a depth range
  blur using a scaled convolution filter.
- 
Nested Class SummaryNested classes/interfaces inherited from class com.jme3.post.FilterFilter.Pass
- 
Field SummaryFields inherited from class com.jme3.post.FilterdefaultPass, enabled, material, postRenderPasses, processor
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionfloatreturns the blur scalefloatreturns the blur threshold.booleanfloatreturns the focus distancefloatreturns the focus rangeprotected MaterialMust return the material used for this filter.protected voidinitFilter(AssetManager assets, RenderManager renderManager, ViewPort vp, int w, int h) Initialization of filter subclasses.protected booleanOverride this method and return true if your Filter needs the depth texturevoidread(JmeImporter im) Override this method if you want to load extra properties when the filter is loaded else only basic properties of the filter will be loaded This method should always begin by super.read(im);voidsetBlurScale(float f) Sets the blur amount by scaling the convolution filter up or down.voidsetBlurThreshold(float f) Sets the minimum blur factor before the convolution filter is calculated.voidsetDebugUnfocus(boolean b) Turns on/off debugging of the 'unfocus' value that is used to mix the convolution filter.voidsetFocusDistance(float f) Sets the distance at which objects are purely in focus.voidsetFocusRange(float f) Sets the range to either side of focusDistance where the objects go gradually out of focus.voidwrite(JmeExporter ex) Override this method if you want to save extra properties when the filter is saved else only basic properties of the filter will be saved This method should always begin by super.write(ex);Methods inherited from class com.jme3.post.Filtercleanup, cleanUpFilter, getDefaultPassDepthFormat, getDefaultPassTextureFormat, getName, getPostRenderPasses, getRenderedTexture, getRenderFrameBuffer, init, isEnabled, isRequiresBilinear, isRequiresSceneTexture, postFilter, postFrame, postQueue, preFrame, setDepthTexture, setEnabled, setName, setProcessor, setRenderedTexture, setRenderFrameBuffer
- 
Constructor Details- 
DepthOfFieldFilterpublic DepthOfFieldFilter()Creates a DepthOfField filter
 
- 
- 
Method Details- 
isRequiresDepthTextureprotected boolean isRequiresDepthTexture()Description copied from class:FilterOverride this method and return true if your Filter needs the depth texture- Overrides:
- isRequiresDepthTexturein class- Filter
- Returns:
- true if your Filter need the depth texture
 
- 
getMaterialDescription copied from class:FilterMust return the material used for this filter. this method is called every frame.- Specified by:
- getMaterialin class- Filter
- Returns:
- the material used for this filter.
 
- 
initFilterprotected void initFilter(AssetManager assets, RenderManager renderManager, ViewPort vp, int w, int h) Description copied from class:FilterInitialization of filter subclasses. This method is called once when the filter is added to the FilterPostProcessor It should contain Material initializations and extra passes initialization- Specified by:
- initFilterin class- Filter
- Parameters:
- assets- the assetManager
- renderManager- the renderManager
- vp- the viewPort where this filter is rendered
- w- the width of the filter
- h- the height of the filter
 
- 
setFocusDistancepublic void setFocusDistance(float f) Sets the distance at which objects are purely in focus.- Parameters:
- f- the desired distance (in world units, default=50)
 
- 
getFocusDistancepublic float getFocusDistance()returns the focus distance- Returns:
- the distance
 
- 
setFocusRangepublic void setFocusRange(float f) Sets the range to either side of focusDistance where the objects go gradually out of focus. Less than focusDistance - focusRange and greater than focusDistance + focusRange, objects are maximally "blurred".- Parameters:
- f- the desired half extent (in world units, default=10)
 
- 
getFocusRangepublic float getFocusRange()returns the focus range- Returns:
- the distance
 
- 
setBlurScalepublic void setBlurScale(float f) Sets the blur amount by scaling the convolution filter up or down. A value of 1 (the default) performs a sparse 5x5 evenly distributed convolution at pixel level accuracy. Higher values skip more pixels, and so on until you are no longer blurring the image but simply hashing it. The sparse convolution is as follows: %MINIFYHTMLc3d0cd9fab65de6875a381fd3f83e1b338%* Where 'x' is the texel being modified. Setting blur scale higher than 1 spaces the samples out.- Parameters:
- f- the desired filter scale (default=1)
 
- 
getBlurScalepublic float getBlurScale()returns the blur scale- Returns:
- the scale
 
- 
setBlurThresholdpublic void setBlurThreshold(float f) Sets the minimum blur factor before the convolution filter is calculated. The default is 0.2 which means if the "unfocus" amount is less than 0.2 (where 0 is no blur and 1.0 is full blurScale) then no blur will be applied at all. Depending on the GPU implementation, this may be an optimization since it uses branching to skip the expensive convolution filter.In scenes where the focus distance is close (like 0) and the focus range is relatively large, this threshold will remove some subtlety in the near-camera blurring and should be set smaller than the default or to 0 to disable completely. Sometimes that cut-off is desired if mid-to-far field unfocusing is all that is desired. - Parameters:
- f- the desired blur factor (default=0.2)
 
- 
getBlurThresholdpublic float getBlurThreshold()returns the blur threshold.- Returns:
- the threshold
 
- 
setDebugUnfocuspublic void setDebugUnfocus(boolean b) Turns on/off debugging of the 'unfocus' value that is used to mix the convolution filter. When this is on, the 'unfocus' value is rendered as gray scale. This can be used to more easily visualize where in your view the focus is centered and how steep the gradient/cutoff is, etcetera.- Parameters:
- b- true to enable debugging, false to disable it (default=false)
 
- 
getDebugUnfocuspublic boolean getDebugUnfocus()
- 
writeDescription copied from class:FilterOverride this method if you want to save extra properties when the filter is saved else only basic properties of the filter will be saved This method should always begin by super.write(ex);- Specified by:
- writein interface- Savable
- Overrides:
- writein class- Filter
- Parameters:
- ex- the exporter (not null)
- Throws:
- IOException- from the exporter
 
- 
readDescription copied from class:FilterOverride this method if you want to load extra properties when the filter is loaded else only basic properties of the filter will be loaded This method should always begin by super.read(im);- Specified by:
- readin interface- Savable
- Overrides:
- readin class- Filter
- Throws:
- IOException
 
 
-