I think this drawing mode could be useful for implementing dynamic lighting
Byjlnr (dev)
Date 2010-06-08 17:41
Edited 2010-06-08 17:54
Well, if you just want to darken stuff, drawing transparent black over it should have the same effect. I used multiplication in Photoshop before, say to "square" the brightness of stuff (or to take the square root, depending on how you see it). Not quite sure what can be done with it so far :)
(Also, my IRC bouncer somehow died, but: :multiply works for me? Gosu::VERSION = ?)
well the idea is i first darken the scene using an image to halve teh color values, then i can put on top of that a spotlight that is just a filled-circle image that does the opposite (multiplies color values by 2). This way i can get a spotlight effect very easily. Using floating point colors this is very easy as you make the darkening image just [1, 0.5, 0.5, 0.5] and then the smaller spotlight image [1, 2, 2, 2] and then just apply all with drawing mode :multiply
You can't really define a color as 0xGGGGGG though—how would you do superwhite with Gosu? :)
I think a spotlight effect could also be achieved using shaders—sorry, I think they're cool! I might play with the shader library from this forum and try just that, for science.
yeah, i'm discovering it's impossible to define colors with channels > 255. Fair enough i guess. Howver another approach is just to define a texture with all colors set at 127 (to halve the brightness of the background image) -- but to keep a circular area with color channels at 255. Moving this 'lightmap' image over the background and drawing with :multiply should give a fairly good spotlight effect, esp. if you have a fuzzy border for the circular area.
Haven't looked into shaders yet but if i can achieve a fairly good effect using this approach then i'll be happy enough :)