ImFusion SDK 4.3
GlVolumeView Class Reference

#include <ImFusion/GL/GlVolumeView.h>

OpenGL view for 3D rendering and correct compositing of direct volume rendering and classic geometry-based GlObjects. More...

+ Inheritance diagram for GlVolumeView:

Detailed Description

OpenGL view for 3D rendering and correct compositing of direct volume rendering and classic geometry-based GlObjects.

GlVolumeView employs a GlVolumeRenderer instance for performing direct volume rendering (DVR) of 3D image data and integrating the regular render scene based on registered GlObjects. Use the Camera class to configure view matrix and projection settings in a comfortable fashion. Furthermore, the renderer offers the following extra functionality:

  • You can enable a LOD mode to reduce the DVR render resolution by a factor of 2 in each dimension to trade render quality for speed. Usually, one does this temporarily during user interaction to provide a smoother user experience.
  • GlVolumeView offers support for order-independent transparency (OIT) and will take care of setting up the OIT manager instance and blending the fragments. OIT is enabled by default if supported by the host system, see GL::OrderIndependentTransparency for more details.
  • You can enable Screen Space Ambient Occlusion (SSAO), a post-processing filter for approximating global illumination/shadowing effects.
  • You can use one of the firstHitpointLocation() functions to query to backproject a pixel/viewport coordinate to world coordinates.
  • You can request GlVolumeView to provide a GL::ObjectPicking manager instance to provide object picking functionality of rendered GlObjects that support this feature.
Note
Internally, GlVolumeView uses caching of the rendering result to avoid performing the expensive DVR ray marching step unless it's necessary, for instance when the view matrix or image data has changed. If you change scene parameters from the outside and encounter rendering artifacts due to the described caching behavior, call setDirty() to force a full re-render during the next frame.

Classes

class  PickingToken
 GlVolumeView uses tokens to handle access to object picking. The token enables picking and keeps it active until the last associated token gets destroyed. More...
 
class  RenderBufferWrapper
 Helper class to allow the injection of custom render buffers surrounding the entire render pipeline. More...
 

Public Types

enum  LodMode { LOD_OFF , LOD_ON , LOD_AUTO_VOLUME_SIZE }
 Possible settings for Level of detail (LOD) rendering. More...
 
enum class  SSAOMode { Disabled , GeometryOnly , Full }
 Enumeration of Screen Space Ambient Occlusion (SSAO) working modes. More...
 
- Public Types inherited from GlView
enum  Type { SLICE2D = 0 , SLICE3D = 1 , SPACE3D = 2 , OTHER = 3 }
 Type of the view. More...
 

Public Member Functions

 GlVolumeView (std::unique_ptr< GlVolumeRenderer > volumeRenderer=nullptr)
 
Type type () const override
 Return the type of this view.
 
bool render () override
 Render the view and if required the volume rendering.
 
bool render (const GL::ViewState &state)
 Render the view using the given state, overriding internal camera.
 
void setCamera (const Camera &camera)
 
const Cameracamera () const
 
void setMatrix (const mat4 &m) override
 Set view matrix from OpenGL camera to world coordinate system.
 
const mat4 & matrix () const override
 Returns the current view matrix (view coordinates to world coordinates).
 
LodMode lodMode () const
 Returns the current setting of the Level of Detail rendering.
 
void setLodMode (LodMode value)
 Sets the current setting of the Level of Detail rendering.
 
void setDirty ()
 Set the dirty flag to issue re-rendering.
 
GlVolumeRenderervr ()
 Return volume renderer instance.
 
void setVr (std::unique_ptr< GlVolumeRenderer > vr)
 Sets the volume renderer instance, vr must not be null.
 
void setMode (int mode)
 Set the volume rendering mode.
 
int mode () const
 Return the volume rendering mode.
 
void setClipOrientation (bool flag)
 Set the orientation of the chosen clip plane.
 
void setClipPlane (int clipping)
 Set which clip plane shall be used.
 
void setCustomClipPlane (GlSlice *plane)
 Specify a custom clip plane for the volume rendering.
 
int clipPlane () const
 Return which is the current clip plane.
 
bool clipOrientation () const
 Return the clip plane orientation.
 
mat4 computeDefaultMatrix (std::optional< Geometry::AlignedBox > sceneBounds=std::nullopt) const
 Set the default view matrix for the given scene.
 
void setDefaultMatrix ()
 Set the default view position and orientation.
 
void setDefaultMatrix (const vec3 &center, const vec3 &extent)
 
