Search code examples
silverlight3dxnaantialiasing

Poor anti aliasing of 3D model using XNA in Silverlight, how to fix?


In Silverlight, I am embedding a 3D model using XNA. The model is rendered in a DrawingSurface control. The issue I am having is that the model render is quite poor in quality. The model has jagged edges even with anti aliasing turned on (see code below), and the model is also blurry.

Dim comp As New OffscreenCompositionMode
    comp.PreferredMultiSampleCount = 4
    comp.RenderTargetUsage = RenderTargetUsage.DiscardContents
    comp.PreferredDepthStencilFormat = DepthFormat.Depth24

    drawingSurfaceCtl.CompositionMode = comp

I tried adjusting the multiSampleCount, camera position, lens and etc but to no effect. Does anyone have any suggestions on how to improve Anti Aliasing?

Also note that this is designed as an out of browser app on pc, and the xna game library cannot be used in this solution.

Thanks


Solution

  • I found the solution accidentally, the DrawingSurface control was embedded within a canvas, which in turn was embedded within a Grid. The canvas had a height and width specified which was larger than the grid row which also had a height and width specified.

    So correcting the canvas height and width, and also setting a height and width to the DrawingSurface control instantly fixed the issue.

    Note that I also tried various sizes for the DrawingSurface and found that a size roughly 2x the size of the canvas it was embedded in gave the best resolution.

    Hope this helps anyone who has this bizarre issue!