Lighting issues

I know there’s a lot of newbies complaining about all sorts of lighting issues but I’m really stuck here, please bear with me.
I’m having trouble with the lights in my scene. Note: All objects in my game are JME boxes.

First issue: In my main class I’m adding three lights to the rootNode, ambientLight, directionalLight and pointLight. I have a box (Lighting.j3md) as the ground, and a lot of small boxes (placeholders for enemies, also Lighting.j3md) that moves along the z-axis after each other. When the first box enters the screen, the light is as expected. When the second box enters the screen, it’s darker, as if it only has ambient light. Now here’s the strangest part: when the first box leaves the screen, the following box gets lit up. And when the second box leaves the screen the third box gets lit up, and so on. Any clues??

Second issue: I had the lights added by code. Then I changed the design so that the lights are added in my Level1.j3o file, which only contains the ground and the three lights described above. I didn’t think this should change anything visually, but once I did this all the boxes/enemies were not shown until I added a pointLight over each of them. However, every box/enemy also has a green health indicator hovering above them and that was still visible (unshaded.j3md). Any clues?

Hope you can help me out here! :slight_smile:

Also I should mention that I’m only using diffuseMaps.

If you add no lights to your scene, you won’t be able to see anything using the Lighting.j3md material
Ambient lighting isn’t really lighting at all, it just makes everything look as it has some kind of ever-present light, it’s usually used in combination with the ‘proper’ light as a cheap imitation to make things look as if they are lit.

If you add light to your model in your j3o, then every instance of that model that you add to your scene will have that same light. So, if you add in your light into your j3o file, then add in some cubes on another node do you think you will be able to see i̶t̶ the cubes?

  1. Check to make sure they aren’t casting shadows on each other. Just to rule this out, you could simply do like this at the top of your main class for testing and make sure you never override this by commenting out every lines that you called setShadowMode():


  1. Any “unshaded.j3md” material will show regardless of lights. There could be NO light at all and it would still render exactly the same. I am unsure about including the lights in your “Level1.j3o” as I have (I’m sorry) never used the SceneComposer, but maybe somebody else here could guide you using it. If you want to keep the lights creation like it was before in the code, I could help you more, but please copy/paste your main class here or link to it so that I can spot the bug, thanks.

Thanks for the replies guys!! It’s always helpful to get input from others, we all think different.

I found the cause - I had overlooked some piece of code that added a normalMap to the boxes. :facepalm:
When I removed the normalMaps, the issues disappeared. Then I used the TangentBinormalGenerator on the mesh and the problem was solved!

1 Like

Yeh, you have to generate the tangents for the normalmap to work right