Package com.jme3.post.ssao
Class SSAOFilter
java.lang.Object
com.jme3.post.Filter
com.jme3.post.ssao.SSAOFilter
- All Implemented Interfaces:
Savable
SSAO stands for screen space ambient occlusion
It's a technique that fakes ambient lighting by computing shadows that nearby objects would cast on each other.
under the effect of an ambient light
more info on this in this blog post http://jmonkeyengine.org/2010/08/16/screen-space-ambient-occlusion-for-jmonkeyengine-3-0/
-
Nested Class Summary
Nested classes/interfaces inherited from class com.jme3.post.Filter
Filter.Pass -
Field Summary
Fields inherited from class com.jme3.post.Filter
defaultPass, enabled, material, postRenderPasses, processor -
Constructor Summary
ConstructorsConstructorDescriptionCreate a Screen Space Ambient Occlusion FilterSSAOFilter(float sampleRadius, float intensity, float scale, float bias) Create a Screen Space Ambient Occlusion Filter -
Method Summary
Modifier and TypeMethodDescriptionprotected voidoverride this method if you have some cleanup to dofloatgetBias()Returns the bias value used in the SSAO calculation.floatReturns the ambient occlusion intensity.protected MaterialMust return the material used for this filter.floatReturns the sample radius used in the SSAO calculation.floatgetScale()Returns the scale value used in the SSAO calculation.protected voidinitFilter(AssetManager assetManager, RenderManager renderManager, ViewPort vp, int w, int h) Initialization of filter subclasses.booleanChecks if approximate normals are being used for SSAO calculation.protected booleanOverride this method and return true if your Filter needs the depth texturebooleanisUseAo()debugging only, will be removedbooleandebugging only, will be removedprotected voidpostQueue(RenderQueue queue) Override this method if you want to make a pre pass, before the actual rendering of the framevoidread(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);voidsetApproximateNormals(boolean approximateNormals) Sets whether to use approximate normals for the SSAO calculation.voidsetBias(float bias) Sets the width of the occlusion cone considered by the occludee.voidsetIntensity(float intensity) Sets the ambient occlusion intensity.voidsetSampleRadius(float sampleRadius) Sets the radius of the area where random samples will be picked for SSAO.voidsetScale(float scale) Sets the distance between occluders and occludee for SSAO.voidsetUseAo(boolean useAo) debugging only, will be removedvoidsetUseOnlyAo(boolean useOnlyAo) debugging only, will be removedvoidwrite(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.Filter
cleanup, getDefaultPassDepthFormat, getDefaultPassTextureFormat, getName, getPostRenderPasses, getRenderedTexture, getRenderFrameBuffer, init, isEnabled, isRequiresBilinear, isRequiresSceneTexture, postFilter, postFrame, preFrame, setDepthTexture, setEnabled, setName, setProcessor, setRenderedTexture, setRenderFrameBuffer
-
Constructor Details
-
SSAOFilter
public SSAOFilter()Create a Screen Space Ambient Occlusion Filter -
SSAOFilter
public SSAOFilter(float sampleRadius, float intensity, float scale, float bias) Create a Screen Space Ambient Occlusion Filter- Parameters:
sampleRadius- The radius of the area where random samples will be picked. default 5.1fintensity- intensity of the resulting AO. default 1.5fscale- distance between occluders and occludee. default 0.2fbias- the width of the occlusion cone considered by the occludee. default 0.1f
-
-
Method Details
-
isRequiresDepthTexture
protected boolean isRequiresDepthTexture()Description copied from class:FilterOverride this method and return true if your Filter needs the depth texture- Overrides:
isRequiresDepthTexturein classFilter- Returns:
- true if your Filter need the depth texture
-
postQueue
Description copied from class:FilterOverride this method if you want to make a pre pass, before the actual rendering of the frame -
getMaterial
Description copied from class:FilterMust return the material used for this filter. this method is called every frame.- Specified by:
getMaterialin classFilter- Returns:
- the material used for this filter.
-
initFilter
protected void initFilter(AssetManager assetManager, 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 classFilter- Parameters:
assetManager- the assetManagerrenderManager- the renderManagervp- the viewPort where this filter is renderedw- the width of the filterh- the height of the filter
-
cleanUpFilter
Description copied from class:Filteroverride this method if you have some cleanup to do- Overrides:
cleanUpFilterin classFilter- Parameters:
r- the renderer
-
getBias
public float getBias()Returns the bias value used in the SSAO calculation.- Returns:
- The bias value.
- See Also:
-
setBias
public void setBias(float bias) Sets the width of the occlusion cone considered by the occludee. A higher bias means a wider cone, resulting in less self-occlusion.- Parameters:
bias- The desired bias value (default: 0.1f).
-
getIntensity
public float getIntensity()Returns the ambient occlusion intensity.- Returns:
- The intensity value.
-
setIntensity
public void setIntensity(float intensity) Sets the ambient occlusion intensity. A higher intensity makes the ambient occlusion effect more pronounced.- Parameters:
intensity- The desired intensity (default: 1.5f).
-
getSampleRadius
public float getSampleRadius()Returns the sample radius used in the SSAO calculation.- Returns:
- The sample radius.
- See Also:
-
setSampleRadius
public void setSampleRadius(float sampleRadius) Sets the radius of the area where random samples will be picked for SSAO. A larger radius considers more distant occluders.- Parameters:
sampleRadius- The desired radius (default: 5.1f).
-
getScale
public float getScale()Returns the scale value used in the SSAO calculation.- Returns:
- The scale value.
- See Also:
-
setScale
public void setScale(float scale) Sets the distance between occluders and occludee for SSAO. This essentially controls the "thickness" of the ambient occlusion.- Parameters:
scale- The desired distance (default: 0.2f).
-
setApproximateNormals
public void setApproximateNormals(boolean approximateNormals) Sets whether to use approximate normals for the SSAO calculation. If `true`, normals are derived from the depth buffer. If `false`, a separate normal pass is rendered.- Parameters:
approximateNormals- `true` to use approximate normals, `false` to use a normal pass.
-
isApproximateNormals
public boolean isApproximateNormals()Checks if approximate normals are being used for SSAO calculation.- Returns:
- `true` if approximate normals are used, `false` otherwise.
-
isUseAo
public boolean isUseAo()debugging only, will be removed- Returns:
- true if using ambient occlusion
-
setUseAo
public void setUseAo(boolean useAo) debugging only, will be removed- Parameters:
useAo- true to enable, false to disable (default=true)
-
isUseOnlyAo
public boolean isUseOnlyAo()debugging only, will be removed- Returns:
- useOnlyAo
-
setUseOnlyAo
public void setUseOnlyAo(boolean useOnlyAo) debugging only, will be removed- Parameters:
useOnlyAo- true to enable, false to disable (default=false)
-
write
Description 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 interfaceSavable- Overrides:
writein classFilter- Parameters:
ex- the exporter (not null)- Throws:
IOException- from the exporter
-
read
Description 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 interfaceSavable- Overrides:
readin classFilter- Throws:
IOException
-