Deferred Shading - Toolkit
Posted
by
AliveDevil
on Game Development
See other posts from Game Development
or by AliveDevil
Published on 2013-06-24T21:11:28Z
Indexed on
2013/06/24
22:32 UTC
Read the original article
Hit count: 299
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.
© Game Development or respective owner