Jump to content
  • Advertisement
Sign in to follow this  
zike22

Per-pixel lighting??

This topic is 4683 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

How do you do per-pixel lighting in 2d. Do you know of any articles or tutorials. Is it just transparency-blending or something??

Share this post


Link to post
Share on other sites
Advertisement
Although I have no experience with per pixel lighting in 2D (or very much in 3D for that matter), I would have to say that it's probably no different. Well, maybe a little different. You might be able to ignore or fix the z coordinate to some value, to simply calculations.

Share this post


Link to post
Share on other sites
All the tutorials i saw delth with the angle of the light and what not, can I really just drop Z coordinates??

Share this post


Link to post
Share on other sites
All the tutorials i saw delth with the angle of the light and what not, can I really just drop Z coordinates??

Share this post


Link to post
Share on other sites
Quote:

About dropping z coordinates


Probably not, depending on your technique you'll still need a fake z coordinate to generate alright tangent space normals.

--CJM

Share this post


Link to post
Share on other sites
Quote:
Original post by CJM

Probably not, depending on your technique you'll still need a fake z coordinate to generate alright tangent space normals.

There's no need to transform coordinates into tangent space when doing per-pixel lighting in 2D.

EDIT: zike22, if you don't want to use shaders, you can use OrangyTang's method.

Share this post


Link to post
Share on other sites
It depends on the complexity of lighting you want. Do you want shadowed objects? Or do you just want to create a feel of different ambient lighting conditions. Maybe a simple alpha overlay would suffice for your purposes?

Share this post


Link to post
Share on other sites
If you don't need bumpmapping the easiest way is to:

- Draw all lights to frame buffer. Drawing the light is just a matter of drawing circle using some triangles. Draw all lights additivly.

- Copy framebuffer to texture

- Clear framebuffer

- Draw all graphics to frame buffer.

- Draw light texture modulative to the framebuffer.

Might not be the fastest way but should be pretty simple and you can make it support shaodws aswell.

Share this post


Link to post
Share on other sites
Yea, I totally forgot to mention that the gameI'm working on is a 2d scroller so, maybe I'm just stupid but I don't see how Orangy Tans method would work for me(but thanks anyways).

It probably is an alpha-blending thing. I just want characters to be able to shoot out lights and use a flashlight, things like that. To add a little more depth to the games "stealth system".

Share this post


Link to post
Share on other sites
Well, I don't see why OT's method wouldn't work in your case. [smile]
But anyway, now that I think of it, Hardguy's method seems simpler. However, I suggest using quads with light textures on them instead of circles. This way you can easily get non-linear light falloff, for example.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!