Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Brin

Lighting In 2D

This topic is 6203 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Alright I''ve been thinking about this for a little while, never actually sat down and tried my ideas yet... But I was wondering: How would you guys do lighting in 2d? And how would you do COLORED lighting in 2d? -Brin Perpetual

Share this post


Link to post
Share on other sites
Advertisement
Well maybe this sounds a tad bit stubborn but personally I''d use a 3D API without mipmapping or anything of that sort. Throw in some vertex lighting on your Quads and VOILA! Lighting! Plus you get hardware alpha, rotation, scaling, etc to boot. Of course, you have to make sure you keep your coordinates VERY accurate. Nothing looks worse than cracks in 2D.

Share this post


Link to post
Share on other sites
If you''re using DX 7, switching to Draw Primitive is not much of a stretch as you can keep the engine running and work one step at a time. If you switch to DX8 you''ll have to rewrite everything and it''s not really worth it.

Primitives use the same screen coordinates as blits. The only "challenge" is getting the non perspective view.

http://therabbithole.redback.inficad.com

Hit the tricks section. There are a couple tutorials on it.

Ben

Share this post


Link to post
Share on other sites
That''s not actually what he asked though...

I''ve been thinking about this myself, and I''ve come up with a few ideas.

The first would be a kind of light mapping where the offset of the pixel is used as an index into a light texture, and then blend the intensity with the base pixel. It''s actually very similar to bump mapping but without the bump

The other idea was a per-"vertex" method where each pixel is gradient shaded according to a brightness value at the corners of the bitmap.
I''m sure all of the standard lighting models could be applied to a 2D surface, like we used to do to polygons before hardware cards came along

You wouldn''t want to dynamically light a whole tile map in real-time, but with some static pre-lighting and then a few dynamic lights it should run OK.

Coloured lights are almost exactly the same but instead of using a byte value for illumination you use a colour value, and multiply each colour channel of the image by the matching channel of the lightmap. Incidentally this is totally free (over the non-coloured) if you use MMX instructions to do your pixel operations.

I''ve written a 2D bumpmap routine with coloured lightmaps and that runs pretty fast, I''m working on a tile engine at the moment that I can add lighting to.

Share this post


Link to post
Share on other sites
Thank you Ruval.

Yes, I was thinking about looking in to MMX... Got any good sites with Documentation, etc..?


-Brin

Share this post


Link to post
Share on other sites
The Intel Developer site at developer.intel.com has the basic
docs, and I think there''s an article on mmx alpha blending here on gamedev. I''m assuming you know assembler, it''s the only way to use mmx directly AFAIK.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!