OpenGLContext.passes.renderpass

Default rendering-algorithm implementation
This module provides the default rendering algorithm implementation, including the opaque, transparent and selection rendering-passes. The classes here are also used as the base classes for the shadow/passes.py module which implements the shadow-casting rendering algorithm.

Classes

Opaque geometry rendering through scenegraph visitation
The opaque rendering passes is the most "normal" of the rendering passes. It basically just uses the RenderVisitor implementation to render the scenegraph or Context.
The OpaqueRenderPass uses the context's shouldRedraw and suppressRedraw methods to determine whether or not to render itself, (and to let the context know that it has rendered). This is not ideologically pure, as potentially there could be another rendering pass responsible for "visible" rendering. It is, however, practical for now.
Note: The OpaqueRenderPass registers objects for the TransparentRenderPass, so the TransparentRenderPass cannot operate without a preceding OpaqueRenderPass.
Representation of an overall rendering pass
The OverallPass object represents a collection of sub-passes which, together, are considered a full rendering cycle. The OverallPass stores information about the entire rendering cycle, with the attributes of the OverallPass available to each sub-pass (and thereby to rendering code).
Attributes: context -- reference to the client Context object into which this pass is being rendered
lightPaths, viewPaths, backgroundPaths, fogPaths -- nodepath objects for each active object of the given node-types found during the initial "findBindables" "rendering" pass which is run before any of the regular render-passes. See: findBindables RenderVisitor.SceneGraphLights RenderVisitor.SceneGraphBackground
transparentObjects
sequence of transparent object records registered (normally by OpaqueRenderPass) for processing (normally by TransparentRenderPass). See: addTransparent() getTransparent()
## Note: the following are not considered particularly useful # and may disappear at some point in time startTime -- the startTime value passed to the initializer, or the value of time.time() during initialization if there was no value viewport -- glGetIntegerv( GL_VIEWPORT ) -> (x,y, width, height) projection -- glGetDoublev( GL_PROJECTION_MATRIX ) -> 4x4 float matrix modelView -- glGetDoublev( GL_MODELVIEW_MATRIX ) -> 4x4 float matrix
Callable list of sub-passes with associated OverallPass
The PassSet is called once per render-cycle, and is responsible for creating the OverallPass which does the actual rendering. It simply creates the OverallPass with the given sub-passes and calls the OverallPass, returning the result.
A particular pass of a particular rendering mode
Most RenderPass instances are actually VisitingRenderPass instances, with the notable exception of TransparentRenderPass objects.
Attributes (normally class-static): transform -- whether to do transforms, most do
visible
whether there is any visible change to the buffer (use textures, colours, etceteras)
transparent
whether is a transparent-rendering pass
selectNames
whether should push/pop selection "names"
selectForced
whether we are currently in forced- selection mode
stencil
whether we are rendering into the stencil buffer
lighting
lighting is being used (most opaque/ transparent, but not selection)
lightingAmbient
whether ambient lighting should be used
lightingDiffuse
whether diffuse lighting should be used (non-ambient)
Note: The RenderPass will look up any missing attributes in the OverallPass object, so effectively the RenderPass has all of the attributes of the OverallPass which is passed to the initializer.
Note: This class is a consolidation of the RenderPass and RenderMode classes in OpenGLContext version 1.0
glSelectBuffer-based selection rendering mode
This is an implementation of glSelectBuffer-based selection modes. It allows for projecting multiple "pick" events into the scenegraph. The implementation tries to be as general as possible.
The RenderVisitor.Grouping method takes care of calling the Grouping nodes' pushName method to generate the name stack which is reported by the SelectRenderPass.
See: OpenGLContext.events.mouseevents OpenGLContext.context.getPickEvents OpenGLContext.context.addPickEvent
Note: Each pick event causes a complete render-traversal, which, if there are a lot of pick-events, can dramatically slowdown your frame rate! There should be some logic to try to minimize these events, but I haven't come up with a generalized solution to the problem.
Note: Pick events are registered and accessed from the Context object. The SelectRenderPass can deal (and it does deal only in the current implementation) with events which were generated/registered either by a previous render-pass, or between rendering passes.
Attributes: bufferSize -- the size of the Name buffer used to store the name-stack which will be reported. The default value, 512, is somewhat wasteful but does allow for fairly deep scenegraph's. matrixSize -- the pixel-size dimensions of the pick matrix (default is 2,2) used pickPoint -- stores the current pick-point for the selection rendering pass. selectable -- mapping from "name" (OpenGL integer name) to selectable Node (an opaque object reference) used to provide easy access to the list of selected nodes. See: addSelectable()
Blend-based transparent/translucent geometry rendering
This is an implementation of transparent geometry rendering which, although not rigorously generalized, should provide basic functionality.
XXX What is wrong with the implementation?
Properly done, a transparent-rendering algorithm should sort all polygons of all transparent objects together with each vertex of each polygon projected, and any intersecting polygons tesselated to form polygons which are unambiguously in front of or behind every other polygon.
I haven't implemented that algorithm, mostly because it is a great deal of work for a fairly minimal payback given relatively infrequent occurrence of intersecting transparent geometry.
There is a further problem when doing stencil-shadow rendering, in that the multi-pass rendering does not have proper depth information. I haven't come across a decent explanation of how to implement support for this, so I haven't done so.