mul..va 14 years ago
parent b68e56c5bf
commit 64a404a939
  1. 18
      engine/src/core-data/Common/MatDefs/Post/CrossHatch.frag
  2. 4
      engine/src/core-data/Common/MatDefs/Post/CrossHatch.j3md
  3. 20
      engine/src/desktop-fx/com/jme3/post/filters/CrossHatchFilter.java

@ -13,30 +13,30 @@ uniform float m_Luminance3;
uniform float m_Luminance4;
uniform float m_Luminance5;
uniform int m_LineDistance;
uniform int m_LineThickness;
uniform float m_LineDistance;
uniform float m_LineThickness;
void main() {
vec4 texVal = texture2D(m_Texture, texCoord);
float linePixel = 0;
float linePixel = 0.0;
float lum = texVal.r*0.2126 + texVal.g*0.7152 + texVal.b*0.0722;
if (lum < m_Luminance1){
if (mod(gl_FragCoord.x + gl_FragCoord.y, m_LineDistance * 2) < m_LineThickness)
linePixel = 1;
if (mod(gl_FragCoord.x + gl_FragCoord.y, m_LineDistance * 2.0) < m_LineThickness)
linePixel = 1.0;
}
if (lum < m_Luminance2){
if (mod(gl_FragCoord.x - gl_FragCoord.y, m_LineDistance * 2) < m_LineThickness)
linePixel = 1;
if (mod(gl_FragCoord.x - gl_FragCoord.y, m_LineDistance * 2.0) < m_LineThickness)
linePixel = 1.0;
}
if (lum < m_Luminance3){
if (mod(gl_FragCoord.x + gl_FragCoord.y - m_LineDistance, m_LineDistance) < m_LineThickness)
linePixel = 1;
linePixel = 1.0;
}
if (lum < m_Luminance4){
if (mod(gl_FragCoord.x - gl_FragCoord.y - m_LineDistance, m_LineDistance) < m_LineThickness)
linePixel = 1;
linePixel = 1.0;
}
if (lum < m_Luminance5){ // No line, make a blob instead
linePixel = m_FillValue;

@ -13,8 +13,8 @@ MaterialDef CrossHatch {
Float Luminance3;
Float Luminance4;
Float Luminance5;
Int LineThickness;
Int LineDistance;
Float LineThickness;
Float LineDistance;
}
Technique {

@ -61,8 +61,8 @@ public class CrossHatchFilter extends Filter {
private float luminance3 = 0.5f;
private float luminance4 = 0.3f;
private float luminance5 = 0.0f;
private int lineThickness = 1;
private int lineDistance = 4;
private float lineThickness = 1.0f;
private float lineDistance = 4.0f;
public CrossHatchFilter() {
super("CrossHatchFilter");
@ -96,8 +96,8 @@ public class CrossHatchFilter extends Filter {
material.setFloat("Luminance4", luminance4);
material.setFloat("Luminance5", luminance5);
material.setInt("LineThickness", lineThickness);
material.setInt("LineDistance", lineDistance);
material.setFloat("LineThickness", lineThickness);
material.setFloat("LineDistance", lineDistance);
}
@Override
@ -191,10 +191,10 @@ public class CrossHatchFilter extends Filter {
/*
* Sets the thickness of lines drawn
*/
public void setLineThickness(int lineThickness) {
public void setLineThickness(float lineThickness) {
this.lineThickness = lineThickness;
if (material != null) {
material.setInt("LineThickness", lineThickness);
material.setFloat("LineThickness", lineThickness);
}
}
@ -203,10 +203,10 @@ public class CrossHatchFilter extends Filter {
* Primary lines are drawn at 2*lineDistance
* Secondary lines are drawn at lineDistance
*/
public void setLineDistance(int lineDistance) {
public void setLineDistance(float lineDistance) {
this.lineDistance = lineDistance;
if (material != null) {
material.setInt("LineDistance", lineDistance);
material.setFloat("LineDistance", lineDistance);
}
}
@ -248,14 +248,14 @@ public class CrossHatchFilter extends Filter {
/*
* Returns the thickness of the lines drawn
*/
public int getLineThickness() {
public float getLineThickness() {
return lineThickness;
}
/*
* Returns minimum distance between lines
*/
public int getLineDistance() {
public float getLineDistance() {
return lineDistance;
}

Loading…
Cancel
Save