Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have done multi pass rendering before and understand how it works. I did a simple example which rendered a basic scene with shadows. This was all done in one file. Now I am trying to figure out is how to put it into my game engine.

Currently my game engine is single pass. It is in a hierarchical structure and uses Direct3D9. I have a graphics component which will load and draw a 3d model. In my game loop I update all the entities in the world then I call the draw function for each one. This draw function gets the vertex buffer, index buffer and texture/ material and draws the 3d model using a shader. This is fine.

To do multi pass rendering to allow for shadows say I will need to draw each model multiple times. It doesn't seem right to me that in each models draw function I should put the 2nd pass code as this will then be completed before the next models 1st pass. Does anyone know of any design solutions or places where I can find some more information about this?

I hope this question isn't too confusing, I have tried to explain what I currently have and what I would like to achieve to the best of my ability.



share|improve this question
up vote 5 down vote accepted

The entities should not be responsible for drawing themselves. They (or just their renderable components) should be passed to the rendering engine and the rendering engine should have the responsibility of rendering them.

share|improve this answer
This makes sense. Thank you. – MulletDevil Jul 29 '11 at 13:43

With your current structure you'll need a second API for your models to handle the shadow pass.

If you wanted to invert some of your logic then let the models store their data and a friendly description of how they want to be rendered, and let the graphics engine pull data from the models to render according to those descriptions. This will let the graphics code handle the shadows (or post processing FX, etc...) in its own way with the second pass.

share|improve this answer

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.