Per-pixel lighting??

Started by
12 comments, last by zike22 18 years, 8 months ago
How do you do per-pixel lighting in 2d. Do you know of any articles or tutorials. Is it just transparency-blending or something??
------------------------------------------------------------------------------------------- My Email: [email=zike22@aol.com]zike22@aol.com[/email] - My AIM: zike22@AIM
"Facts are chains that bind perception and fetter truth. For a man can remake the world if he has a dream and no facts to cloud his mind." - The Emperor, WarHammer 40K
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.
All the tutorials i saw delth with the angle of the light and what not, can I really just drop Z coordinates??
------------------------------------------------------------------------------------------- My Email: [email=zike22@aol.com]zike22@aol.com[/email] - My AIM: zike22@AIM
"Facts are chains that bind perception and fetter truth. For a man can remake the world if he has a dream and no facts to cloud his mind." - The Emperor, WarHammer 40K
All the tutorials i saw delth with the angle of the light and what not, can I really just drop Z coordinates??
------------------------------------------------------------------------------------------- My Email: [email=zike22@aol.com]zike22@aol.com[/email] - My AIM: zike22@AIM
"Facts are chains that bind perception and fetter truth. For a man can remake the world if he has a dream and no facts to cloud his mind." - The Emperor, WarHammer 40K
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
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.
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?
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.
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".
------------------------------------------------------------------------------------------- My Email: [email=zike22@aol.com]zike22@aol.com[/email] - My AIM: zike22@AIM
"Facts are chains that bind perception and fetter truth. For a man can remake the world if he has a dream and no facts to cloud his mind." - The Emperor, WarHammer 40K
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.

This topic is closed to new replies.

Advertisement