Jump to content
  • Advertisement
Sign in to follow this  
Mullvalen

OpenGL Front to back render tutorial?

This topic is 4588 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Do you know of any good tutorial about front-to-back rendering. I would prefer if it were in OpenGL but its not necessary...

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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==

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!