Class CrossHatchFilter

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

public class CrossHatchFilter extends com.jme3.post.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/
Author:
Roy Straver a.k.a. Baal Garnaal
  • 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 a crossHatch filter
    CrossHatchFilter(com.jme3.math.ColorRGBA lineColor, com.jme3.math.ColorRGBA paperColor)
    Creates a crossHatch filter
  • Method Summary

    Modifier and Type
    Method
    Description
    float
    Returns current influence of image colors on lines
    float
    Returns current influence of image colors on paper background
    float
    Returns line/paper color ratio for blobs
    com.jme3.math.ColorRGBA
    Returns line color
    float
    Returns minimum distance between lines
    float
    Returns the thickness of the lines drawn
    float
    Returns threshold for lines 1
    float
    Returns threshold for lines 2
    float
    Returns threshold for lines 3
    float
    Returns threshold for lines 4
    float
    Returns threshold for blobs
    protected com.jme3.material.Material
     
    com.jme3.math.ColorRGBA
    Returns paper background color
    protected void
    initFilter(com.jme3.asset.AssetManager manager, com.jme3.renderer.RenderManager renderManager, com.jme3.renderer.ViewPort vp, int w, int h)
     
    protected boolean
     
    void
    read(com.jme3.export.JmeImporter importer)
    Load properties when the filter is de-serialized, for example when loading from a J3O file.
    void
    setColorInfluenceLine(float colorInfluenceLine)
    Sets color influence of original image on lines drawn
    void
    setColorInfluencePaper(float colorInfluencePaper)
    Sets color influence of original image on non-line areas
    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
    void
    setLineColor(com.jme3.math.ColorRGBA lineColor)
    Sets color used to draw lines
    void
    setLineDistance(float lineDistance)
    Sets minimum distance between lines drawn Primary lines are drawn at 2*lineDistance Secondary lines are drawn at lineDistance
    void
    setLineThickness(float lineThickness)
    Sets the thickness of lines drawn
    void
    setLuminanceLevels(float luminance1, float luminance2, float luminance3, float luminance4, float luminance5)
    Sets minimum luminance levels for lines drawn
    void
    setPaperColor(com.jme3.math.ColorRGBA paperColor)
    Sets color used as background
    void
    write(com.jme3.export.JmeExporter exporter)
    Save properties when the filter is serialized, for example when saving to a J3O file.

    Methods inherited from class com.jme3.post.Filter

    cleanup, cleanUpFilter, getDefaultPassDepthFormat, getDefaultPassTextureFormat, getName, getPostRenderPasses, getRenderedTexture, getRenderFrameBuffer, init, isEnabled, isRequiresBilinear, 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

    • CrossHatchFilter

      public CrossHatchFilter()
      Creates a crossHatch filter
    • CrossHatchFilter

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

    • isRequiresDepthTexture

      protected boolean isRequiresDepthTexture()
      Overrides:
      isRequiresDepthTexture in class com.jme3.post.Filter
    • initFilter

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

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

      public void setPaperColor(com.jme3.math.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 com.jme3.math.ColorRGBA getLineColor()
      Returns line color
      Returns:
      the pre-existing instance
    • getPaperColor

      public com.jme3.math.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
    • read

      public void read(com.jme3.export.JmeImporter importer) throws IOException
      Load properties when the filter is de-serialized, for example when loading from a J3O file.
      Specified by:
      read in interface com.jme3.export.Savable
      Overrides:
      read in class com.jme3.post.Filter
      Parameters:
      importer - the importer to use (not null)
      Throws:
      IOException - from the importer
    • write

      public void write(com.jme3.export.JmeExporter exporter) throws IOException
      Save properties when the filter is serialized, for example when saving to a J3O file.
      Specified by:
      write in interface com.jme3.export.Savable
      Overrides:
      write in class com.jme3.post.Filter
      Parameters:
      exporter - the exporter to use (not null)
      Throws:
      IOException - from the exporter