At the moment I am trying to create a tech demo in directX 9. I have a good understanding of basic lighting but, in my game/demo, I want to be able to create and light a scene like the following:

enter image description here

Could someone please help me and point me in the direction of a good base light class, or where I could learn how to implement one myself?

  • \$\begingroup\$ It's from UDK showcase (unrealengine.com/en/showcase/udk/samaritan) with DirectX 11 specific Deferred Lighting. Will be hard time achieving it with DX9... \$\endgroup\$ Jul 3, 2012 at 20:27
  • \$\begingroup\$ I know. Just wanted a sample picture of the type of thing I'm after mate. Easier to show a picture :) \$\endgroup\$
    – N0xus
    Jul 3, 2012 at 20:31
  • 1
    \$\begingroup\$ As I said, hard time achieving with DX9. Try googling DX9 Deferred Shading / Rendering. \$\endgroup\$ Jul 3, 2012 at 20:36

2 Answers 2


That tech demo uses deferred rendering, it might be hard to get exactly that quality but it is perfectly possible to write a deferred renderer for DirectX9.

The idea behind deferred rendering is that you trade video memory for speed of calculating lighting. You create multiple render targets (using MRT) one for the lighting, one for the diffuse + specular intensity, one for the normals + specular power. Light calculations needed for adding a new light are performed on the data from the render targets (mainly from normals and depth data in there) so drawing an extra light means you don't have to draw the geometry an extra time. This way a scene with a dozen or even a hundreds of lights is possible, as opposite to a normal forward renderer where you have to draw all the geometry for each light, which quickly becomes costly.

Unfortunately computing shadows is still expensive but good designers have noticed that it's not necessary at all for all lights to cast a shadow to get a realistic scene.

An excellent example of this technique is the game S.T.A.L.K.E.R, and lucky for you they did a few articles on their implementation of the technique which are available for free at nVidia's developer pages.

Another similar technique is called light pre-pass of which some excellent slides by Wolfgang Engel are available here

Now as for some tutorials to point you at, I don't know of any specific C++/DirectX 9 one's, but to show it's possible this is a tutorial for deferred rendering in XNA, which uses only techniques available in DirectX 9 (XNA can't do any DirectX 10+ stuff since it has to run on the Xbox 360 as well)


Achieving the quality of lighting in the screenshot you provided and takes a team of programmers and a small army of artists. You're better off using an existing engine (like the Unreal Development Kit or CryEngine) which has the lighting you want.

However, if you want to do it yourself, I'd suggest taking a look at this presentation: Rendering Tech of Space Marine. It goes to great lengths to explain the techniques used in their DirectX 9 deferred renderer. It should either give you a starting point or let you realize that you've bitten off more than you can chew.

Keep in mind that it took them close to 6 years to develop Space Marine from scratch on Xbox 360 and PC.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .