Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I recently managed to get some lights rendered in a scene by using a buffer and a for-loop. The problem with this method is the performance drop if more lights are used. I tried to convert Deferred Rendering in XNA4.0 | ROY-T.NL but it is not working, because I am not using any models. I know I have to render color, normals and lights seperate but I don't know how I could get it working.

For understanding my structure better I'm using a world-class which holds some chunks. These chunks are loading all vertices from their items. These items have a property which returns the vertices. The item is returning VertexPositionNormalTexture[].

The chunk loads these Vertices and combines them to one large array of VertexPositionNormalTexture via someList.AsParallel().SelectMany(m => m).ToArray()). m is a VertexPositionNormalTexture. someList is List<VertexPositionNormalTexture>.

I got my own shader to draw these vertices how I want them to be drawn. The first thing I would try is setting up two RenderTarget2D for rendering the color and normal part. With two different shaders.

Than I would have to render the lights and there's the problem: I don't know how. I set up a structure to simplify working with lights but it didn't really help.

public struct Light {
    public Vector3 Position;
    public Color4 Color;
    public float Range;
    public float Intensity;

    public Light( Vector3 position, Color color, float range, float intensity )
        : this() {
        this.Position = position;
        this.Color = color;
        this.Range = range;
        this.Intensity = intensity;

    public float[] Definition {
        get {
            return new[] { Position.X, Position.Y, Position.Z, Color.Red, Color.Green, Color.Blue, Intensity, Range };

The next part is equally different because I don't know how to combine the colorMap, normalMap and textureMap to one finalMap.

Some information to the system: I'm using SharpDX (Nightly from some months ago) and the SharpDX.Toolkit (I don't want to mess up with Direct3DDevice and similar things).

Can someone help me with this problem? If things are missing or I provided insufficient information tell me, I need to get deferred shading working. Things I'm not able to do: create a rendertarget which holds all lights, merge colorMap, normalMap and lightMap to one finalMap and presenting this to the user.

share|improve this question
This is far from a trivial problem. The link you provided took me to a page providing a good explanation of deferred rendering, and one method to implement it. Not a quick and easy process. catalinzima.com/tutorials/deferred-rendering-in-xna –  Evan Jun 24 '13 at 22:09
I implemented a deferred shader in SharpDX using the linked tutorial - it contained all the information I needed. Is there some specific problem that you are having when following the tutorials? Perhaps try debugging the pipeline using the graphics debugger in Visual Studio - I couldn't have written my deferred shader without it - msdn.microsoft.com/en-us/library/vstudio/hh873207.aspx –  gareththegeek Jun 25 '13 at 9:32
okay .. working on the tutorial. One question: Am I forced to use the quadRenderer or can I use GraphicsDevice.DrawQuad() instead? –  AliveDevil Jun 25 '13 at 11:50
this tutorial is not helping me, because I don't have any idea what I should to get this working. I'm not using models but VertesPositionNormalTexure which leads to many problems. Than I have to use GraphicsDevice.SetRenderTargets(GraphicsDevice.BackBuffer) and GraphicsDevice.DrawQuad(Effect effect) instead of GraphicsDevice.ResetTargets() and QuadRenderer.Render(). They're defining a shader calls RenderGBuffer..but it's never used. Anyone who is able to tell me how I can use these shader for custom vertices (without models)? –  AliveDevil Jun 25 '13 at 17:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.