Can't get point light to cast shadows

Hello! I’ve set a scene with a direct light and a point light.

As you can see only the direct light casts shadows (which also proves that the shadow mode is set correctly). When I try to make point light cast shadow with this code

    PointLight lamp = new PointLight();
    lamp.setPosition(new Vector3f(0, 8, 0));
    lamp.setColor(ColorRGBA.White);
    rootNode.addLight(lamp);

    PointLightShadowRenderer plsr = new PointLightShadowRenderer(assetManager, 512);
    plsr.setLight(lamp);
    plsr.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
    viewPort.addProcessor(plsr);

nothing really happens. I’ve tried to turn off the direct light and its shadow renderer, and, alternatively, to (un)set flush queues as as described in docs, but to no avail. Point light is set directly above 3 objects.

Are you are trying to run 2 shadow renderers and once ?

You have to call setFlushShadowQueues(false) on the first renderer.

Thank you for replies.

Not really. I’ve tried to disable (commented out) the DirectionalLightShadowRenderer and the DirectionalLight with no result.

I’ve tried it. Still nothing.

Simply put, I cannot get point light shadow casting to work whith or whitout the other light source / shadow renderer present and with or without setFlushShadowQueues(false) on the first renderer.

Does the TestPointLightShadows in the repo works for you?

With the exception of

ShadowTestUIManager uiMan = new ShadowTestUIManager(assetManager, plsr, plsf, guiNode, inputManager, viewPort);

which I commented out, it seems to work… Here is a screenshot:

http://i.imgur.com/4xg2zbh.png

NB: PointLightShadowRenderer works and PointLightShadowFilter does not work.

Show me your code, something must be wrong.

Its doesn’t work how? it crashes? it displays no shadows?

It simply does not display point light cast shadows (direct light cast shadows are displayed). Here is the code

        pickables = new Node("Pickables");
//        pickables.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
        rootNode.attachChild(pickables);
        Spatial scene = assetManager.loadModel("Models/Scene1.j3o");
//        scene.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
        pickables.attachChild(scene);

        /** A white, directional light source */
        DirectionalLight sun = new DirectionalLight();
        sun.setDirection((new Vector3f(-0.5f, -0.5f, -0.4f)).normalizeLocal());
        sun.setColor(ColorRGBA.White);
        rootNode.addLight(sun);

        /* this shadow needs a directional light */
        DirectionalLightShadowRenderer dlsr = new DirectionalLightShadowRenderer(assetManager, 1024, 2);
        dlsr.setLight(sun);
        dlsr.setFlushQueues(false);
        viewPort.addProcessor(dlsr);

        /** A white, spot light source. */
        PointLight lamp = new PointLight();
        lamp.setPosition(new Vector3f(0, 8, 0));
        lamp.setColor(ColorRGBA.White);
        rootNode.addLight(lamp);

        PointLightShadowRenderer plsr = new PointLightShadowRenderer(assetManager, 512);
        plsr.setLight(lamp);
//        plsr.setFlushQueues(true);
        plsr.setEdgeFilteringMode(EdgeFilteringMode.PCF4);
        viewPort.addProcessor(plsr);

I know this is very old. But since i found it a few times, and it wasn’t resolved here (it is in another thread), i thought i would post the fix. Or at least what i believe is the fix.

By default Point Lights have a light radius of zero. This is used by the shadow renderer/Filter and hence you get not shadows. Set the point light to the required radius and everything should work fine.

+1

While we’re here (I just didn’t want to make a thread about this yet) does anyone know of any obvious reason why a directional light shadow renderer would stop working only when I change the directional lights direction?

normalize the direction

Already done :frowning:

There’s a fair chance it’s something I’ve messed up

well then a est case would help

Yeah I’ll do that before I start a thread, but I think we both know it’s gonna work fine :stuck_out_tongue:

Soon as I have finished messing with SSR this is next on my to do list