Jump to content
  • Advertisement
Sign in to follow this  
markr

OpenGL Simple shadow rendering technique

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

A lot of concern is expressed, in these opengl forums, of the difficulty of doing offscreen rendering in opengl. Certainly, the consensus seems to be that pbuffers are difficult to use (and platform-specific - although all the major platforms HAVE them they're slightly different) - and that the easier to use ARB extension, is not very widely supported. I have an idea for drawing a shadow map: - Use the normal back buffer to create a shadow map somehow (probably only needs 1 channel) - Then call glCopyTexImage2d to copy this into a texture - Clear the back buffer and render the ground normally - Then draw the shadow map from the copied texture on to the ground with appropriate blending (or use multitexturing to draw it with the ground) This sounds like it will probably work fairly fast, and without requiring any puffers or anything. I won't have to use the whole of the back buffer if I don't want to (for example, if in really high res, only a small portion of the back buffer) Mark

Share this post


Link to post
Share on other sites
Advertisement
yep, thats certainly the simplest way todo it but it does bring with it two 'issues'

1 - you cant have a shadow map which is larger than the closest power-of-two below your current screen size, which could lead to alising issues at <1024*1024

2 - Read back of the z-buffer is VERY slow on a X800 and beyond ATI based card. Currently the shadow mapping examples I have run at a glorious 4fps due to this. The problem seems to be the compression used for the z-buffer slowing down the readback. (This also effects pbuffer solutions as well and ATI dont support binding a depth buffer properly). Atm I dont have any details on when or even if a fix is forthcoming.

Share this post


Link to post
Share on other sites
This is how I do my glow/blur type effects, mainly because it works on just about everything without any extra work. The copy isn't great though, but I'm usually doing low-res stuff so thats ok for me. For other stuff, we'll just have to wait for the FBO extension to be widely reported, I've heard it actually fixes all these problems and is nice to work with.

Share this post


Link to post
Share on other sites
My plan is not to use the z buffer at all when drawing this shadow map. The z buffer will of course still be there but I won't be using it.

I also don't plan to read it back.

This is a top-down view of the map, which uses perspective but is still mostly flat(ish). I intend to use glOrtho to render the shadow map and make it slightly larger than the visible area of the ground. This will enable me to avoid effects near the edges that I don't want, and compensate for the fact that occasionally bits of the ground slightly outside the normal area might be visible (for example, if there is a cliff right near the edge of the screen.

I'm thinking about using some billboards with blurry images to draw the shadows, then only using a single channel to draw the shadows on top of the ground (or more likely, use multitexture).

I could potentially also use it as a more generic kind of decal map to throw other items on there too (tyre tracks, footprints, bomb craters), but I'm not sure whether that's a good idea.

Mark

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.

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!