DirectionalLightShadowRenderer

Hello, I’m using that code for Shadows:
[java] DirectionalLightShadowRenderer pssmShadow = new DirectionalLightShadowRenderer
(assetManager, 1024, 3);
game.getViewPort().addProcessor((SceneProcessor) pssmShadow);
pssmShadow.setLight(sun);
pssmShadow.setLambda(0.5f);

            DirectionalLightShadowFilter pssmFilter = new DirectionalLightShadowFilter

(game.getAssetManager(), 1024, 3);
pssmFilter.setLambda(0.55f);
pssmFilter.setShadowIntensity(0.6f);
fpp.addFilter(pssmFilter);[/java]

but I can’t see any shadows. Here’s [java]sun[/java] vector:
[java]sun.setDirection(new Vector3f(40f, 48f, 20f).normalizeLocal());[/java]

your code does not give a lot of information, but do you call
[java]setLight()[/java]? (ShadowFilter/Renderer)

Generally you should use a shadow filter or a shadow renderer, but not both. TestDirectionalLightShadow.java is confusing in this regard because it creates both but only enables one at a time.

To make the filter effective, you would have to invoke viewPort.addProcessor(fpp);

It’s also possible you have the shadow intensity set to 0. Try adding pssmX.setShadowIntensity(1f);

By the way, it’s confusing to put “pssm” in the instance’s name, because PSSM refers to a yet another shadow technique, now deprecated in jME3.

I got [java]viewPort.addProcessor(fpp);[/java]

and PSSM is not working in jME 3 because I got it crossed when trying to use it’s classes.
Here’s my code now but still no effect -.-:

[java] DirectionalLightShadowFilter pssmFilter = new DirectionalLightShadowFilter
(game.getAssetManager(), 1024, 3);
pssmFilter.setLambda(0.55f);
pssmFilter.setLight(sun);
pssmFilter.setShadowIntensity(1f);
fpp.addFilter(pssmFilter);[/java]

Have you invoked setShadowMode(RenderQueue.ShadowMode.CastAndReceive) on the geometries in your scene?

I set rootNode’s shadowMode to Cast and Receive but still no effect

Could you post a short (<200 lines) test program which does not depend on any non-public assets? In other words, a complete app that I can run and debug?

It will be hard because I got over 30 classes connected

Maybe I will give you a code of main class? And u will take a look.

Here’s code: http://pastebin.com/wxfRENMA

@Skatty said: It will be hard because I got over 30 classes connected

I’ve been there! Last year I spent several days pinning down this bug: http://hub.jmonkeyengine.org/forum/topic/sky-visibility-in-a-simple-scene/.

I ask because it’s difficult to debug a problem when you can only see 1% of code. Chances are the bug is not in the 1% you’ve posted, but involves some interaction with the other 99%.

Have you confirmed that your shadow code is even getting executed?

@Skatty said: Maybe I will give you a code of main class? And u will take a look.

Here’s code: GameState.java - Pastebin.com

You have a lot of post-processing filters there. What happens if you comment out all the filters other than DirectionalLightShadowFilter?

When I comment rest of filters there isn’t any shadows

Have you confirmed that the code is getting executed?

Try setting the rootNode to .CastAndRecieve - right now it looks like everything is set to receive a shadow, but nothing is told to cast a shadow. If you see shadows after that, you know its working, and can set about giving each object the correct shadowmode. I’m not sure if the tutorials mention, but it’s usually best to set the terrain to receive only - no point in calculating a shadow being cast below the terrain - which you won’t even see anyway.

First, your light is pointing upward, which is probably not what you want. Then you have to choose between the shadowProcessor and the ShadowFilter, don’t use both.

@nehon said: First, your light is pointing upward, which is probably not what you want.

No. My light is like sun in upper corner and it cast light in good angle/direction

lol =D :-3 NO

@Skatty said: No. My light is like sun in upper corner and it cast light in good angle/direction

I think @nehon has a valid point:
[java]
new Vector3f(40f, 48f, 20f).normalizeLocal()
[/java]
generates a vector with a positive y-component; it is more upwards than downwards. This appears to be the direction which your directional light is propagating.

@normen said: lol =D :-3 NO

What’s so funny, Normen?

@sgold said: What's so funny, Normen?

He sounds like grumpy cat. “No! Upwards isn’t upwards, its good! Your other point is invalid.”