RenderToBitmap Quality
I am having trouble creating high quality images using the renderToBitmap function.

The images created do not appear to draw the entire object before the bitmap is rendered. Also it appears that items behind are being displayed in front of others.

Increasing the quality of the image via the dpi or size makes this effect worse.

Ive attached an image of the render and an screenshot from the actual application to compare.

Any suggestions on how to improve this?

Attached Files Thumbnail(s)
It looks like you are having a z-fighting issues.

The z-fighting happens because the z-buffer that is used to store depth information has a limited precision - probably a 24 bit float values. Each rendered pixel in the scene gets its own depth value - distance of the pixel on the 3D object to the camera. The depth values are used to determine which object is in front of other objects (from the camera's perspective) - if a rendered pixel has a bigger depth value that the current depth value for a pixel at the same position, the pixel is discarder; if the value is smaller, then the newly rendered pixel color is used instead of the previous color at that position.

The calculated depth values are determined by the actual object distance from the camera and also from the camera's NearPlaneDistance and FarPlaneDistance. NearPlaneDistance defines at which distance from the camera the objects are clipped because they are too close to the camera. The FarPlaneDistance does the clipping of the objects that are farther away from camera then the FarPlaneDistance.

If the difference between the FarPlaneDistance and NearPlaneDistance is bigger, then the resolution of the depth buffer is decreased. What is more, with PerspectiveCamera (not OrthographicCamera), the depth resolution is much better for objects that are closer to NearPlaneDistance (from the camera's perspective) then for the objects that are farther away from the Camera.

This means that to get better depth resolution, it is desired to have the values of NearPlaneDistance and FarPlaneDistance as close together as possible.

In WPF the default value for NearPlaneDistance is 0.125. The default value for FarPlaneDistance is PositiveInfinity - this means that the actually used FarPlaneDistance is calculated from the size of the objects in the scene.

This means that to solve your problems you can do any of the following two things:
1) Manually set the NearPlaneDistance and FarPlaneDistance to some good values - increasing the NearPlaneDistance will have the biggest impact on resolution. You can check which value is the best by zooming into an object and checking when the clipping occurs.

2) Decrease the size of the whole scene (in your case the wiregrid) - this will decrease the auto-generated FarPlaneDistance.

I hope that this will help solve your problems. If not, please try to create a simple sample project with your problem and send it with Feedback form ( so that I can check what is the problem.

For those who would like to know how this is handled in Ab3d.DXEngine:
The Ab3d.DXEngine uses a 32 bit depth buffer - better resolution then for WPF. Also by default the engine calculates the optimal NearPlaneDistance and FarPlaneDistance so that the depth resolution is as good as possible. It is possible to disable automatic calculation by setting OptimizeNearAndFarCameraPlanes properties on DXScene to false.
Andrej Benedik

Forum Jump:

Users browsing this thread:
1 Guest(s)