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
ConstructorsConstructorDescriptionCreates a crossHatch filterCrossHatchFilter(ColorRGBA lineColor, ColorRGBA paperColor) Creates a crossHatch filter -
Method Summary
Modifier and TypeMethodDescriptionfloatReturns current influence of image colors on linesfloatReturns current influence of image colors on paper backgroundfloatReturns line/paper color ratio for blobsReturns line colorfloatReturns minimum distance between linesfloatReturns the thickness of the lines drawnfloatReturns threshold for lines 1floatReturns threshold for lines 2floatReturns threshold for lines 3floatReturns threshold for lines 4floatReturns threshold for blobsprotected MaterialMust return the material used for this filter.Returns paper background colorprotected voidinitFilter(AssetManager manager, RenderManager renderManager, ViewPort vp, int w, int h) Initialization of filter subclasses.protected booleanOverride this method and return true if your Filter needs the depth texturevoidread(JmeImporter importer) Load properties when the filter is de-serialized, for example when loading from a J3O file.voidsetColorInfluenceLine(float colorInfluenceLine) Sets color influence of original image on lines drawnvoidsetColorInfluencePaper(float colorInfluencePaper) Sets color influence of original image on non-line areasvoidsetFillValue(float fillValue) Sets line/paper color ratio for areas with values less than luminance5, really dark areas get no lines but a filled blob insteadvoidsetLineColor(ColorRGBA lineColor) Sets color used to draw linesvoidsetLineDistance(float lineDistance) Sets minimum distance between lines drawn Primary lines are drawn at 2*lineDistance Secondary lines are drawn at lineDistancevoidsetLineThickness(float lineThickness) Sets the thickness of lines drawnvoidsetLuminanceLevels(float luminance1, float luminance2, float luminance3, float luminance4, float luminance5) Sets minimum luminance levels for lines drawnvoidsetPaperColor(ColorRGBA paperColor) Sets color used as backgroundvoidwrite(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
-
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:FilterOverride this method and return true if your Filter needs the depth texture- Overrides:
isRequiresDepthTexturein 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:FilterInitialization 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:
initFilterin 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:FilterMust return the material used for this filter. this method is called every frame.- Specified by:
getMaterialin 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
-
read
Load properties when the filter is de-serialized, for example when loading from a J3O file.- Specified by:
readin interfaceSavable- Overrides:
readin classFilter- Parameters:
importer- the importer to use (not null)- Throws:
IOException- from the importer
-
write
Save properties when the filter is serialized, for example when saving to a J3O file.- Specified by:
writein interfaceSavable- Overrides:
writein classFilter- Parameters:
exporter- the exporter to use (not null)- Throws:
IOException- from the exporter
-