Jump to content


Scene Graph Question


2 replies to this topic

#1 jirzynek

    New Member

  • Members
  • PipPip
  • 15 posts

Posted 13 February 2009 - 12:52 PM

Hi!

Right now in my engine I've implemented 2 scene graphs. One takes care of game geometry (terrains, scenes, animation, particles) and second manages 2d objects (panels, menus, generaly everything what has something common with 2D and is on top of 3d layer).

What is the best way to handle priorities in SG? For example I have a skybox and I want to draw it first (before anything else) with Depth test disabled and all other geometry with Depth test enabled. What is the best way to do this? Another sortkey?

cheers
jirzynek

ps. sorry for my language mistakes...
int i = 0;
(+ - + - + - + ++--++--++--++--++--++--++--------++++++i);

#2 .oisyn

    DevMaster Staff

  • Moderators
  • 1822 posts

Posted 13 February 2009 - 01:54 PM

Or you can alter the projection matrix so that you "allocate" the back portion of your z resolution for your skybox. Then it doesn't matter when you draw it. This also avoids overdraw when you do a z-pass of all your geometry first.
C++ addict
-
Currently working on: the 3D engine for Tomb Raider.

#3 Reedbeta

    DevMaster Staff

  • Administrators
  • 4969 posts
  • LocationBellevue, WA

Posted 13 February 2009 - 09:12 PM

In the engine I work on we have a system with several different sort keys. At the top there is a "primary key" that is set by the shader file and is one of an enumeration hard-coded into the engine. The engine binds render targets and sets a few other states based on the primary key as well. Within each primary key value we group by shader file, then by shader parameters (texture assignments etc). The list of things to render is regenerated each frame and kept sorted by this key system as things are inserted into the list, then we run through the list and draw everything.

In our case we have a special primary key values for the skybox which runs after the ones for all the opaque world geometry, but before the ones for transparent geometry. Like .oisyn suggest we use z-testing to ensure the skybox doesn't occlude the geometry (our sky is actually a screen-space quad, rather than a literal cube, and we set the vertices directly in clip space, which lets us put them exactly at the farthest possible z value).

Anyway, this kind of key system is a decent general paradigm for making sure things render in the right order.
reedbeta.com - developer blog, OpenGL demos, and other projects





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users