2D lighting- Would this work with my game?

Started by
1 comment, last by theagentd 12 years, 3 months ago
Hello there. I'm working on a 2D RPGish game right now. It has a birds eye view, but the camera isn't completely top down. Think 2D zelda games I guess. I'm planning on implementing some simple lighting; a simple circle(or other 2D shape) of light around the player would suffice. The problem is, I'm not sure if it would look completely right. If a player walked up to a building, the light might not look right on the walls. Do you think this would work decently, or would I have to get more in to some more advanced pixel shaders and 2.5D kind of stuff?
Advertisement

The problem is, I'm not sure if it would look completely right.

I fear, that the only answer is, that you need to implement and test it yourself. You could try to take a look at similar games and try to guess which technique they use, maybe you're lucky and get more information about the used technique (developer sometimes talk about the used technique in interviews,blogs, gdc etc.).

An other option is, to create a mock-up screenshot of your vision with photoshop/gimp and ask around here to get some feedback about feasibility and possible technique ideas.
This is completely possible and can look great. I implemented this a few years ago for a tile-based 2D game, and it looked great but I never finished that game. Today the source code is way too hacked up and some resources are missing so I sadly can't provide you with a screenshot. I just implemented hard shadows from this article using framebuffers in OpenGL:
http://www.gamedev.n...t-shadows-r2032
It's easy to render the shadows of blocking tiles as the technique in the article works fine for them, but it's also possible to make sprites cast shadows by rendering them as in a black color stretched away from the shadow caster. The real problem is making sprites have correct lighting. A solution to this is to sample a line of the "lighting map" at the bottom of each sprite and apply that over the whole sprite, but this does not work too well for tall objects.

Jeez, now I want to implement this myself!!! T___T


EDIT: Managed to dig something out and get it running after some oiling up...


spriteshadows.png

It doesn't show any tile shadows, but it should give you an idea of how it looks. Well, maybe a little at least... Anyway, this demo runs at over 200 FPS on my laptop with over 300 lights. Granted there's only a single shadow-caster, and many of the lights have been culled, but it also runs smoothly with 1000 lights, barely managing 60 FPS...

This topic is closed to new replies.

Advertisement