Hi,
Your approach seems correct. But rendering all the terrain geometry in every frame may not be a good way. Because, if your terrain is big enough, it may be a performance killer :) To avoid this, I recommend you to use a partitioning technique such as "spatial partitioning". Other expert members here can describe it or you can google for it.
Quote:Where should I be adding my lighting if I go for this approach? I suppose it should be in the deferred shading class, but would it be sensible to set up a LightManager class as well, then pass the contents of the g-buffer to it?
After filling the g-buffer, lighting must be done for every "active" light in your scene as a post process (*). Then you must add the lighting results by additive alpha blending. A custom light manager class would be useful for stroing your light parameters. For example, I'm using a light manager class to add/remove lights to screen, determine light types, prepare convex light geometry, calculate light-space matrices (for projective texturing and/or shadow mapping) etc.
(*)Pass your render target textures to your deferred-shading shader. Do your lighting calculation in it and render a full-screen quad to show the results.
Quote:Finally, how do I prevent models etc. overwritting other objects if they would not be draw. Say I draw my terrain first, then all my models, what if a model is drawn behind a hill, how is this dealt with in deferred shading? Do I have to run occlusion tests for everything and order my draw calls?
It can be done by using occlusion tests. Or, early-z culling can be used (I'm not sure, experts correct me :) ).
Hope this helps.
Regards,
Rohat.
There's no "hard", and "the impossible" takes just a little time.