Deferred rendering with both Clockwise and CounterClockwise culling
Posted
by
user1423893
on Game Development
See other posts from Game Development
or by user1423893
Published on 2012-07-09T22:59:27Z
Indexed on
2012/07/10
3:23 UTC
Read the original article
Hit count: 346
I have a deferred rendering system that works well with objects that appear solid and drawn using CounterClockwise culling.
I have a problem with Clockwise culled objects that are supposed to represent hollow that display their inside faces only.
The image below shows a CounterClockwise culled object (left) Clockwise culled object (right).
The Clockwise culled object faces display what would be displayed on the CounterClockwise face. How can I get the lighting to light the inner faces for Clockwise culled objects and continue lighting the outer CounterClockwise faces as normal?
My lighting method is below
private void DeferredLighting(GameTime gameTime)
{
// Set the render target for the lights
game.GraphicsDevice.SetRenderTarget(lightMap);
// Clear the render target to (0, 0, 0, 0)
game.GraphicsDevice.Clear(Color.Transparent);
// Set the render states
game.GraphicsDevice.BlendState = BlendState.Additive;
game.GraphicsDevice.DepthStencilState = DepthStencilState.None;
game.GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
// Set sampler state to Point as the Surface type requires it in XNA 4.0
game.GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
// Set the camera properties for all lights
BaseLight.SetCameraProperties(game.ActiveCamera);
// Draw the lights
int numLights = lights.Count;
for (int i = 0; i < numLights; ++i)
{
if (lights[i].Diffuse.W > 0f)
{
lights[i].Render(gameTime, ref normalMap, ref depthMap, ref sgrMap);
}
}
// Resolve the render target
game.GraphicsDevice.SetRenderTarget(null);
}
I have tried adjusting the render states but no combination works for both objects.
© Game Development or respective owner