Adding lights - light map

Hi,

Ok, I can draw a ‘light’ into a FBO and then render over the screen no problem. Now, is it possible to map lots of these ‘lights’ into some sort of 2d array that matches my game world and ‘scroll’ these into the FBO when the game world scrolls?

Hope that makes sense?!

Thanks

Actually it would be the same logic than you use to relocate your tiles in the color buffer when the game world scrolls…

Thought as much,

Tiles are procedurally generated, so not 100% sure where lights would go. I can let user add them, but could simply use Box2dLights I guess for that?

Yes. It depends however, how you are handling the scrolling and culling (e.g. translating the viewport/camera or offsetting the x/y coordinates before placing the tiles). I would use constant world coordinates with a moving viewport, so there is no guessing, what is at which x/y in the world at any given time.

But regardless what you use, you just have to make sure, you are applying the same mechanism for all layers you add.

I’m translating the camera around to do the scrolling.

Thanks