Class SoftBloomFilter

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

public class SoftBloomFilter extends 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.

  • Constructor Details

    • SoftBloomFilter

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

    • initFilter

      protected void initFilter(AssetManager am, RenderManager rm, ViewPort vp, int w, int h)
      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 class Filter
      Parameters:
      am - the assetManager
      rm - the renderManager
      vp - the viewPort where this filter is rendered
      w - the width of the filter
      h - the height of the filter
    • getMaterial

      protected Material getMaterial()
      Description copied from class: Filter
      Must return the material used for this filter. this method is called every frame.
      Specified by:
      getMaterial in class Filter
      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 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(JmeExporter ex) throws IOException
      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 interface Savable
      Overrides:
      write in class Filter
      Parameters:
      ex - the exporter (not null)
      Throws:
      IOException - from the exporter
    • read

      public void read(JmeImporter im) throws IOException
      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 interface Savable
      Overrides:
      read in class Filter
      Throws:
      IOException