Jump to content
  • Advertisement
Sign in to follow this  
shaKu_shawn

RenderToSurface has invalid ZBuffer?

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

I setup my device then I setup my rendering Surface and RenderToSurface object like so.. RtsHelper = new RenderToSurface(m_device, c_scene_width, c_scene_height, Format.X8R8G8B8, true, DepthFormat.D16); renderSurface = m_device.CreateRenderTarget(c_scene_width, c_scene_height, Format.X8R8G8B8, MultiSampleType.NonMaskable, 2, false); now if I use my device to render to the form it looks great no bad z effects at all. But when I use the RenderToSurface object to render to the surface I have some glitches where I can see the vertices in the back... one other thing that I noticed is that if I use a Texture instead of a Surface and use Texture.GetSurfaceLevel(0) to get the surface when needed it renders just fine and it appears to not have any Z issues but you can't use multisampling this way and it is very slow! My main question is... do I need to setup the ZBuffer or DepthStencil on the surface specifically?

Share this post


Link to post
Share on other sites
Advertisement
Ok here is what I am getting when usin the RenderToSurface (implemented in variable RtsHelper) to render the scene. If I replace the RtsHelper.BeginScene() and RtsHelper.EndScene() method calls and use the Device.BeginScene() and EndScene() method calls it works perfect to render to the form with none of these ZBuffer problems! But I need to render directly to a surface or texture!

Rendering to a texture does not support multisampling so all I have left is to render to a surface! Below is an image rendered with the ZBuffer problem clearly shown on both the top and bottom.

Share this post


Link to post
Share on other sites
Just a shot in the dark:

enable ZENABLE and ZWRITEENABLE, disable any alpha functionality and clear the render target and zbuffer before any calls to Begin()

Share this post


Link to post
Share on other sites
thanks for the reply fox... ya I have ZBuffer and ZBufferWrite both enable... I call Clear to clear the render target and the zbuffer at the beginning of each draw cycle.. i am really stumped on this one. As I said before if I go away from using the RenderToSurface object and render directly to the form not changing any of the device settings or anything just switching it from using the RenderToSurface.BeginScene/EndScene methods to using the Device's methods it works fine...

Share this post


Link to post
Share on other sites
With your RTS helper object you told it to use a 16-bit depth buffer. Are you using a 16-bit depth buffer in your regular swap chain? If not, then chances are that you're seeing the artifacts due to precision issues with respect to the precision of the depth buffer and the position of your front and back planes. Try moving your front and back planes as close as possible together to maximize the amount of precision in the depth buffer utilized by your scene.

Share this post


Link to post
Share on other sites
I was using the same depth format all the way around... I found a way to do waht I was trying to do without using the RenderToSurface object which fixed all of my ZBuffer problems and all is going good. Thanks for your replies!

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!