Package com.jme3.post.filters
Class CrossHatchFilter
java.lang.Object
com.jme3.post.Filter
com.jme3.post.filters.CrossHatchFilter
- All Implemented Interfaces:
Savable
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/
-
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
ConstructorDescriptionCreates a crossHatch filterCrossHatchFilter
(ColorRGBA lineColor, ColorRGBA paperColor) Creates a crossHatch filter -
Method Summary
Modifier and TypeMethodDescriptionfloat
Returns current influence of image colors on linesfloat
Returns current influence of image colors on paper backgroundfloat
Returns line/paper color ratio for blobsReturns line colorfloat
Returns minimum distance between linesfloat
Returns the thickness of the lines drawnfloat
Returns threshold for lines 1float
Returns threshold for lines 2float
Returns threshold for lines 3float
Returns threshold for lines 4float
Returns threshold for blobsprotected Material
Must return the material used for this filter.Returns paper background colorprotected void
initFilter
(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) Initialization of filter subclasses.protected boolean
Override this method and return true if your Filter needs the depth texturevoid
setColorInfluenceLine
(float colorInfluenceLine) Sets color influence of original image on lines drawnvoid
setColorInfluencePaper
(float colorInfluencePaper) Sets color influence of original image on non-line areasvoid
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 insteadvoid
setLineColor
(ColorRGBA lineColor) Sets color used to draw linesvoid
setLineDistance
(float lineDistance) Sets minimum distance between lines drawn Primary lines are drawn at 2*lineDistance Secondary lines are drawn at lineDistancevoid
setLineThickness
(float lineThickness) Sets the thickness of lines drawnvoid
setLuminanceLevels
(float luminance1, float luminance2, float luminance3, float luminance4, float luminance5) Sets minimum luminance levels for lines drawnvoid
setPaperColor
(ColorRGBA paperColor) Sets color used as backgroundMethods inherited from class com.jme3.post.Filter
cleanup, cleanUpFilter, getDefaultPassDepthFormat, getDefaultPassTextureFormat, getName, getPostRenderPasses, getRenderedTexture, getRenderFrameBuffer, init, isEnabled, isRequiresBilinear, isRequiresSceneTexture, postFilter, postFrame, postQueue, preFrame, read, setDepthTexture, setEnabled, setName, setProcessor, setRenderedTexture, setRenderFrameBuffer, write
-
Constructor Details
-
CrossHatchFilter
public CrossHatchFilter()Creates a crossHatch filter -
CrossHatchFilter
Creates a crossHatch filter- Parameters:
lineColor
- the colors of the linespaperColor
- 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 classFilter
- 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 classFilter
- Parameters:
manager
- the assetManagerrenderManager
- 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.
-
setLineColor
Sets color used to draw lines- Parameters:
lineColor
- the desired color (alias created, default=(0,0,0,1))
-
setPaperColor
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 1luminance2
- Top-right to bottom left 1luminance3
- Top-left to bottom right 2luminance4
- Top-right to bottom left 2luminance5
- 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
Returns line color- Returns:
- the pre-existing instance
-
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
-