Deferred Rendering

This article covers implementing a deferred renderer in XNA Game Studio 2.0. This was originally posted on Ziggyware, and can still be found here.

The tutorial is divided in the following chapters:

You can find an implementation of this tutorial in XNA Game Studio 4.0 on Roy Triesscheijn’s Blog.

  • NAM
    #1 written by NAM 2 years ago

    hi,
    before i begin, I can’t English well.

    I have tried to make my game using the defferred rendering which you wrote.

    and, i met the troble.
    when i try to make RenderTarget2D on full screen or windows mode.

    like this.

    renderTarget = new RenderTarget2D(
    Framework.Device,
    texWidth, texHeight, 1,
    SurfaceFormat.HalfVector4, MultiSampleType.FourSamples, 0, RenderTargetUsage.PlatformContents);

    but I just heard the error message “The active render target and depth stencil surface must have the same pixel size and multisampling type.”

    i know it is caused by ‘MultiSampleType.FourSamples’

    Can’t i use MultiSampleType??

  • Catalin Zima
    #2 written by Catalin Zima 2 years ago

    No, you can’t use Multisampling with Deferred rendering

  • NAM
    #3 written by NAM 2 years ago

    Thank you~ ^^

  • Dark!
    #4 written by Dark! 2 years ago

    Hey Catalin I’m trying to work deferred shading into my program but for some reason (btw, I’m just using the same g-buffer setup) after I set the render targets, clear them using the ziggyware renderer, and draw my object; I immediately “resolve” them to null and I save the GetTexture()’s to pngs so I can see if they’re rendering correctly. But, they are always blank, which I don’t understand. I even rendered my object with basic effect to make sure my world/view/proj matrices were setup correctly, then switched over to deferred rendering and I always get a black screen and all the render targets are blank (well the depth buffer turns out white, and the color and normal turn out opaque black). It just feels like i’ve been running through my code a hundred times and don’t see the issue…

    Any help? Thanks Catalin

  • Dark!
    #5 written by Dark! 2 years ago

    Ahh! I figured out my problem (after writing a whole test application to debug sanely in) it came from one line of code:

    GraphicsDevice.RenderState.DepthBufferEnable = true;

    Calling that line of code seems to cause the frame to draw blank for the first frame (then everything would turn back to normal) BUT since I had spritebatch running I ran that line every frame to reset everything from spritebatch which in turn caused every frame to turn out empty.

    Thanks anyways Catalin 8) and btw amazing tutorial my friend!

  • Wiffledude
    #6 written by Wiffledude 6 months ago

    o_o All dat spam….
    Anyway, good article. I’m working on an XNA game engine, and to me seems deferred rendering is the best choice. As for the material system, it seems that my best option would be to go with material ID / lighting response lookup, right, perhaps with material ID rendered as a separate render target? Is that how games usually do it? Seems a bit strange to me, but sounds like it would work fairly well.

  • You may use these HTML tags: <a> <abbr> <acronym> <b> <blockquote> <cite> <code> <del> <em> <i> <q> <strike> <strong>

  • Comment Feed for this Post
Go to Top