XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

[2.0] Postprocessing and Multisampling

Last post 12/18/2007 5:34 AM by PelleAtor. 3 replies.
  • 12/13/2007 7:48 PM

    [2.0] Postprocessing and Multisampling

    Hi,

    I'm having some problems getting postprocessing and multisampling to work together :(

    I'm using the BloomPostProcess sample as a base but when I turn on multisampling I get this exception:

    InvalidOperationException
    The active render target and depth stencil surface must have the same pixel size and multisampling type.

    In 2.0 beta I solved this by changing the initialisation of the rendertargets (BloomComponent.LoadContent) to take the backbuffer multisample settings into account:

    renderTarget1 = new RenderTarget2D(GraphicsDevice, width, height, 1, 
    format, pp.MultiSampleType, pp.MultiSampleQuality);
    renderTarget2 = new RenderTarget2D(GraphicsDevice, width, height, 1,
    format, pp.MultiSampleType, pp.MultiSampleQuality);

    However in 2.0 final I still get the exception :( In 1.0 everything just worked.

    I turn multisampling on by adding the following to Game.cs:
    protected override void Initialize()
    {
    MultiSampleType multiSampleType = MultiSampleType.FourSamples;
    GraphicsDevice.PresentationParameters.MultiSampleType = multiSampleType;
    int qualityLevels;
    GraphicsAdapter.DefaultAdapter.CheckDeviceMultiSampleType(DeviceType.Hardware,
    graphics.GraphicsDevice.DisplayMode.Format,
    false, multiSampleType, out qualityLevels);
    GraphicsDevice.PresentationParameters.MultiSampleQuality = qualityLevels - 1;

    graphics.ApplyChanges();
    base.Initialize();
    }

    Any ideas? Should think that multisampling and postprocessing should be possible at the same time.

     -Pelle
  • 12/17/2007 5:57 PM In reply to

    Re: [2.0] Postprocessing and Multisampling

    Hi again,

    I think I finally solved this by adding this call right after the call to graphics.ApplyChanges:
    GraphicsDevice.Reset(GraphicsDevice.PresentationParameters);

    This seems to recreate the DepthStencil with the required settings for everything to work :)


     -Pelle
  • 12/17/2007 6:10 PM In reply to

    Re: [2.0] Postprocessing and Multisampling

    Intercept the graphics.PreparingDeviceSettings event of the GraphicsDeviceManager and use e.PresentationParameters.xxxxx to modify the various things you're currently changing in Initialise. Initialise isn't the place for changing GraphicsDevice settings as should the graphics device get lost and need to be recreated for any reason, it won't call Initialise again.
  • 12/18/2007 5:34 AM In reply to

    Re: [2.0] Postprocessing and Multisampling

    Thanks :)

    Found the sample in the help for GraphicsDeviceManager.PreparingDeviceSettings event ... works like a charm.

     -Pelle
Page 1 of 1 (4 items) Previous Next