[SOLVED] Model taking shadow from itself

I just notice an odd problem with the shadows, it seens the objects are taking shadow from itself :

Those objects are using :

spatial.setShadowMode(RenderQueue.ShadowMode.Cast);

This is the lights on the scene :

    // Sun Light
    sun.setDirection(new Vector3f(1,0,-2).normalize());
    sun.setColor(ColorRGBA.White.mult(0.6f));
    rootNode.addLight(sun);
    rootNode.attachChild(sunLightNode);

    // Ambient Light
    ambient.setColor(ColorRGBA.White.mult(0.2f));
    rootNode.addLight(ambient);

    // Configure Shadows from the sun
    final int SHADOWMAP_SIZE=256;
    DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, 3);
    dlsr.setShadowIntensity(0.2f);
    dlsr.setLight(sun);  viewPort.addProcessor(dlsr);

Obs: There is some lights in the model, but I tried to remove those lights and got the same effect.

Any tip ?

Does your space ships has special setting, like not writing depth, being in a trasparent bucket or non obvious things that we should know?
Post the code where you load and add the space ship

Nothing specialā€¦
The code abore is from another object that is getting the same effect :

    spatial = Main.ref_assetManager.loadModel("Models/enemies/triangle/triangle.j3o");
    spatial.setName("triangle_"+String.valueOf(indexnum));
    spatial.setShadowMode(RenderQueue.ShadowMode.Cast);
    ownerNode.attachChild(initialRotationNode);
    objNode.attachChild(spatial);
    initialRotationNode.attachChild(objNode);

The material for this particular object is lighting.j3md with single texture on difusemap and specular/difuse = 1,1,1,1 , ambient = 0,0,0,1. I am using this setup for almost every object, not sure if there is something wrong with this ambient 0,0,0,1.
Blend = off , facecull = back.

Also, it looks like its happening with all objects, I think it allways happend, but I just notice today.

Could you test with cast and receive?

Yes, same problem with cast and receiveā€¦

Can you see anything wrong in this ? :

    // Configure Shadows from the sun
    final int SHADOWMAP_SIZE=256;
    DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(assetManager, SHADOWMAP_SIZE, 3);
    dlsr.setShadowIntensity(0.2f);
    dlsr.setLight(sun);  viewPort.addProcessor(dlsr);

Also, this is the code I use to load the planet ( that will receive shadows ) :

        Spatial s_planet = assetManager.loadModel("Models/planets/planet_cold_venus/planet_cold_venus.j3o");
        s_planet.rotate( 90*FastMath.DEG_TO_RAD , 0 , 90*FastMath.DEG_TO_RAD );
        planetNucleNode.attachChild(s_planet);
        s_planet.scale( 7 * 120/100);
        planetOrbit_ratio=11 ;
        sun.setColor(ColorRGBA.White.mult(0.6f));
        ambient.setColor(ColorRGBA.White.mult(0.3f));
        s_planet.setShadowMode(RenderQueue.ShadowMode.Receive);

Do anyone have any idea where to start looking ?

Do you have a FilterPostProcessor? If so, Make sure the shadow renderer is added to the viewport before the filterPostProcessor.

1 Like

You are right !
I cant believe it was so simple to fix it !
I really thought post processors like glow should be declared only once per game, and I put it in the first lines of the main class.
I guess a lot of people do the same mistake.
Thanks friend, you are the best !