vec3 sceneCenter () const
 Return center of shown volume if available, or further objects such as meshes otherwise.
 
Geometry::AlignedBox sceneBounds () const
 Return axis-aligned bounding box of all shown images and annotations.
 
void setRenderBufferWrapper (RenderBufferWrapper *w)
 Sets a custom render buffer wrapper around the entire render pipeline.
 
RenderBufferWrapperrenderBufferWrapper () const
 Returns the custom render buffer wrapper if defined.
 
std::optional< vec3 > firstHitpointLocation (vec2i pixel) const
 Return the world coordinate of the front-most object rendered in the view.
 
std::optional< vec3 > firstHitpointLocation (vec2i pixel, int filterKernelSize) const
 Return the filtered world coordinate of the front-most object rendered in the view.
 
std::optional< std::pair< vec3, vec3 > > firstHitpointLocationAndNormal (vec2i pixel, int filterKernelSize) const
 Return the filtered world coordinate of the front-most object rendered in the view and the normal at that location.
 
std::unique_ptr< PickingTokencreatePickingToken ()
 Returns a picking token, enabling the picking if necessary. Picking is guaranteed to stay on while at least one of the tokens lives.
 
const GL::ObjectPickingobjectPicking () const
 Returns access to a pre-existing object picking. Consider using createPickingToken instead, unless you only want to check if picking is active right now.
 
bool isOrderIndependentTransparencyEnabled () const
 Returns true if order-independent transparency support is enabled.
 
void setOrderIndependentTransparencyEnabled (bool value)
 Specify whether order-independent transparency support should be enabled.
 
const GL::OrderIndependentTransparencyorderIndependentTransparency () const override
 Returns the order-independent transparency handling object used by this view if supported and enabled.
 
SSAOMode ssaoMode () const
 Returns whether and when to apply SSAO post-processing.
 
void setSsaoMode (SSAOMode value)
 Sets whether and when to apply SSAO post-processing.
 
GlScreenSpaceAmbientOcclusionssao ()
 Returns the SSAO instance in case SSAO is enabled.
 
void applyTransformation (const vec3 &translation, const vec3 &rotation, const vec3 *center=0)
 Applies the given transformation to the view's matrix.
 
bool usesAutoClipDistance () const
 Returns the flag whether to compute OpenGL near/far clip distance automatically based on scene contents.
 
void setUseAutoClipDistance (bool value)
 Sets the flag whether to compute OpenGL near/far clip distance automatically based on scene contents.
 
double nearClipDistance () const
 Return the OpenGL near clip distance.
 
void setNearClipDistance (double val)
 Set the OpenGL near clip distance, will have no effect if setUseAutoClipDistance() is enabled.
 
double farClipDistance () const
 Return the OpenGL far clip distance.
 
void setFarClipDistance (double val)
 Set the OpenGL far clip distance, will have no effect if setUseAutoClipDistance() is enabled.
 
void setShowWorldCoordinateSystem (bool v)
 Visualizes the world coordinate system.
 
bool showsWorldCoordinateSystem () const
 
void setApplyClipPlaneToGlObjects (bool v)
 Defines if the clipping plane defined by m_clipping or m_customClipPlane (or the absence of that) should automatically be applied to GL objects rendered in this view as well, e.g.
 
bool appliesClipPlaneToGlObjects () const
 
bool flipsY () const
 Returns the flag whether to flip the rendered image vertically.
 
void setFlipY (bool value)
 Sets the flag whether to flip the rendered image vertically.
 
void renderObjectsOnly ()
 Renders only the GlObjects attached to the view.
 
- Public Member Functions inherited from GlView
virtual void resize (int width, int height)
 Set a new viewport size for this view.
 
int height () const
 Current viewport height of the view.
 
int width () const
 Current viewport width of the view.
 
void addObject (GlObject *object)
 Add a reference to a GlObject to be drawn by this view.
 
void removeObject (GlObject *object)
 Remove a reference to a GlObject drawn by this view.
 
const std::vector< GlObject * > & objects () const
 Return the set of GlObjects that are drawn by this view.
 
const GL::ViewStatestate () const
 Return the view state that was set during the last render() call.
 

Public Attributes

Signal< GlVolumeView * > matrixChanged
 

Additional Inherited Members

- Protected Member Functions inherited from GlView
GL::OrderIndependentTransparencysharedOitInstance () const
 Offers support for GlViews sharing GL::OrderIndependentTransparency instances to reduce GPU memory consumption.
 
