1

我正在使用 XNA 3.0,并且我想为具有多个 3d 对象的 3d 场景使用抗锯齿。我去了 msdn 站点并实施了 MSAA,但我仍然看到锯齿状的边缘。是因为我没有为每个对象渲染反别名吗?

这是 cos 片段:

     public Game1()
    {
        graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";
        graphics.PreferMultiSampling = true;
        graphics.PreparingDeviceSettings +=
        new EventHandler<PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings);
     }
     void graphics_PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e)
     {
        int quality = 0;
        GraphicsAdapter adapter = e.GraphicsDeviceInformation.Adapter;
        SurfaceFormat format = adapter.CurrentDisplayMode.Format;
        // Check for 4xAA
        if (adapter.CheckDeviceMultiSampleType(DeviceType.Hardware, format,
            false, MultiSampleType.FourSamples, out quality))
        {
            // even if a greater quality is returned, we only want quality 0
            e.GraphicsDeviceInformation.PresentationParameters.MultiSampleQuality = 0;
            e.GraphicsDeviceInformation.PresentationParameters.MultiSampleType =
            MultiSampleType.FourSamples;
        }
        // Check for 2xAA
        else if (adapter.CheckDeviceMultiSampleType(DeviceType.Hardware, format,
                 false, MultiSampleType.TwoSamples, out quality))
        {
           // even if a greater quality is returned, we only want quality 0
          e.GraphicsDeviceInformation.PresentationParameters.MultiSampleQuality = 0;
          e.GraphicsDeviceInformation.PresentationParameters.MultiSampleType =
             MultiSampleType.TwoSamples;
       }
       return;
     }
4

0 回答 0