#1 Members - Reputation: 131
Posted 18 July 2012 - 09:05 PM
#2 Members - Reputation: 705
Posted 19 July 2012 - 08:24 AM
You will need to learn OpenGL though in order to use this effectively, but once you learn it you won't have to learn a new library for 3d (although you may need to learn a few more OpenGL concepts).
Here's a link to the book I have on OpenGL and so far I have found it pretty useful: http://www.amazon.co...2707587&sr=1-29
Here's a link to a tutorial in doing lighting in OpenGL (although I think it's 3d): http://www.sjbaker.o...l_lighting.html
#define TRUE FALSE //Happy debugging...
#3 Members - Reputation: 1565
Posted 19 July 2012 - 11:43 AM
Assuming your art assets were created looking like they are lit up, at runtime you actually want to darken everything that's not under the light.
I suggest experimenting with blended layers in a paint program until you get the effect you want (hint - additive or multiplicative), then work out how to set up blending in SDL to reproduce your chosen effect.
Edited by mrbastard, 19 July 2012 - 11:44 AM.
#4 Members - Reputation: 3715
Posted 19 July 2012 - 01:50 PM
No need to use OpenGL - though it will certainly open up lots more possibilities. Alpha blending will do what you need in plain SDL.
Assuming your art assets were created looking like they are lit up, at runtime you actually want to darken everything that's not under the light.
I suggest experimenting with blended layers in a paint program until you get the effect you want (hint - additive or multiplicative), then work out how to set up blending in SDL to reproduce your chosen effect.
If you are going to use Alpha Blending in SDL you really, really, really should use the development version (2.0) since it is fairly slow in 1.2.
The voices in my head may not be real, but they have some good ideas!
#5 Members - Reputation: 194
Posted 19 July 2012 - 06:43 PM
Then I suppose you could calculate the distance of your character and other objects to provide the illusion that they are essentially appearing within the viewport area.
I "surf" the web, literally.
#7 Members - Reputation: 131
Posted 20 July 2012 - 12:31 PM
I think it could be relatively simple. If the camera follows your character in a fixed center point you could overlay the rendering with an image that has a transparent center point which fades into black around the edges. You could even make this a sprite and animate it slightly for a closer feel of having a torch lighting the zone.
Then I suppose you could calculate the distance of your character and other objects to provide the illusion that they are essentially appearing within the viewport area.
Yea I was thinking of doing this but if I wanted more then one torch I would have trouble
#8 Members - Reputation: 154
Posted 20 July 2012 - 11:33 PM
Yea I was thinking of doing this but if I wanted more then one torch I would have trouble
You could implent a basic lightmap:
Setup an array as big as your screen:
uint8_t lightmap[SCREEN_SIZE];
- Reset lightmap to 0 (black)
- Do one pass and fill this lightmap, you would basically take your lightsources, fill in whites in your lightmap at their position (use some fade out formula so it gets darker further away from the light source)
- Alpha blend (multiplicative blend) the screen with your lightmap
Although, doing this in software is gonna be pretty slow if you use a high resolution.






