Jump to content
  • Advertisement

Archived

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

xardias

2D soft shadows

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

Hi there, I just read the Article about 2D soft shadows. I tried to implement such a feature into my own game. Everything went well, until I tried to use multiple lights at one object. The problem is, that the shadow of a second lightsource will be drawn over the first light source, and removes the light intensities. Well have a look: http://d3-genetic.de/ftp/xardias/shadow5.jpg The right Shadow is great, the lightsource has been drawn over it and lightens the shadow (by additive blending). But the left shadow has been drawn after the lightsource so the shadow removes the light intensity. Orangy Tang told me, that he has a rendering pass of all visible objects, done once per light. Well i draw these two lights light like this: - Render Lightsource 1 (this multiplies the colorbuffer with a triangle fan and vertex colors) - Render shadow of Lightsource 1 (here the the shadow casted by the lightsource 1 is calculated. - Render Lightsource2 (the second Lightsource is rendered, it lays over the shadow of the first, so the shadow is lightend) - Render shadow of Lightsource2 (the shadow casted by the second light is calculated. It will be drawn OVER the first lightsource, so the second lightsource will be oppaqued) Should I use Depth testing to place the shadows ? But then i would have problems with the blending operations... Greetings Dennis ''Xardias'' Kempin PS: Please forgive my english.

Share this post


Link to post
Share on other sites
Advertisement
I''m pretty sure its not your depth testing thats causing that, but i''m not totally sure on the rendering order. You need a pass per light that looks something like:
- fill light intensity
- mask off shadows
- draw scene modulated by this lights intensity

Could you give more detail on when and how you draw your scene geometry in with your lighting passes?

Share this post


Link to post
Share on other sites
Well at the moment i''m only trying to render a lightmap, completly without the geometry.
It looks like this:

- Clear whole ColorBuffer
function RenderLight{
- Set Blend mode to additive colors (GL_SRC_COLOR, GL_ONE_MINUS_SRC_COLOR)
- Render the triangle fan for filling the color uffer with the light intensities
- Calculate normals/Backfaces/Boundarypoints/etc
- Disable blending (we dont want the shadow to be translucent)
- Render shadow "volume"
- Set Blending to Multiply Colors (GL_DST_COLOR, GL_ZERO)
- Bind penumbra texture
- Render the Penumbra
- Unbind Textures
- Disable blending
}
- Call the whole stuff again (RenderLight) only with other light position.
- Display Szene

Well this way I render the light.
I dont think this is possible to do with only one lightmap.
So I want to render one texture for every light.
This texture i will render like this:

- Disable Blending
- Render light intensities
- mask off shadows
- save image to texture

After that is done for each light. I can activeate Additive Blending and blend them all together to the screen.
That has one big advantage:
If a light (ore the shadow casting objects) have not moved, i can use the light texture of the last frame, and do not need to render it.

But if you see my fault, please tell me

thanks and greetings
Dennis

Share this post


Link to post
Share on other sites
You will need to use a lightmap for every light, if you''re only using one at the moment then thats your problem.

If you''re already doing that, I''d guess its your blending state thats not doing quite what you think. Check each lightmap is actually correct (generate both, but only draw the one on the right that causes problems), you could have some state carried over incorrectly that you''re not seeing.

Assuming the individual lightmaps are correct, then it must be how you''re combining them. I''d double check you are actually enabling additive blending, the results in the picture would be produced if you left the same blending as you use for the shadows on.

Your method also has the advantage of only having to draw the scene once (instead of once per light as I use), so it sounds like a good optimisation. However I''m not sure how you''d manage having lots of lightmap textures of different resolutions around constantly.

Share this post


Link to post
Share on other sites
well, i used only one lightmap for all lights.
i gonna implement multiple lightmaps.
Well i will set the viewport to 512x512, so all the lightmaps will have the same size. When the scene is rendered i can scale the texture to the radius of the light (that would be a nice configuration option: "light quality". lower qualities will use textures of 256x256 or 128x128)
I didnt knew that you render the whole szene for each light.
Well this will take some time... i have to create a complete renderer class, because i have to create all dynamic textures before i render the scene.
I will tell you when its finished.

Thank a lot Orangy.

[edited by - xardias on January 13, 2004 12:06:34 PM]

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!