Per-pixel lighting??
How do you do per-pixel lighting in 2d. Do you know of any articles or tutorials.
Is it just transparency-blending or something??
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??
All the tutorials i saw delth with the angle of the light and what not, can I really just drop Z coordinates??
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.
- 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".
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".
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.
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
Popular Topics
Advertisement