Class SoftBloomFilter
- All Implemented Interfaces:
Savable
Compared to BloomFilter
, this filter produces much higher quality
results that feel much more natural.
This implementation, unlike BloomFilter, has no brightness threshold, meaning all aspects of the scene glow, although only very bright areas will noticeably produce glow. For this reason, this filter should only be used if HDR is also being utilized, otherwise BloomFilter should be preferred.
This filter uses the PBR bloom algorithm presented in this article.
-
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
-
Method Summary
Modifier and TypeMethodDescriptionfloat
Gets the glow factor.protected Material
Must return the material used for this filter.int
Gets the number of downsampling/upsampling passes per step.protected void
initFilter
(AssetManager am, RenderManager rm, ViewPort vp, int w, int h) Initialization of filter subclasses.boolean
Returns true if pass textures use bilinear filtering.void
read
(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);void
setBilinearFiltering
(boolean bilinearFiltering) Sets pass textures to use bilinear filtering.void
setGlowFactor
(float factor) Sets the factor at which the glow result texture is merged with the scene texture.void
setNumSamplingPasses
(int numSamplingPasses) Sets the number of sampling passes in each step.void
write
(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, cleanUpFilter, getDefaultPassDepthFormat, getDefaultPassTextureFormat, getName, getPostRenderPasses, getRenderedTexture, getRenderFrameBuffer, init, isEnabled, isRequiresBilinear, isRequiresDepthTexture, isRequiresSceneTexture, postFilter, postFrame, postQueue, preFrame, setDepthTexture, setEnabled, setName, setProcessor, setRenderedTexture, setRenderFrameBuffer
-
Constructor Details
-
SoftBloomFilter
public SoftBloomFilter()Creates filter with default settings.
-
-
Method Details
-
initFilter
Description copied from class:Filter
Initialization 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:
initFilter
in classFilter
- Parameters:
am
- the assetManagerrm
- the renderManagervp
- the viewPort where this filter is renderedw
- the width of the filterh
- the height of the filter
-
getMaterial
Description copied from class:Filter
Must return the material used for this filter. this method is called every frame.- Specified by:
getMaterial
in classFilter
- Returns:
- the material used for this filter.
-
setNumSamplingPasses
public void setNumSamplingPasses(int numSamplingPasses) Sets the number of sampling passes in each step.Higher values produce more glow with higher resolution, at the cost of more passes. Lower values produce less glow with lower resolution.
The total number of passes is
2n+1
: n passes for downsampling (13 texture reads per pass per fragment), n passes for upsampling and blur (9 texture reads per pass per fragment), and 1 pass for blending (2 texture reads per fragment). Though, it should be noted that for each downsampling pass the number of fragments decreases by 75%, and for each upsampling pass, the number of fragments quadruples (which restores the number of fragments to the original resolution).Setting this after the filter has been initialized forces reinitialization.
default=5
- Parameters:
numSamplingPasses
- The number of passes per donwsampling/upsampling step. Must be greater than zero.- Throws:
IllegalArgumentException
- if argument is less than or equal to zero
-
setGlowFactor
public void setGlowFactor(float factor) Sets the factor at which the glow result texture is merged with the scene texture.Low values favor the scene texture more, while high values make glow more noticeable. This value is clamped between 0 and 1.
default=0.05f
- Parameters:
factor
-
-
setBilinearFiltering
public void setBilinearFiltering(boolean bilinearFiltering) Sets pass textures to use bilinear filtering.If true, downsampling textures are set to
min=BilinearNoMipMaps
and upsampling textures are set tomag=Bilinear
, which produces better quality glow. If false, textures use their default filters.default=true
- Parameters:
bilinearFiltering
- true to use bilinear filtering
-
getNumSamplingPasses
public int getNumSamplingPasses()Gets the number of downsampling/upsampling passes per step.- Returns:
- number of downsampling/upsampling passes
- See Also:
-
getGlowFactor
public float getGlowFactor()Gets the glow factor.- Returns:
- glow factor
- See Also:
-
isBilinearFiltering
public boolean isBilinearFiltering()Returns true if pass textures use bilinear filtering.- Returns:
- See Also:
-
write
Description copied from class:Filter
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);- Specified by:
write
in interfaceSavable
- Overrides:
write
in classFilter
- Parameters:
ex
- the exporter (not null)- Throws:
IOException
- from the exporter
-
read
Description copied from class:Filter
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);- Specified by:
read
in interfaceSavable
- Overrides:
read
in classFilter
- Throws:
IOException
-