Shadow and ToonEdge - Order problem

Hi, sorry if this problem already have an answer…



When i use CartoonEdgeFilter with PssmShadowRenderer, shadow appear before my player if i add PssmShadowRenderer after CartoonEdgeFilter in the viewport and CartoonEdgeFilter doesn’t work in otherwise.



If i add two times CartoonEdgeFilter in the viewport all work fine but fps down…



Am I really bad or it’s a real problem ?

(sorry for bad english)



Can’t help you, but others will probably ask for a test case to be able to help you.

Ok thx makeshift. This is the test case :



[java]public void simpleInitApp() {

BulletAppState bulletAppState = new BulletAppState();

stateManager.attach(bulletAppState);



Box floorshape = new Box(50f, 0.05f, 50f);

Geometry floor = new Geometry(“floor”, floorshape);

floor.setShadowMode(ShadowMode.Receive);



viewPort.setBackgroundColor(ColorRGBA.Blue);



Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);

mat.setColor(“Color”, ColorRGBA.Green);

floor.setMaterial(mat);

floor.addControl(new RigidBodyControl(0));

bulletAppState.getPhysicsSpace().add(floor);



Material mat2 = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);

mat2.setBoolean(“UseMaterialColors”, true);

mat2.setColor(“Diffuse”, ColorRGBA.Red);

Node oto = (Node) assetManager.loadModel(“Models/Oto/Oto.mesh.xml”);

oto.setMaterial(mat2);

oto.setShadowMode(ShadowMode.Cast);

oto.setLocalTranslation(0, 5, 0);

CapsuleCollisionShape capsule = new CapsuleCollisionShape(3f, 4f);

CharacterControl character = new CharacterControl(capsule, 0.1f);

oto.addControl(character);

bulletAppState.getPhysicsSpace().add(character);



DirectionalLight sun = new DirectionalLight();

sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));



ChaseCamera chaseCam = new ChaseCamera(cam, oto, inputManager);

chaseCam.setMaxVerticalRotation(FastMath.DEG_TO_RAD * 70);



rootNode.attachChild(floor);

rootNode.attachChild(oto);

rootNode.addLight(sun);



FilterPostProcessor fpp =new FilterPostProcessor(assetManager);



PssmShadowRenderer pssmRenderer = new PssmShadowRenderer(assetManager,1024,4);

pssmRenderer.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());

pssmRenderer.setShadowIntensity(0.45f);

pssmRenderer.setFilterMode(FilterMode.PCF4);



CartoonEdgeFilter toon=new CartoonEdgeFilter();

fpp.addFilter(toon);



/**This block make all working/

//viewPort.addProcessor(pssmRenderer);

//viewPort.addProcessor(fpp);

//viewPort.addProcessor(fpp);



/**Here, cartoon edge doesn’t work well/

//viewPort.addProcessor(pssmRenderer);

//viewPort.addProcessor(fpp);



/**And here, shadow is before Oto/

viewPort.addProcessor(fpp);

viewPort.addProcessor(pssmRenderer);

}[/java]

Seems like the PSSM renderer isn’t getting a proper depth buffer to render to… @nehon: have any idea?

I’ll look into it

So im not crazy ! Thank you :stuck_out_tongue:

The FilterPostProcessor must be added after the pssmRenderer to the viewport.

The order is very important.

I know nehon. But if I add the fpp after pssm the cartoon edge filter is not render correctly. Look the end of my test case.

http://nsm05.casimages.com/img/2011/09/04//1109040711131307938692106.jpg

Sorry i should have read your post with more attention.

Ok so it might be that the filter itself fail to get the correct depth for some reason…it looks like a clear depth issue…

I’ll look into it

This one was wild, it’s fixed in last SVN.

In fact that was the normal buffer that was not properly cleared.



@Momoko_Fan it’s the same issue as the clear depth when depth write is not enabled.

here the pssm pass disable color write, so when the next pass tries to clear the color buffer it’s not done. Anyway, i just enable color write before clearing now if color write is not enabled.

@nehon If i do things well (“Jmonkey SDK nightly” check in settings → reload catalog and update all)… It still doesn’t work in all case…But I may be a zero… In any case thank you :smiley:

Don’t update the jMP to get the svn, you have to update the jME3 sources from googlecode.

Huh? You can get the jme3 libraries incl sources using the update function too.

Haha! Never noticed it. :o



Edit: Sure, but you’ll have to wait until the next nightly. You won’t get the mods the minutes after they’ve been committed.

I’m sorry please don’t hurt me :stuck_out_tongue:

I’ve compiled Jme with svn.

Thank You for all. It’s working now and if you can see my face i have a big smile on it.

I come back to the next bug :stuck_out_tongue: :stuck_out_tongue: