No shadow casting

I have included in my code all the necessary stuff, from TestShadowPass.java, to get shadow casting in my scene, but the result is that i get no shadow casts. As you see in the image, sphere doesn’t cast a shadow on the box mesh (at least it is not visible).







Here are some parts of my code:





   public void simpleSetup()
 {
   display.setMinStencilBits( 8 );
      /** shadowing */
      shadowPass.add(rootNode);
      shadowPass.addOccluder(rootNode); //every node casts a shadow
      shadowPass.setRenderShadows(true);
      shadowPass.setEnabled(true);
      shadowPass.setRenderVolume(true);
      shadowPass.setLightingMethod(ShadowedRenderPass.ADDITIVE);
      passManager = new BasicPassManager();
      passManager.add(shadowPass);
      RenderPass rPass = new RenderPass();
        rPass.add(fpsNode);
      passManager.add(rPass);
      
      shadowPass.doRender(renderer);
      ShadowedRenderPass.blended.setSrcFunction(2);
      ShadowedRenderPass.blended.setDstFunction(1);
      ShadowedRenderPass.blendTex.setSrcFunction(2);
      ShadowedRenderPass.blendTex.setDstFunction(0);
      
      
      lightState = renderer.createLightState();
      lightState.setTwoSidedLighting(true);
      lightState.setEnabled(true);
      directionalLight = new DirectionalLight();
      directionalLight.setDiffuse(new ColorRGBA(1, 1, 1, 1.0f));
      directionalLight.setAmbient(new ColorRGBA(1, 1, 1, 1.0f));
      directionalLight.setSpecular(new ColorRGBA(1, 1, 1, 1.0f));
      directionalLight.setDirection(new Vector3f(0, -1f, -0.5f).normalizeLocal());
      directionalLight.setShadowCaster(true);
      directionalLight.setEnabled(true);


      lightState.detachAll();
      lightState.attach(directionalLight);
      rootNode.setRenderState(lightState);

      
      shadeState = renderer.createShadeState();
      shadeState.setShade(ShadeState.SM_SMOOTH);
      shadeState.setEnabled(true);
      rootNode.setRenderState(shadeState);
      
      TextureState ts = renderer.createTextureState();
      Texture texture = TextureManager.loadTexture("textures/wood_tex.png", Texture.MM_LINEAR, Texture.FM_LINEAR);
      texture.setWrap(Texture.WM_WRAP_S_WRAP_T);
      ts.setTexture(texture);
      
      rootNode.setRenderState(ts);

      /** an alphaState is needed for transparency effect */
      alphaState = renderer.createAlphaState();
      alphaState.setBlendEnabled(true);
      alphaState.setSrcFunction(AlphaState.SB_SRC_ALPHA);
      alphaState.setDstFunction(AlphaState.SB_ONE_MINUS_SRC_ALPHA);
      alphaState.setTestEnabled(true);
      alphaState.setTestFunction(AlphaState.TF_GREATER);
      alphaState.setEnabled(true);

      rootNode.setRenderState(alphaState);
      rootNode.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);
}




public void simpleUpdate()
   {
...
       rootNode.updateRenderState();
   passManager.updatePasses(tpf);
}


public void simpleRender()
   {
        
          passManager.renderPasses(renderer);
   }




Do i miss something?

No idea, anybody  :?

Are you  using SimpleGame or SimplePassgame?

Is the Passmanager rendering its passes ?

I am not using either of them. My application is based on Java Swing for the GUI, so i use com.jmex.awt.SimpleCanvasImpl.

That should be the problem but i dont know what code i must include to have a working shadow pass manager.



From the code i have posted, I do think Passmanager renders its passes:





public void simpleUpdate()

{



      rootNode.updateRenderState();

passManager.updatePasses(tpf);

}





public void simpleRender()

{

   

    passManager.renderPasses(renderer);

}

set a Breakpoint or something and make sure simpleRender() is being invoked.

dhdd said:

set a Breakpoint or something and make sure simpleRender() is being invoked.


Yes its being invoked...

Would you mind posting a complete (simple) test.  Just take a look at SimplePassGame and try to make your test only have the necessary functions needed to replicate the issue.  (Don't post your entire application please :))



(also, does jME 1.0 or 2.0 make a difference?)

basixs said:

Would you mind posting a complete (simple) test.  Just take a look at SimplePassGame and try to make your test only have the necessary functions needed to replicate the issue.  (Don't post your entire application please :))

(also, does jME 1.0 or 2.0 make a difference?)



Ok here is a simple test code based on JMESwingTest.java (from jmetest.util).
It integrates a JME into an AWT canvas and uses Swing for the rest of the GUI. I have added some code to support shadows, but the result is the same; i cant get shadows  :'(
http://rapidshare.com/files/186995250/JMESwingTestShadow.java

by the time your application gets to simpleSetup, the display is already created, and setMinStencilBits has no effect.  You might try extending doSetup, set your min stencil, then call super.doSetup()

Thanks!

The problem was exactly that; I was setting the minimum bits of Stencil buffer far after the creation of the display.

lol, thanx Renanse.



I didn't see that and should have, I have made that mistake myself in the past