Lights in Defold?

Hey guys,

I’m a seasoned web developer but new to game development. In fact I started with Java & Android about a month ago and started playing around with libGDX and now I’m a couple of weeks away from releasing my first Android mobile game, a top down driving game that has lighting as one of the core ingredients.

Yesterday I saw a post (on Reddit I think) where Defold was mentioned and I looked it up and it was love at first sight :heart_eyes: Defold is very new to me of course but I really like what I’ve seen so far. So I was thinking about re-creating my game in Defold as it’s a small game.

However, I can’t seem to find anything about lights, in specific ambient and cone light…

This is a small demo I made when I was first playing around and learning libGDX with Box2D & Box2D lights.

So my question is if such light effects are possible in Defold (without much hassle)?

Thank you.

4 Likes

I just want to clarify that the reason I decided to make lights an essential part of my first game is because a) I can’t draw a straight line to save my life and b) as a new game developer my planned budget for trying out something new is very limited (read zero) as this is a new and unknown market to me.

So I have to rely on free art and as much as I appreciate people who create free art, it still limits what I can do and the environment I can create for the player. To get around this limitation I decided to have a night environment with cool light effects…

Here is an example from the early stages of the actual game, with and without ambient light… I’m sure you will agree that there is a huge difference and that the night image looks a lot better, real, mature or whatever you want to call it even though it’s exactly the same images.

And finally a small animation of the driving at night, with different light upgrades.

Not that this adds anything to my question, I just wanted to clarify why I need the lights so much, to hide my total lack of skill for anything remotely related to what can be defined as art :slight_smile:

4 Likes

Yes, you can certainly do the effects you describe, but unfortunately we don’t have much in place that helps you along (like a ‘light’ component would). What you need to do is make the lights yourself by writing your own render-script. It’s basically opengl through lua. I’ve seen some cool lighting demos by @FredrikMalmer made this way.

2 Likes

Hi Ragnar,

Thank you for your reply. I think I will definitely have to look into and learn OpenGL if I want to pursue a future in game development, but at this stage I think it might be a bit overwhelming for me. I’m already struggling with all the geometry, trigonometry, etc which I never needed as a web developer and that I haven’t touched even once since ~20 years ago in school. I’m seriously worried my head will explode (or implode, I’m not really sure which) if I push myself any harder :joy:

Perhaps the best solution is to just finish this game up in libGDX and if it somehow generates some revenue, invest that into some art for a game where I won’t be ashamed to turn the lights on :slight_smile:

3 Likes

@d954mas played with lights and shadows using a shader and wrote a bit about it in this post: Problem with shader

@d954mas: Did you have some code to share as well or at least an HTML5 demo of the light effect?

1 Like

I can share code, but it is not well organized, and contains some bugs(bad shadows on android, and broken HTML after shader optimisations), few commits before head all work) It is not well example, it is something like proof of concept. I share it tomorrow on github.

4 Likes

I push lights on github
To understand what happened there read article https://github.com/mattdesl/lwjgl-basics/wiki/2D-Pixel-Perfect-Shadows
My example contains only point light. You will need to write cone light yourself. It is similar to point light, but you need limit rays angle. The head commit contains problem with shadow, so try shaders from article, or use commit before shader optimizations=)

3 Likes

Hi Dima,

Thank you for sharing your code, appreciate it :+1: I will definitely look into and play around with this.

4 Likes

Great,
thanks for sharing. I’m testing different game engines and I’m implementing something very similar to this in all of the engines I’m testing. Currently I get a really good performance on android using cocos2d-x and C++. I’ve implemented it in gideros but it was too slow and I was just about to do it in defold but now you saved me a lot of time.

4 Likes

Nice! It would be interesting to hear your thoughts on Defold and how it compares once you’ve had a chance to use it for a while.

3 Likes