- Protected Attributes inherited from GlView
std::vector< GlObject * > m_objects
 Other objects to consider during rendering.
 
mat4 m_matrix = mat4::Identity()
 Matrix converting view coordinates to world coords (inverse of a traditional OpenGL view matrix)
 
GL::ViewState m_state
 OpenGL state describing viewport, projection and model-view matrix of last render call.
 
int m_width = 0
 
int m_height = 0
 

Member Enumeration Documentation

◆ LodMode

enum LodMode

Possible settings for Level of detail (LOD) rendering.

Enumerator
LOD_OFF 

Do not use LOD rendering.

LOD_ON 

Always use LOD rendering.

LOD_AUTO_VOLUME_SIZE 

Automatically adjust LOD rendering based on volume size (currently not supported)

◆ SSAOMode

enum class SSAOMode
strong

Enumeration of Screen Space Ambient Occlusion (SSAO) working modes.

See also
GlScreenSpaceAmbientOcclusion
Enumerator
Disabled 

SSAO is disabled.

GeometryOnly 

SSAO is applied after the geometry rendering pass (before DVR pass)

Full 

SSAO to the final scene (after DVR pass)

Member Function Documentation

◆ type()

Type type ( ) const
inlineoverridevirtual

Return the type of this view.

Implements GlView.

◆ render()

bool render ( )
overridevirtual

Render the view and if required the volume rendering.

Implements GlView.

◆ setMatrix()

void setMatrix ( const mat4 & m)
overridevirtual

Set view matrix from OpenGL camera to world coordinate system.

Reimplemented from GlView.

◆ matrix()

const mat4 & matrix ( ) const
overridevirtual

Returns the current view matrix (view coordinates to world coordinates).

Reimplemented from GlView.

◆ setClipPlane()

void setClipPlane ( int clipping)

Set which clip plane shall be used.

Here, a value of 0-2 means that the corresponding standard MPR slice is used as clip plane, 3 disables the clip plane, and 4 means that a custom clip plane is used if available.

◆ computeDefaultMatrix()

mat4 computeDefaultMatrix ( std::optional< Geometry::AlignedBox > sceneBounds = std::nullopt) const

Set the default view matrix for the given scene.

If sceneBounds is null it will use sceneBounds().

◆ firstHitpointLocation() [1/2]

std::optional< vec3 > firstHitpointLocation ( vec2i pixel) const

Return the world coordinate of the front-most object rendered in the view.

Parameters
pixelLookup location in the view's pixel space (0, 0)..(width, height).

◆ firstHitpointLocation() [2/2]

std::optional< vec3 > firstHitpointLocation ( vec2i pixel,
int filterKernelSize ) const

Return the filtered world coordinate of the front-most object rendered in the view.

Parameters
pixelLookup location in the view's pixel space (0, 0)..(width, height).
filterKernelSizeFilter kernel size in terms of number of pixels in each direction.

◆ firstHitpointLocationAndNormal()

std::optional< std::pair< vec3, vec3 > > firstHitpointLocationAndNormal ( vec2i pixel,
int filterKernelSize ) const

Return the filtered world coordinate of the front-most object rendered in the view and the normal at that location.

Parameters
pixelLookup location in the view's pixel space (0, 0)..(width, height).
filterKernelSizeFilter kernel size in terms of number of pixels in each direction. \ret Location of the intersection and normal to the surface

◆ orderIndependentTransparency()

const GL::OrderIndependentTransparency * orderIndependentTransparency ( ) const
overridevirtual

Returns the order-independent transparency handling object used by this view if supported and enabled.

GlObjects can use this instance to support correct blending of their semi-transparent surfaces with the ones from the other GlObjects.

Reimplemented from GlView.

◆ applyTransformation()

void applyTransformation ( const vec3 & translation,
const vec3 & rotation,
const vec3 * center = 0 )

Applies the given transformation to the view's matrix.

First rotation is performed around center, then translation is added. Scene center will be used if center is zero.

◆ setShowWorldCoordinateSystem()

void setShowWorldCoordinateSystem ( bool v)

Visualizes the world coordinate system.

For the case of meshes and point clouds, the lengths of the axes are adjusted according to the data.

◆ setApplyClipPlaneToGlObjects()

void setApplyClipPlaneToGlObjects ( bool v)

Defines if the clipping plane defined by m_clipping or m_customClipPlane (or the absence of that) should automatically be applied to GL objects rendered in this view as well, e.g.

meshes.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close