Sign in to follow this  
moonshine

2d lighting

Recommended Posts

I've been wondering if it's possible to make flat 2d planes react to light sources. Im using D3D 9.0b, and Im going to be using alpha channel transparency on my sprites, which rules out using the alpha channel as lighting info. Basicaly its going to be a 2d game, but I want sprites to react to light sources, preferably without using D3D's lights. The only thing I can think of is using an 8bit b/w image over each sprite and alphablend them, or multitexturing (not sure about older card support on that). does anyone have any idea how to do this? Bumpmapping could also be an option but I dont know how older cards deal with that.

Share this post


Link to post
Share on other sites
Hmm. i had a similar idea recently, and i did a test program (with allegro though). I used gouraud shaded sprites and a little calculation to get the "light-strenth" for the four corners of each sprite. I could send you the source/exe if you want it, send me an email if you're intrested... (jonatanhedborg@hotmail.com)

Share this post


Link to post
Share on other sites
Since your using D3D, use the same method used in 3D games. Multitexture the lightmap with the texture (MODULATE the two, alpha blending does not give you lighting). This will handle lighting the tiles on your map. To apply the lights to sprites that are above the tiles, do the same thing, but use the stencil buffer to mask away pixels that are not on the sprite.

You can do dot3 lighting and bump mapping as well, but it requires some extra work. Also, I've done this and it and it's significantly slower the regular lightmapping.

Share this post


Link to post
Share on other sites
Quote:
Original post by moonshine
The only thing I can think of for that is a normal map, but I dont know if theyre supported on older cards etc


DOT3 is supported on a wide range of gpu. Most card sold in the last 4 years supports it as far as i know. Of course, you still have some problems with i815, older ati chipsets, and so on ;) You may have a look to the delphi3d hardware database to see wether your target gpu supports DOT3 or not (I'm not an OpenGL guru but I think this is the GL_xxx_texture_env_dot3 extensions, where xxx is ARB, EXT,...).

If you sprite are not too big, you can still try to emulate some kind of bump mapping on older adapters, using an embossing technique.

Yours,

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this