Class SoftBloomFilter

java.lang.Object
com.jme3.post.Filter
com.jme3.post.filters.SoftBloomFilter
All Implemented Interfaces:
com.jme3.export.Savable

public class SoftBloomFilter extends com.jme3.post.Filter
Adds a glow effect to the scene.

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.

Author:
codex
  • Nested Class Summary

    Nested classes/interfaces inherited from class com.jme3.post.Filter

    com.jme3.post.Filter.Pass
  • Field Summary

    Fields inherited from class com.jme3.post.Filter

    defaultPass, enabled, material, postRenderPasses, processor
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates filter with default settings.
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    Gets the glow factor.
    protected com.jme3.material.Material
     
    int
    Gets the number of downsampling/upsampling passes per step.
    protected void
    initFilter(com.jme3.asset.AssetManager am, com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp, int w, int h)
     
    boolean
    Returns true if pass textures use bilinear filtering.
    void
    read(com.jme3.export.JmeImporter 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(com.jme3.export.JmeExporter 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SoftBloomFilter

      public SoftBloomFilter()
      Creates filter with default settings.
  • Method Details

    • initFilter

      protected void initFilter(com.jme3.asset.AssetManager am, com.jme3.renderer.RenderManager rm, com.jme3.renderer.ViewPort vp, int w, int h)
      Specified by:
      initFilter in class com.jme3.post.Filter
    • getMaterial

      protected com.jme3.material.Material getMaterial()
      Specified by:
      getMaterial in class com.jme3.post.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 to mag=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

      public void write(com.jme3.export.JmeExporter ex) throws IOException
      Specified by:
      write in interface com.jme3.export.Savable
      Overrides:
      write in class com.jme3.post.Filter
      Throws:
      IOException
    • read

      public void read(com.jme3.export.JmeImporter im) throws IOException
      Specified by:
      read in interface com.jme3.export.Savable
      Overrides:
      read in class com.jme3.post.Filter
      Throws:
      IOException