Problem with shadow!

Hi guys,



I have a problem with shadow pass.



I'm using BasicGameState class. When I add shadow effect to my model, it's always render hardly.



P/S: you can image that it likes render about 2-3 frame per second.  :smiley:

I am afraid a bit more info is needed or some screenshot… or something. It is not quite clear what you mean by 'it's always render hardly'.



If you are having performance problems, perhaps a small code snipped from a related class would help… Otherwise there is very little to go on.

Remove of all!



I used this tutorial http://www.jmonkeyengine.com/wiki/doku.php?id=working_with_shadows_-_from_basegame_to_standardgame to make shadows.



The following steps I do to make shadows:


  1. Using StandardGame class:



                    StandardGame game = new StandardGame("Ts");



    game.getSettings().setStencilBits(4);

                    game.getSettings().setDepth( 16 );

                    game.getSettings().setAlphaBits( 0 );

                    game.getSettings().setSamples( 0 );



    game.start();


  2. Using BasicGameState class and initialize lighting:



            DirectionalLight dr1 = new DirectionalLight();

            dr1.setEnabled(true);

            dr1.setDiffuse(ColorRGBA.white);

            dr1.setAmbient(new ColorRGBA(0.2f, 0.2f, 0.2f, 0.4f));

            dr1.setDirection(new Vector3f(-1f, -1f, 1f).normalizeLocal());

            dr1.setShadowCaster(true);



            LightState lightState = DisplaySystem.getDisplaySystem().getRenderer().createLightState();

           

            lightState = renderer.createLightState();

           

            lightState.attach(dr1);

            lightState.setEnabled(true);

            lightState.setGlobalAmbient(new ColorRGBA(0.6f, 0.6f, 0.6f, 1.0f));

    rootNode.setRenderState(lightState);


  3. Initializing ShadowedRenderPass & BasicPassManager objects


  4. Adding my model & occluders into ShadowedRenderPass object


  5. Update & render BasicPassManager object.



    That's all. Do I need take care of camera. Does it affect to view shadows

make sure u r not rendering the scene twice by rendering both the root pass and the root node. If u r not doing that, then it's really just coz volume shadow is pretty expensive since it generates slot of triangles for the shadows