Jump to content
  • Advertisement
Sign in to follow this  
Chojun

D3D: Stencil Buffer Initialization

This topic is 3801 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 all, Currently I'm part of a group that is doing development on a commercial, open-source game that is about 10 years old (it was released 1999 and open-sourced late 2004). The game uses the DirectX 6 API (DirectX 7 SDK using DX6 Interfaces... I can't find the DirectX 6 SDK anywhere). I'm trying to add shadow volumes to the game, but have run into a problem in doing so. All of the stencil operations, geometry, and render-state changes are in place, and I know that the stencil buffer is working because when I disable writing to the stencil buffer, the shadow volumes show up on the screen. The shadow quad is being drawn correctly and I have the correct blending ops setup. However, the shadows don't show up. It uses a double-buffered display, where it renders to the back buffer and then blt's the image to the front buffer at display time. The game also uses a Z-Buffer. It does this by grabbing a copy of the back Buffer created at initialization time (when it creates the window), passing a copy to the renderer, creating the Z-Buffer, and then attaching it to the back buffer. This leads me to my question. I looked all over the DX 7 Documentation and couldn't find an answer. Of course, the Stencil Buffer is created at the same time the Z-Buffer is created (they work in conjunction) but it is only attached to the back buffer, and not the front buffer. Does the front buffer also need a Z/Stencil Buffer in order for the Shadow Volume effect to work?

Share this post


Link to post
Share on other sites
Advertisement
Would that be Homeworld? (edit: scratch that, I saw it was Warzone. Never played that game :) )

For your convenience I have packed libs, headers and docs in a rar file. The link is in a private message I have sent to you.

This is version 6.1 (no real difference), there was a reason for 6.1 but I forgot what it was. Should work though. If it doesn't I can pack version 6 for you but I think that version had some serious bugs with it, don't take my word on that though.

Hope this helps.

Btw, the link will be gone after one day and the size is around nine megabytes.

If there is any other version you need you can PM me and I'll see what I can do.
I have every version since Windows Game SDK.


[Edited by - MichaelT on July 16, 2008 8:05:54 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by Chojun
I looked all over the DX 7 Documentation and couldn't find an answer. Of course, the Stencil Buffer is created at the same time the Z-Buffer is created (they work in conjunction) but it is only attached to the back buffer, and not the front buffer. Does the front buffer also need a Z/Stencil Buffer in order for the Shadow Volume effect to work?


The zbuffer/stencil buffer are only in use when rendering/drawing. That is in association with the backbuffer. The front buffer is only needed to DISPLAY things, so there's no use to keep a different stencil for front and back. When back becomes front, the old stencil buffer becomes then associated with the new back buffer. Make sure you clear the stencil buffer after each frame.

I would guess what prevents shadows from appearing is some fault in the way you implemented the algorithm. Or some bug in runtime/driver but if you've seen stencil shadow volumes appear in other games then there's some chance problems are in your code. But without details hard to tell from here...

LeGreg

Share this post


Link to post
Share on other sites
Also a wrong culling, or wrong stencil INCR/DECR movements can give this kind of problem.

Make a way to show also the shadow volume, if needed. It works?

Share this post


Link to post
Share on other sites
Quote:
Original post by LeGreg

The zbuffer/stencil buffer are only in use when rendering/drawing. That is in association with the backbuffer. The front buffer is only needed to DISPLAY things, so there's no use to keep a different stencil for front and back. When back becomes front, the old stencil buffer becomes then associated with the new back buffer. Make sure you clear the stencil buffer after each frame.


That's kinda what I figured. So, this more-or-less answers my original question. To me this is good news, though, because bringing a stencil buffer to the front buffer in this codebase would be an absolute pain..

Quote:
I would guess what prevents shadows from appearing is some fault in the way you implemented the algorithm. Or some bug in runtime/driver but if you've seen stencil shadow volumes appear in other games then there's some chance problems are in your code. But without details hard to tell from here...

LeGreg


The rendering code for the shadow volumes works fine because if I disable the stencil buffer and alpha blending the shadow volumes show up. Same with the shadow quad. I highly doubt it is a problem with the runtime or driver, so it must then be a configuration issue in my code.

I'll post code samples when I get a chance (I've been very busy).

Oh, and for the record, MichaelT is an unstoppable force of excellence (thanks for the DX6 SDK.. I've been searching for that for FOREVER) :)

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!