XNA 4.0在具有锯齿状边缘的问题...知道高品质的输出的方法的一个窗口? [英] XNA 4.0 in a window having jagged edges issues...Know of a method for high quality output?

查看:196
本文介绍了XNA 4.0在具有锯齿状边缘的问题...知道高品质的输出的方法的一个窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个例子项目的XNA 4.0表单控件在我写的应用程序: http://creators.xna.com/en-US/sample/winforms_series1

I'm using this example project's XNA 4.0 form control in an application I'm writing: http://creators.xna.com/en-US/sample/winforms_series1

它的工作很好,我已经做了相当多的具有视觉效果和动画。主要的问题我抓我的头,在为3D模型和原始3D形状(气瓶30曲面细分)我使有非常锯齿状边缘给他们,如果他们是分辨率低。

It's working great and I've done quite a bit with visuals and animation. The main issue I'm scratching my head at is the 3d model and primitive 3D shapes (cylinders with a tessellation of 30) I render have very jagged edges to them as if they are low resolution.

我试图找出如何启用多重采样,但所有的例子我可以在网上找到似乎并不适用于这本小说在自定义表单控件使用XNA的方式。

I tried to figure out how to enable multisampling, but all of the examples I can find online don't seem to apply to this novel way of using XNA in the custom form control.

在GraphicsDeviceService()构造函数有对象创建psentationParameters一个$ P $,但唯一可用的属性是整型的parameters.MultiSampleCount。我尝试设置与没有效果。

Inside the GraphicsDeviceService() constructor there is a PresentationParameters object created, but the only property available is parameters.MultiSampleCount of type integer. I tried setting that with no effect.

我也试图让后面的缓冲两倍的控件的大小(GraphicsDeviceService.cs):


    GraphicsDeviceService(IntPtr windowHandle, int width, int height)
    {
        parameters.BackBufferWidth = width * 2;
        parameters.BackBufferHeight = height * 2;
        ...
    }

然后,我改变了这一功能(GraphicsDeviceControl.cs):



    void EndDraw()
    {
        Rectangle sourceRectangle = new Rectangle(0, 0, ClientSize.Width * 2, ClientSize.Height * 2);
        Rectangle destinationRectangle = new Rectangle(0, 0, ClientSize.Width, ClientSize.Height);
        GraphicsDevice.Present(sourceRectangle, destinationRectangle, this.Handle);
    }

但是,这并不能正常工作。我的渲染到屏幕上的物体被转移到窗口的1/4和修剪。它看上去的确稍显不足参差不齐,但...

But that didn't work properly. My objects rendered to the screen were relegated to 1/4th of the window and clipped. It did look slightly less jagged though...

所以,在这一点上我不知道我能做些什么来获得使用此方法(在窗口XNA控制)高品质的图形。我一般pretty的新的XNA,所以任何建议将是最有帮助的。

So at this point I'm not sure what I can do to get high quality graphics using this method (XNA control in a window). I'm pretty new to XNA in general, so any suggestions would be most helpful.

感谢

推荐答案

我下载了code样品,看看那里的presentationParameters人们正在搭建。这些都是你需要修改。

I downloaded that code sample to see where the PresentationParameters were being set up. These are what you need to modify.

这是在GraphicsDeviceService类。

It's in the GraphicsDeviceService class.

在这个类的构造函数,它是建立所谓的参数的对象,一个presentationParamters对象。

In the constructor of this class, it is setting up an object called "parameters", a PresentationParamters object. Add this line after the new and before passing the parameters to the graphicsDevice:

parameters.MultiSampleCount = 10;

这价值我任意选择。它提供了一个健康的抗锯齿。了解更多关于抗锯齿,如果你需要了解这个数字究竟是。它的道次的通过去假频滤波器的数目。所以,你可能要降低它获得更好的性能,或提高其更多的抗锯齿。

That value I picked arbitrarily. It provides a healthy antialiasing. Read more about antialiasing if you need to understand what this number exactly is. It's the number of passes through the antialias filter. So you may want to lower it for better performance, or raise it for more antialiasing.

这篇关于XNA 4.0在具有锯齿状边缘的问题...知道高品质的输出的方法的一个窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