The easiest and fastest way to get your lights on in Defold

For the past month ive been working on a lighting system for defold. It is as simple as it can get, and supports normal mapping too! Also, i made a 3D camera to help me visualize the rendercam camera’s object better, if the creator of rendercam wants, they can surely use it on the API, or any other person for that matter! Im quitting defold in hopes to find an engine with a more 3Dish approach, but im so glad that i wont be leaving Defold with nothing to contribute to. Much thanks to everyone in the server who helped me set up all of this!


FYI, there is an error when you run the project, maybe you have some changes that didn’t get pushed?

ERROR:SCRIPT: assets/scripts/light_reciever.script:16: ‘#mBigCube’ does not have any property called ‘light_options’

Good luck with your engine search! It’s slim pickings for quality stuff out there (especially 3D).


Oh thats no odd behaviour, it just so happens that the normal mapping just doesnt use that variable, gonna fix this. EDIT: DONE!

1 Like

Hmm, does that fix the error for you? I’m still getting the same error, except now it’s for ‘#lit_mesh’ instead of ‘#mBigCube’. I believe you need to define those shader uniforms you’re using in the material file.


@Caue-Aron - great! The errors concerning the properties are gone now :smiley: But the model is sadly still unlit:
Screenshot 2022-11-19 at 13.47.04
In the read me it says: “Apply the light_reciever material to your mesh”. I can’t find this material in the project. :face_with_monocle: Renaming the ‘house.material’ didn’t do the trick. I’d love to see your cool light bulbs in action.
Ah, just noticed - this is the 2D collection running. Still dark though, like the 3D one.


OMG, it should be working, it works just fine to me… I gonna have a look

I all looks fine for me tho, i just cloned the repository and no errors:

1 Like

Hello @Caue-Aron!

Ah, seems to be a Mac issue, here the models stay black. So I just tried on Windows. Here both scenes are lit with beautiful lights :partying_face:
I do get the property errors though in the 2D scene (none in the 3D scene).

But the model changes colour nicely as the lamps orbit around it.
I can’t try on Linux, my Linux machine has died a death - maybe some else could check for you?


On Linux here, as you can see I get the error and the lighting doesn’t work (it doesn’t change as the lights orbit around):

It looks like the error happens because you’re not actually using those shader uniforms at all in the shader: “light_options”, “light_dir”, and “light_dir_color”. Apparently your little trick with making a local float with them to pretend to use them doesn’t fly on Linux, I guess the compiler is a bit smarter here. :grin:. Since they aren’t used at all anyway, they should just be removed.

So the error is easy to fix: just don’t use shader variables that you don’t use! :grinning_face_with_smiling_eyes:

I didn’t dig around much past that, so I still don’t know why the actual shader code isn’t working as expected.