Web Analytics Made Easy - Statcounter
Skip to content

Rendering#

SAMSON uses an internal OpenGL renderer to display the data graph.

As an extension developer, you usually interact with the renderer by implementing display-style functions in your classes. The most common case is a visual model derived from SBMVisualModel, but editors and other node types may also contribute to what appears in the viewport.

If your geometry should be selectable, you also need to think about selection rendering, not just visual rendering.

The practical responsibilities of an extension#

When you add custom rendered content, there are usually three questions to answer:

  • how should it look in the main viewport
  • how should it behave during picking and selection
  • does it need 2D editor overlays or helper visuals

Those map to different rendering stages and functions in SAMSON.

Viewport

See

See User guide: Rendering effects and User guide: Visualizing for more information on SAMSON's rendering possibilities and settings.

The rendering pipeline#

SAMSON renders each frame using the following pipeline:

  • Shadow computations: the data graph and active editor are rendered for shadow generation.
  • Data graph rendering: the document content is rendered. Only structural models have a default visual representation. For many other node types, SAMSON calls the nodes' display functions.
  • Editor rendering: the active editor can draw temporary 3D helper geometry used during interaction.
  • Frame post-processing: effects such as shadows, fog, and highlighting are applied.
  • Editor interface rendering: the active editor can draw a 2D overlay interface.

Rectangle selection editor

This separation is important because not all visuals belong in the same stage. A persistent representation belongs in a model display function; a temporary interaction aid often belongs in an editor display or displayInterface.

Shadows#

SAMSON uses shadow maps to implement shadows. During the Shadow computations step, the data graph is rendered from the point of view of the first light, to generate a depth map that is used during the post-processing step to determine whether a pixel should be shadowed or not.

If you want your nodes to display shadow, then implement for the relevant node type in the display function a part for the SBNode::RenderingPass::ShadowingGeometry rendering type.

Display utility functions#

SAMSON uses, and expects extensions to use, core-profile OpenGL functionality. Legacy calls such as glBegin and glEnd are not supported in extension rendering code.

Because raw core-profile OpenGL can be cumbersome, SAMSON provides utility functions for common batched drawing tasks. These are especially helpful when implementing display functions for data graph nodes.

For example, api/classSAMSON.md#function-displaytriangles can be used to draw triangles in a viewport.

These helpers are also important for selection rendering because the picking pipeline needs a selectable representation, not just a visually pleasing one.

Selection rendering#

The renderer is also used for picking. If you add custom selectable geometry to the data graph, implement for the relevant node type in the display function a part for the SBNode::RenderingPass::SelectableGeometry rendering type.

That function should render the selectable representation in a way that matches how users expect picking to work.

Practical guidance#

  • Put persistent scene representation in model or node display functions.
  • Put temporary interaction visuals in editor rendering functions.
  • Implement selection rendering explicitly when your custom geometry must be pickable.
  • Use SAMSON display utilities instead of unsupported legacy OpenGL patterns.

Please refer to the documentation of the SAMSON interface for information about each display function.