Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

Regards,

MD.

share|improve this question

2 Answers 2

up vote 4 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

 
discard

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.