(Shadow) performance tweaks?

Hey guys,



first of all thank you for this great java engine. In the past years I have learned to love java but I have always thought I have to use c++ for 3D stuff. I am not that experienced with 3D engines although I have played for some time with Ogre3D and Irrlicht.

Now I have seen these great demo-videos of “Gen -  The Room”, that was really nice looking. That gave me the inspiration for a little testing for the engine and I tried something of that kind myself. Just for playing around, I have no intention of writing a game, so no competition :wink:



So first of all, this is what we are talking about:

http://www.youtube.com/watch?v=qlnxcZoBqWQ



If you want to have a look at the code it is uploaded to google code:

http://code.google.com/p/stoerbild/source/browse/





So, now for my problem:

Basically this is an array of ‘Box’. I do a lot of calculating for the positions of the boxes, but this is CPU stuff and for now this is no problem. Actually my problem is the shadowing. I have only two lights, but my frames drop down to something like 10-15fps sometimes when I enable the ShadowPass. I have a Macbook Pro with a 9600GT.

I know, there are a lot of boxes, but I wondered if there are some tips, tweaks to increase performance. I already found some things like SharedMesh, BackFaceCulling, and lockMesh() for all the boxes.



Thank you :slight_smile:



mq

did you try to see if DirectionalShadowMapPass.java performes better ?

Ok, obviously this topic is not that interesting :wink:



So let me restate the question. If I wrote this same "demo" in Ogre3D, would it be faster? If so, what is the problem here? Is JNI to slow? Or is just shadow calculation not that advanced in jME as it is in Ogre?

My impression is that jMe supports realistic additive/modulative shadows and directional shadows. There are other techniques to calculate shadows, aren't there?



regards,

mq

i think the topic is very interesting, but it seems people with experience in this area are rather rare :slight_smile:



It would be interesting to see how ogre3d or other engines deal with shadows, do the use stencil or shadow mapping or other techniques, and how are they different from jme’s.



Ardor3d also implemented a PSSM which should give better shadow quality.

ParallelSplitShadowMapPass.java



Maybe its possible to port it to jme and see how it works out?

Core-Dump said:

It would be interesting to see how ogre3d or other engines deal with shadows, do the use stencil or shadow mapping or other techniques, and how are they different from jme's.

Ogre3D, (and now jME3) have several ways of creating shadow effects, through a modular system, that is responsible for applying the shadow effect. In the scene graph, objects are classified as either shadow casters, shadow receivers or both, while lights can be configured to either cast shadows or not. This information is then used by the shadow system to apply the effect to the scene. It is possible to apply the shadow either as a post process effect or in a single pass if the object's shader supports it- this will create higher quality shadows than a post process. jME2 and Ardor3D make shadow effects a "utility" rather than a core feature, this makes the shadow system inflexible, only support post process shadowing, and have issues when other screen-based effects get applied (such as SSAO).

Thank you for your answers. Also the explanation concerning Ogre and jME3 is very interesting.



Unfortunately I have not the 3D experience trying to port Ardor's technique to jME, but I was curious and tried to port my demo to Ogre3D, at least the basics.

Interestingly the lighting looks somehow very different in Ogre, but I still have problems to clone the environment. Also I do not know yet how to create SharedMeshs in Ogre, so performance comparison would not be fair.

By default Ogre3D supports the following shadow techniques:

  • Texture Additive/Modulative (+ some 'integrated' switch)
  • Stencil Additive/Modulative
  • and additionally a directional shadow if have understood it correctly



    At first glance after trying several options Additive Stencil Shadowing in Ogre3D is not significantly faster than it is in jME2 (at least not at default settings). But as I still have problems recreating the scene, I cannot say for sure. And Ogre has several options for shadowing, there are several settings. jME is more straight forward.

    jME in general is much more straight forward than Ogre, a lot of things are very simple in jME. On the other hand Ogre often is more configurable. And of course Java is much more straight forward than C++, too :wink:



    Unfortunately I have not much time these days, but I will keep you up to date :slight_smile:

    Thanks for your help.



    regards,

    mq