[Fix] toon filter with particles textures

This fix is for particles textures, no apply toon effect on material :wink:



Just a little patch :wink:



[patch]Index: material/Material.java

===================================================================

— material/Material.java (revision 5975)

+++ material/Material.java (working copy)

@@ -71,6 +71,8 @@



private static final RenderState additiveLight = new RenderState();

private static final RenderState depthOnly = new RenderState();

+

  • private boolean isToonParticles = false;



    static {

    depthOnly.setDepthTest(true);

    @@ -200,6 +202,14 @@

    this.transparent = transparent;

    }


  • public void setToonParticles(boolean toon) {
  •    isToonParticles = toon;<br />
    
  • }

    +
  • public boolean isToonParticles() {
  •    return isToonParticles;<br />
    
  • }

    +

    public boolean isReceivesShadows() {

    return receivesShadows;

    }

    Index: renderer/RenderManager.java

    ===================================================================

    — RenderManager.java (revision 5975)

    +++ RenderManager.java (working copy)

    @@ -374,11 +374,16 @@

    g.getMaterial().selectTechnique(tmpTech);

    }else if (forcedMaterial != null){

    // use forced material
  •             forcedMaterial.render(g, this);<br />
    
  •   		 if (!g.getMaterial().isToonParticles())<br />
    
  •   			forcedMaterial.render(g, this);<br />
    

}

}else if (forcedMaterial != null){

// use forced material

  •        forcedMaterial.render(g, this);<br />
    
  •   	if (!g.getMaterial().isToonParticles()) {<br />
    
  •   		forcedMaterial.render(g, this);<br />
    
  •   	} else {<br />
    
  •   		g.getMaterial().render(g, this);<br />
    
  •   	}<br />
    

}else{

if(forcedRenderState!=null){

g.getMaterial().setAdditionalState(forcedRenderState);

[/patch]



Examples with use :



[java]package jme3test.post;



import com.jme3.app.SimpleApplication;

import com.jme3.effect.ParticleEmitter;

import com.jme3.effect.ParticleMesh.Type;

import com.jme3.material.Material;

import com.jme3.math.Vector3f;

import com.jme3.post.FilterPostProcessor;

import com.jme3.post.filters.CartoonEdgeFilter;

import com.jme3.renderer.Caps;



public class TestToonParticles extends SimpleApplication {



private FilterPostProcessor fpp;



public static void main(String[] args) {

TestToonParticles app = new TestToonParticles();

app.start();

}



@Override

public void simpleInitApp() {

flyCam.setEnabled(true);



initFilter();

initSmoke();

}



private void initFilter() {

// Initiate cartoon filter

if (renderer.getCaps().contains(Caps.GLSL100)) {

fpp = new FilterPostProcessor(assetManager);

fpp.addFilter(new CartoonEdgeFilter());

viewPort.addProcessor(fpp);

}

}



private void initSmoke() {

// Initiate Material

Material mat = new Material(assetManager,

“Common/MatDefs/Misc/Particle.j3md”);

mat.setTexture(“m_Texture”,

assetManager.loadTexture(“Effects/Smoke/Smoke.png”));

// Set Cartoon Material Particles

mat.setToonParticles(true);



// Initiate ParticleEmiter

ParticleEmitter emit = new ParticleEmitter(“Emitter”, Type.Triangle,

200);

emit.setGravity(0);

emit.setVariation(1);

emit.setLowLife(1);

emit.setHighLife(1);

emit.setStartVel(new Vector3f(0, .5f, 0));

emit.setImagesX(15);

emit.setMaterial(mat);



rootNode.attachChild(emit);

}

}[/java]



Have fun !