Class CrossHatchFilter

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

public class CrossHatchFilter extends Filter
A Post Processing filter that makes the screen look like it was drawn as diagonal lines with a pen. Try combining this with a cartoon edge filter to obtain manga style visuals. Based on an article from Geeks3D: http://www.geeks3d.com/20110219/shader-library-crosshatching-glsl-filter/
  • Constructor Details

    • CrossHatchFilter

      public CrossHatchFilter()
      Creates a crossHatch filter
    • CrossHatchFilter

      public CrossHatchFilter(ColorRGBA lineColor, ColorRGBA paperColor)
      Creates a crossHatch filter
      Parameters:
      lineColor - the colors of the lines
      paperColor - the paper color
  • Method Details

    • isRequiresDepthTexture

      protected boolean isRequiresDepthTexture()
      Description copied from class: Filter
      Override this method and return true if your Filter needs the depth texture
      Overrides:
      isRequiresDepthTexture in class Filter
      Returns:
      true if your Filter need the depth texture
    • initFilter

      protected void initFilter(AssetManager manager, RenderManager renderManager, 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:
      manager - 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
    • 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.
    • setLineColor

      public void setLineColor(ColorRGBA lineColor)
      Sets color used to draw lines
      Parameters:
      lineColor - the desired color (alias created, default=(0,0,0,1))
    • setPaperColor

      public void setPaperColor(ColorRGBA paperColor)
      Sets color used as background
      Parameters:
      paperColor - the desired color (alias created, default=(1,1,1,1))
    • setColorInfluenceLine

      public void setColorInfluenceLine(float colorInfluenceLine)
      Sets color influence of original image on lines drawn
      Parameters:
      colorInfluenceLine - the desired factor (default=0.8)
    • setColorInfluencePaper

      public void setColorInfluencePaper(float colorInfluencePaper)
      Sets color influence of original image on non-line areas
      Parameters:
      colorInfluencePaper - the desired factor (default=0.1)
    • setFillValue

      public void setFillValue(float fillValue)
      Sets line/paper color ratio for areas with values less than luminance5, really dark areas get no lines but a filled blob instead
      Parameters:
      fillValue - the desired ratio (default=0.9)
    • setLuminanceLevels

      public void setLuminanceLevels(float luminance1, float luminance2, float luminance3, float luminance4, float luminance5)
      Sets minimum luminance levels for lines drawn
      Parameters:
      luminance1 - Top-left to bottom right 1
      luminance2 - Top-right to bottom left 1
      luminance3 - Top-left to bottom right 2
      luminance4 - Top-right to bottom left 2
      luminance5 - Blobs
    • setLineThickness

      public void setLineThickness(float lineThickness)
      Sets the thickness of lines drawn
      Parameters:
      lineThickness - the desired thickness (in pixels, default=1)
    • setLineDistance

      public void setLineDistance(float lineDistance)
      Sets minimum distance between lines drawn Primary lines are drawn at 2*lineDistance Secondary lines are drawn at lineDistance
      Parameters:
      lineDistance - the desired distance (in pixels, default=4)
    • getLineColor

      public ColorRGBA getLineColor()
      Returns line color
      Returns:
      the pre-existing instance
    • getPaperColor

      public ColorRGBA getPaperColor()
      Returns paper background color
      Returns:
      the pre-existing instance
    • getColorInfluenceLine

      public float getColorInfluenceLine()
      Returns current influence of image colors on lines
      Returns:
      the influence factor
    • getColorInfluencePaper

      public float getColorInfluencePaper()
      Returns current influence of image colors on paper background
      Returns:
      the influence factor
    • getFillValue

      public float getFillValue()
      Returns line/paper color ratio for blobs
      Returns:
      the ratio
    • getLineThickness

      public float getLineThickness()
      Returns the thickness of the lines drawn
      Returns:
      the thickness (in pixels)
    • getLineDistance

      public float getLineDistance()
      Returns minimum distance between lines
      Returns:
      the distance (in pixels)
    • getLuminance1

      public float getLuminance1()
      Returns threshold for lines 1
      Returns:
      the first luminance threshold
    • getLuminance2

      public float getLuminance2()
      Returns threshold for lines 2
      Returns:
      the 2nd luminance threshold
    • getLuminance3

      public float getLuminance3()
      Returns threshold for lines 3
      Returns:
      the 3rd luminance threshold
    • getLuminance4

      public float getLuminance4()
      Returns threshold for lines 4
      Returns:
      the 4th luminance threshold
    • getLuminance5

      public float getLuminance5()
      Returns threshold for blobs
      Returns:
      the 5th luminance threshold