RenderToSurface has invalid ZBuffer?
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?
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.
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.
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()
enable ZENABLE and ZWRITEENABLE, disable any alpha functionality and clear the render target and zbuffer before any calls to Begin()
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...
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement