So me and my friend are working hard on our 2D game engine based on LibGDX, and it can do a lot but there is no support for Lights, So we need to implement a good lighting system,

I am relatively new to shaders though, while I've read lot's of cool tutorials on how it's done, the question that is left for me is an architecture of that all.There are tons of tutorials on how to cast a light on one particular texture, but we have an entire scene, build of many many textures.

So what is the best way to do that? Render all scene to FBO, then apply light to it? if so, is it optimal to render entire scene to FBO or maybe just parts that potentially will be light up? What are the common practices/mistakes? Basically I am not seeing entire picture of how is this usually done Anyone did this before? would really appreciate any help or advice, and I can provide a screenshot of a level for example to make it really clear what I need to be done.

Busy between school, work, life, games, programming and general screwing around.If you'd like some pixel art for your game, send me a PM, i'll see what I can do.Current project: http://elementalwarblog.wordpress.com/

Haha, i hoped for an much more simple design (square tiles) .I guess the simplest solution is using an texture with all the light sources (in small scale).Hopefully someone with more knowledge could answer this, im curious about it to

But it's worth mentioning that I do not need any complex type of lights like directional ones, just point light that ill illuminate it's surroundings in a round shape.I can basically do this with a small fragment shader code for one texture, but if used on entire screen I guess a Frame Buffer Object needs to be used, and here I am not sure about architecture and best practices.

A spot(or point) light is usually light that starts from one specific point and continues outward. Is that sort of what you're looking for?

Busy between school, work, life, games, programming and general screwing around.If you'd like some pixel art for your game, send me a PM, i'll see what I can do.Current project: http://elementalwarblog.wordpress.com/

I am not sure about the naming, I am looking for effect that looks like a round circle. (you can see it on a screenshot)Basically it's a simple effect of a gradient fading circle that overlays the scene. It gives the near surroundings a color. It does not have direction or anything.

And most importantly it does not need any fancy things like stop on walls or whatever.

That is a point light. The first link I posted should help you understand them.

Busy between school, work, life, games, programming and general screwing around.If you'd like some pixel art for your game, send me a PM, i'll see what I can do.Current project: http://elementalwarblog.wordpress.com/

Do the lights need to be dynamic? If not, just bake them into your textures.

If the lights need to be dynamic, you can "fake" it by overlaying them as a second draw pass. Basically this involves rendering a transparent feathered circle atop your scene, using different vertex colors and blend modes to achieve something like this (Slick code here). The problem, of course, is that it is not truly dynamic -- it won't cast any shadows if you place the light next to an occluder (wall or player).

For something more dynamic you'll want to use a solution like in box2dlights. If you want to learn how it works, read here.

You can also use a normal mapping technique like I discussed in the tutorials, but generally that's not going to be very efficient if you have many lights (unless you apply some sort of deferred lighting technique). Further, these shader-based techniques may perform poorly on Android/iOS.

Wow, thanks! I think I am more interested in the one where it is pseudo dynamic, I am afraid bo2xlight might be using too much resources, so I'll take a look at your example code, looks pretty good so far! This is nor a primarily Android game, it is PC, but with a possibility of future Android port.I will look at the example code more detailed tomorrow, but just to clarify, is this the right method?1) Draw entire screen to buffer2) Overlay Light to buffer using shaders3) Render buffer to actual screen4) Render elements that are not affected to light on screen.

If so, is there a room for optimization like:1) render only parts that are expected to be affected by light to buffer so buffer will take less memory? (Does this make sense?)2) Any caching techniques maybe?

box2dlights will generally be less intensive since it is not dependent on fill-rate and multiple draw passes.

The steps you outlined will work but involve more fill rate. Really the main performance hit here is the extra fill and state changes involved with rendering to an FBO with different shaders before rendering to screen.

So, that means that even if I do not need "more dynamic" system, box2dlight is still better in performance then the fake dynamic overlaying to buffer approach?

As author of box2dLights I can say that performance with box2dLights is way better than any other multiple light solution that I have tested. If you don't need shadows then algorithm is cheap as hell. Its designed to work with mobile devices so performance with pc is top notch.

Oh well, that's great to hear then! we just go ahead and try to use it then! Thanks a lot!

First i read through the code of box2light I was a bit worried that it uses a physics engine to do a calculations, and I thought it might be slow, but yeah if you say it's not then it's great news.

I hope it is possible to use it with Stage class right?

Should be usable with Stage.Box2d is only used for raycasting what is needed for shadows. Box2d have really good and efficient acceleration structure for collisions so that plus native code make generic raycasting with it really fast.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org