Author Topic: Help with light and darkness  (Read 1777 times)

Diarandor

  • Hero Member
  • *****
  • Posts: 1053
  • Cats are cool! (ΦωΦ)
    • View Profile
Help with light and darkness
« 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!!!
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

wrightmat

  • Sr. Member
  • ****
  • Posts: 259
    • View Profile
Re: Help with light and darkness
« Reply #1 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.

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1177
    • View Profile
Re: Help with light and darkness
« Reply #2 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.

Diarandor

  • Hero Member
  • *****
  • Posts: 1053
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Help with light and darkness
« Reply #3 on: September 20, 2014, 05:42:18 pm »
Thanks a lot again for your help!
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”