• Advertisement
Sign in to follow this  

fake diffuse lighting?

This topic is 4486 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 would you fake diffuse lighting for a 2d game? i assume that it would involve alpha blending, but i'm not so sure

Share this post


Link to post
Share on other sites
Advertisement
You can also use the accumlation buffer, using different "light sprites" to add lighting.

Share this post


Link to post
Share on other sites
2 textures
One containing the backbuffer
One containing the lights
Modulate them as output

Render your game as normal, then copy the backbuffer to the first texture.
For the texture containing the light, each light is represented by triangles. Simple spot light, 1 triangle. Point light, tri fan. Render each using SRCBLEND_ONE and DESTBLEND_ONE to the light texture (which is cleared as black) with 1 alpha in the center and 0 alpha for the verts on the edges.

Using stencilling, this method can also give you really cool shadows.

Example of what this would look like



If your using DirectX, I can help you with the actual code.
Hope this helps :)

Share this post


Link to post
Share on other sites
Quote:
Original post by Eddycharly
CadeF, nice technique.
unfortunately it only works on flat environements.


Um... isn't that what the OP was looking for?

Share this post


Link to post
Share on other sites
ok, i think i understand
there's a few things i'm not so sure about though,
such as how would you implement colored lights and stuff

Share this post


Link to post
Share on other sites
Colored lights - Change the color of the light's center vertex (only one), while all other vertices are RGBA 0,0,0,0

Share this post


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

  • Advertisement