Front to back render tutorial?

Started by
5 comments, last by FlyingDodo 18 years, 1 month ago
Do you know of any good tutorial about front-to-back rendering. I would prefer if it were in OpenGL but its not necessary...
My blog about personal development for studying people - www.tricktolearn.com
Advertisement
Not to sound like a dick but the OpenGL website is a great place to learn OpenGL. There are also several OpenGL books avaliable that are very in-depth. Older versions of the books are avaliable on the OpenGL website I believe.
By 'front-to-back rendering' do you just mean sorting solid objects by their depth and rendering them front-to-back in order to try and get maximum efficiency from the Z-buffer?

It basically means you end up filling in the closest depth buffer values first and so anything else behind it will get an 'early out' due to the depth test (does depend on the graphics card though). It's the same theory as having a Z-only pre-pass (you render all your geometry with colour writes turned off so its stupidly quick and fills in the Z-buffer, then you render as normal and most of your pixels will early out saving fillrate)

HTHs

Paul
The obvious example of rendering order issue might be skybox. The skybox should be rendered AFTER any opaque geometry in order to minimize overdrawing (fillrates), before any semitransparent geometry. Therefore, the transparent object can be blended with skybox. And, it is important that the semitransparent geometry has to be drawn with opposite order, from far to near.

You can see it is necessary to have at least 3 different rendering orders: opaque -> skybox -> semitransparent.

In order to get better fillrate performance, the scene must be organized into more multiple groups as Paul mentioned.

The skybox is rendered with the depth range trick, so, the skybox is always rendered on the far clip plane.


...
glDepthRange(1,1); // depth value for skybox
drawSkybox();
...

==song==
Quote:The skybox should be rendered AFTER any opaque geometry


playing devils advocate :)

You can also render the skybox first with z test and z writes off....now I can't for the life of me remember which is faster on modern graphics cards.

By drawing it after you reduce the fill rate, but by drawing it first you reduce the cost of z-testing....hmmm....actually I think drawing it after like songho said is probably better now days, especially due to the fact that skydomes now can have quite complex shaders, and so the cost of the z-test is oveweighed by the savings from not running the shader.

No idea if thats the actual case though, I'm sure theres an Nvidia/ATI doc lying around....hell at the very least it's real easy to test :)

Paul
Quote:Original post by songho
You can see it is necessary to have at least 3 different rendering orders: opaque -> skybox -> semitransparent.


Oh, the thing i need it for is 2D graphics with parralax scrolling with many layers. Therefore it would be good to draw it front to back to eliminate overdrawing.
My blog about personal development for studying people - www.tricktolearn.com
I would recommend you look into bsp trees. http://www.gamedev.net/reference/articles/article657.asp

Once you have generated the tree all you need to do is check which side the camera is on each node and then recursively visit each node.

This topic is closed to new replies.

Advertisement