DirectionalLightShadowRenderer: Problem when changing contents of sceneNode

Hi everyone,

I am exchanging Objects in my scene, and change lights and shadows. So everytime I change something, I remove the processors from the viewport, make a new one, and add it to the view port.

I do it this way, because just changing the contents of the scene does not seem to remove the shadow rendering of the previous objects, and the game gets very slow after a while. After removing all processors with [java]ViewPort.removeProcessors()[/java] everything at first seems fine, but when creating new processors and adding them to the ViewPort, this also seems to add the “old” processors / shadows, overlaying the different shadows.

Since viewport.removeProcessors() does not seem to be the right way to actually remove the DSLR, what would be the right way?

Thanks for any suggestions!

Here’s the code how I add the DLSR:

[java]DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(assetManager, shadowMapSize,
dlsr.setLight(sun);
dlsr.setShadowZExtend(distanceFromCamera);
dlsr.setShadowIntensity(shadowIntensity);
dlsr.setShadowZFadeLength(fadingOutOver);
dlsr.setEdgeFilteringMode(EdgeFilteringMode.PCFPOISSON);
viewPort.addProcessor(dlsr);[/java]

Can you create a small testcase demonstrating the problem?
cause changing the scene should work.
Also the removal should work.

Yeah, we’ll need you to create a simple test case. That way when the test case works you’ll know where to start looking… and in the slight chance that the test case doesn’t work then we’ll be able to show you what’s wrong. And in the even slighter chance that this is actually a JME bug then it will give us something to start with… but people remove objects from their scenes all the time with the shadow stuff and don’t have issues.

Thanks @Empire Phoenix & @pspeed for your answers: I found the problem that re-added the processors. Pretty stupid mistake of mine :slight_smile:
But I still have some other strange behavior, that I cannot explain, and unfortunately, could not reproduce in a test case yet, but I’ll keep trying. But in the mean time, I thought you might have an idea what could cause that behavior:
I have the following 2 scenarios, that should lead to the same result of FPS, but they don’t:

Scenario 1:
• I add a large city to my scene (75 FPS)
• I add shadows (DLSR) as described in my original post (45 FPS)
• I remove the Processors and remove the city (>300 FPS)
• I add the same city again to the scene (8 FPS)
–> I would expect this to be the same FPS as in first step, but for some reason it is not, and even drops far below the step with shadows

To try to find out what causes the problem, I do the exact same steps but do not add the shadows:

Scenario 2:
• I add a large city to my scene (75 FPS)
• I don’t add any shadows (75 FPS)
• I remove the city (>300 FPS )
• I add the same city again to the scene (75 FPS)

looking at the two scenarios, where the only difference is the adding and removing of the processors, I would assume, the the problem lies somewhere with adding and removing the processors. But from my point of view, there is not logical reason since removing processors and objects from the scene is, as you said, pretty basic stuff.

But like I said, If you have any ideas / can point me to a direction, I’d be grateful!

Cheers, P.

Edit: I played around a bit more, and found out, that reducing the the amount of shadow maps (nbSplits) to 1 (instead of 2, 3, 4), does completely remove the problem (not a single FPS less), but of course, that reduces shadow quality greatly. Using nbSplits of 2, 3 or 4 does lead to the described effect described above (Scenario 1). With higher nbSplits, frame drops per repetition of Scnenario 1 are more significant than with lower nbSplits.

Take a look at the statistics above the fps, and see if the differ, and how.

I checked that already, no changes at all … I also checked GPU and memory (in case of garbage collection) … no significant changes there also …