<TextureRenderer|User's Guide|Fundamental Shapes>

RenderQueue

See Javadoc

The render queue provides the means to organize scene elements prior to drawing them. In simple scenes, this is not required and can be ignored. However, it doesn't take long before proper Geometry sorting is required to prevent any rendering artifacts. For example, by default Geometry is rendered by its position in the Scene Graph. If there are transparent objects in the graph, and they are drawn before any opaque objects that are supposed to be behind it, those objects will not appear visible through the transparent object. This is where RenderQueue comes into play. RenderQueue makes use of a number of different buckets: opaque, transparent and ortho. Renderer defines the constants and to set a queue you use the method setRenderQueueMode in Spatial. For example, to place some Geometry into the transparent queue:

geom.setRenderQueueMode(Renderer.QUEUE_TRANSPARENT);

Once objects are in the queues, they are preprocessed and ordered before being drawn. The ordering is as follows:

  1. Draw the opaque objects first (front to back)1)
  2. Draw transparent objects (back to front) drawing the inside of the object.
  3. Draw transparent objects (back to front) drawing the outside of the object.
  4. Draw Ortho objects.

The order is important for the following reasons:

  • Drawing opaque first insures that any opaque objects will be visible from behind transparent objects. Drawing front to back allows OpenGL to optimize by throwing out occluded pixels.
  • Drawing transparent objects from back to front insures that all objects are visible from behind a transparent object, even other transparent objects.
  • Drawing the transparent objects twice (once rendering the inside, again the outside), allows complex objects to appear truly transparent.2)
  • Ortho objects are drawn last because these are screen oriented (UI, HUD, etc) graphics and should always be “on top” of the rest of the scene.

RenderQueue modes are inherited from a parent, so special care needs to be taken if a branch of the scene graph has different queue elements contained within it.

RenderQueue handles all processing and requires no work from the user. Sorting of the Geometry occurs dynamically as needed. The user must only set the RenderQueue mode.

<TextureRenderer|User's Guide|Fundamental Shapes>

1) front/back means the distance from the camera, front being close, back being far
2) Transparent objects can be only rendered once by calling RenderQueue.setTwoPassTransparency(false).

/var/www/wiki/data/pages/renderqueue.txt · Last modified: 2009/07/28 18:44 (external edit)  
Recent changes · Show pagesource · Login

Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki

subscribe to jME latest jme headlines


site design by bleedcrimson designs © 2008