Working with spotlights in a model

Hey there guys,

currently I am setting up a main menu 3d scene, right now it is a big model.

I layed everything out in the scene composer and it looks like this:

As you can see i use quite a lot of light sources. Right now the organization of the scene looks like this:
Every nodes contains certain light sources. So far so good.

The thing is i use point lights and some of them work as intended. However every spotlight and some of the point lights are not “shining”.

Ingame looks like this:

As you can see the spot lights are not working properly and some of the point lights (the one that should illuminate the DOOM title). I tried to debug it, managed to get the LighLists of my nodes and all the lights are there, so i would assume they would be “rendered”.
I do not really understand why this is happening.

The code to load the model:

public void build3DMenu(){

        final Spatial menu3DModel = app.getAssetManager().loadModel("Scenes/mainenu/MainMenuScene.j3o");
        Quaternion rotate90clock = new Quaternion();
        rotate90clock.fromAngleAxis( FastMath.PI / 2, new Vector3f(0, 1, 0));


        LOGGER.log(Level.WARNING, ((Node) menu3DModel).getChild("Title").getLocalLightList().get(0));


As you can everything is loaded from the model. So i guess there is the problem but thats just an assumption.

im not sure about point/spot lights issue(maybe range parameter or something else), but just want to mention that you should make sure to use materials properly. For example for PBR you should use light probes(+ AmbientLight optionally). Usually PBR models are just black since there is no light probe.

For non-pbr models, use AmbientLight+DirectionalLight.

Spotlight/Pointlight should work for both.

Also, your SDK scene preview also use light from camera, same as point/spot one.
So it might be that you just have wrong directions/positions of lights.

If i remember correctly lights do not shine on other brances of your scene tree. i thin if you want all lit, you have to add the lights to the rootnode

1 Like

Yep, lights only illuminate the portion of the scene tree to which they are added… ie: the light list of a node only affects the node and it’s children.

“Why the heck would the engine do that?!?”

Well, because for every active light in the view, the scene is rendered an additional time… once per light. 100 lights currently in view, scene is rendered 100 times in a single frame.

If you have a lot of lights and your lights are not dynamic then you may be better off baking them. JME does support baked light maps.

Edit: else for a handful of lights on screen at any given time, you are probably fine.