Ugly shadows with basic shadow renderer

Hi !



I encounter some problems with the basic shadow renderer :

<img src=’



My geometries are PrismMesh with two polygonal triangulated faces and quads faces around (I tried with jME standard boxes and it does the same bug).

All geometries of a single building are optimised with the batch factory.

Materials are lightning texture, except the floor that have solid color.

The green floor is set to “receive” only, all the other shapes are “cast and receive”.

The bsr is construct with :

[java] BasicShadowRenderer bsr = new BasicShadowRenderer(assetManager, 1024);

bsr.setDirection(new Vector3f(1, -1, 0).normalizeLocal());

viewPort.addProcessor(bsr);

rootNode.setShadowMode(ShadowMode.Off);[/java]



I tried the PssmShadowRenderer but get no shadow with various codes like :

[java]PssmShadowRenderer sr = new PssmShadowRenderer(assetManager, 1024, 4);

sr.setDirection(new Vector3f(1, -1, 0).normalizeLocal());

sr.setCompareMode(CompareMode.Software);

viewPort.addProcessor(sr);

rootNode.setShadowMode(ShadowMode.Off);[/java]



Thanks for you help !

mhh is rootNode.setShadowMode(ShadowMode.Off); just a test or is it what you are actually doing?

because it would explain the “no shadow” but i guess it’s just a copy/paste error.



the BasicShadowRenderer uses one map (1024*1024 in your case) for the entire scene so it’s ok from small scenes, but not for big areas like yours.



Hence the pssmShadowRenderer. It should work though, do you have some error in the console?

thank you for your answer.



I’ve understood that the basic shadow renderer is not usefull in my case because of the size of my objects.



I used the setShadowMode(Off) on the rootNode like said in the tutorials, and put some cast and receive on the individual nodes like floors or building. After your message, I tried to comment that line, but I still have no shadow at all.



Here is the precise code I use :

[java] PssmShadowRenderer sr = new PssmShadowRenderer(assetManager, 4096, 1);

sr.setDirection(new Vector3f(1, -1, 0).normalizeLocal());

// sr.setCompareMode(CompareMode.Software);

viewPort.addProcessor(sr);

// rootNode.setShadowMode(ShadowMode.Off);[/java]



plus the children attach (shapesNode is attached to root node at the initApp()) :

[java]Node toOptimizeNode = new Node();

for (int i = shapeIndex; i < shapes.size(); i++) {

shapeIndex++;

displayShape(shapes.get(i), toOptimizeNode);

}

Node optimized = (Node) GeometryBatchFactory.optimize(toOptimizeNode);

optimized.setShadowMode(ShadowMode.CastAndReceive);

shapesNode.attachChild(optimized);[/java]



Don’t know what I’m doing wrong. You have to know that my geometries are constructed in the simpleUpdate() method and not in the initialisation. Maybe shadows must be recomputed some times or else.



Thanks for your help.

Try specifying 4 splits for shadow renderer, e.g.

ssmShadowRenderer(assetManager, 4096, 4);

I tried.



On my main application, it thrown a “out of memory” exception after a few modeling.



On a lite version, construting just one building, I can model the building but no shadow is visible. But in the same time, I noticed that the frame rate decrease with a high number of meshes (that are optimized with batch factory). So I guess the shadows are computed but just not visible.



I get the latest night built and the latest driver for my geForce : same problem.



Thanks for the time you spend on my code.

1 Like

The less objects you have in your scene the faster shadows will be rendered, so yes batching should help there too.

Also map size of 4096 is a bit excessive, try 1024, but I don’t think that’s why the shadows do not appear (but could explain the outOfMemory).

Don’t you have some shader compilation error in the log? (usually the source code of the shader is output to the log followed by the error)

I don’t have any error in the log. But I guess that the fps lowering is the sign that the shader works correctly, but the effect does not appera. I will do a simple test case to check that the shader work on my computer and then try to implement my tools to understand wich one make the shadow renderer fail. I will comme back here at that moment.



Of course, if you have an idea, i take it !



Thanks you very much for your time !





Ben

Can you run the jME3 test “TestPssmShadow”?

Yes I can run the TestPssmShadow correctly. I don’t know if it can help, but here is a picture with the option displayDebug on :

<img src=’

Well, this really looks like a shader issue, the shadow maps are computed correctly, but nothing is displayed.