John Ruf
John Ruf

Reputation: 275

Design patterns for lighting in XNA 4.0 for Xbox 360?

I am wondering if anyone has any good patterns for handling lighting in XNA for the Xbox 360. I am currently trying to implement a spotlight component. I have read about deferred shading as a means of reducing complexity. I have also heard that this is not a good idea for the Xbox 360 and that it is more difficult in XNA 4.0 than it was in XNA 3.0. My goal is to make a reusable component that encapsulates a spotlight effect that can be used through a game.

Thanks,

-John

Upvotes: 2

Views: 402

Answers (1)

Eclectus
Eclectus

Reputation: 306

Deferred Rendering allows you to apply lighting after the world itself has been rendered.

  • It does reduce complexity in the sense that you are not forced to choose which lights will affect a model before drawing it (usually the closest/most significant ones).

  • It can make translucency handling and anti-aliasing more complex.

  • It allows for many lights to be applied, and move around the scene, something that is impractical with forward lighting.

  • It requires several buffers to be present - a geometry buffer as a minimum, but normal and specular buffers are helpful also. Techniques exist to pack such buffers, but they do require more memory, and use bandwidth to write to. This means that deferred rendering has a greater up front cost then forward rendering does, but provides more flexibility in relation to the amount of lights, and moving them.

  • Starcraft 2, Gears of War and other games use a deferred renderer, so its certainly a proven solution.

  • It is not very different in terms of complexity under XNA 4 here is a link showing an implementation under XNA 4. The main difference if having to explicitely store a copy of the z buffer rather than accessing it directly. http://roy-t.nl/index.php/tag/deferred-rendering/ and you could consider light pre-pass also http://jcoluna.wordpress.com/

Since you want a spotlight effect I can see why you'd consider deferred rendering, as I'm guessing that the spotlight is dynamic. However if you haven't used deferred rendering before, I'd suggest exploring Roy's link above to decide if your happy with the cost/complexity.

Upvotes: 1

Related Questions