Solarus-Games English Forum

Solarus => Development => Topic started by: Diarandor on September 20, 2014, 03:28:31 AM

Title: Help with light and darkness
Post by: Diarandor on September 20, 2014, 03:28:31 AM
Hi,

I would like to know if it is possible to program dark rooms where there are several sources of light (including the hero, some moving enemies, and torches on walls). Outside the illuminated areas there would be opaque darkness. Is it possible to do this? And how?

Thanks for your help!!!
Title: Re: Help with light and darkness
Post by: wizard_wizzle (aka ZeldaHistorian) on September 20, 2014, 04:43:16 PM
I don't believe it is currently, as I also need this for my game. The current approach to darkness/light is to apply a dark sprite over the whole screen, with a transparent area in the middle which appears as "light" (and can follow the hero, such as with the lamp). The problem is that you can't apply multiple lights because there is no actual light, only a lack of darkness in a small area. If you had pre-arranged areas of light, I suppose you could do multiple "cut-out" areas in the dark sprite, but this can't be done dynamically.

Eventual implementation of shaders in the engine could allow for more advanced lighting effects.
Title: Re: Help with light and darkness
Post by: Christopho on September 20, 2014, 05:09:30 PM
I confirm wrightmat's answer.
We have an issue for this: https://github.com/christopho/solarus/issues/466
surface:get_pixels() and surface:set_pixels() is a first good solution: you could at least build your own darkness mask.
Title: Re: Help with light and darkness
Post by: Diarandor on September 20, 2014, 05:42:18 PM
Thanks a lot again for your help!