![]() |
LibCarna Version 3.4.0
|
Performs direct volume renderings of the volume geometries in the scene. More...
#include <DVRStage.hpp>
Public Member Functions | |
DVRStage (unsigned int geometryType, unsigned int colorMapResolution=base::ColorMap::DEFAULT_RESOLUTION) | |
Instantiates. The created stage will render such base::Geometry scene graph nodes, whose geometry types equal geometryType. | |
virtual | ~DVRStage () |
Deletes. | |
virtual void | reshape (base::FrameRenderer &fr, unsigned int width, unsigned int height) override |
Orders this stage to reshape its buffers according to the specified width and height. | |
virtual void | renderPass (const base::math::Matrix4f &viewTransform, base::RenderTask &rt, const base::Viewport &vp) override |
Triggers the volume rendering. | |
void | setTranslucency (float translucency) |
Sets the translucency property. | |
float | translucency () const |
Tells current translucency. | |
void | setDiffuseLight (float diffuseLight) |
Sets the diffuse light amount to diffuseLight and the ambient light amount to one minus diffuseLight. | |
float | diffuseLight () const |
Tells the diffuse light amount. The ambient light amount is one minus the diffuse light amount. | |
bool | isLightingUsed () const |
Tells whether lighting was used during the last rendering. The return value is undefined if nothing was rendered yet. | |
![]() | |
VolumeRenderingStage (unsigned int geometryType) | |
Instantiates. The created stage will render such base::Geometry scene graph nodes, whose geometry types equal geometryType. | |
virtual | ~VolumeRenderingStage () |
Deletes. | |
void | setSampleRate (unsigned int sampleRate) |
Sets number of slices to be rendered per segment. | |
unsigned int | sampleRate () const |
Tells number of slices to be rendered per segment. | |
![]() | |
GeometryStage (unsigned int geometryType, unsigned int geometryTypeMask=RenderQueue< base::Renderable::BackToFront >::EXACT_MATCH_GEOMETRY_TYPE_MASK) | |
Instantiates s.t. the predefined rendering queue enqueues such LibCarna::base::Geometry scene graph nodes, whose geometry type AND-linked with geometryTypeMask equals the geometryType specified here. | |
virtual | ~GeometryStage () |
Releases acquired video resources. | |
virtual void | prepareFrame (Node &root) override |
Called once before each frame. | |
std::size_t | renderedPassesCount () const |
Tells the number of passes rendered so far since the beginning of the current frame. | |
GeometryFeatureType::ManagedInterface & | videoResource (GeometryFeatureType &geometryFeature) const |
Interfaces the geometryFeature video resources that were acquired by this rendering stage. | |
const GeometryFeatureType::ManagedInterface & | videoResource (const GeometryFeatureType &geometryFeature) const |
![]() | |
RenderStage () | |
Instantiates in enabled-state. | |
virtual | ~RenderStage () |
Deletes. | |
void | setViewTransformFixed (bool viewTransformFixed) |
Sets whether the view transform is pass-invariant for the duration of a single frame. | |
bool | isViewTransformFixed () const |
Tells whether the view transform is pass-invariant for the duration of a single frame. | |
bool | isInitialized () const |
Tells whether this stage is ready for rendering. | |
bool | isEnabled () const |
Tells whether this stage is enabled. Disabled stages are not rendered by render tasks. | |
void | setEnabled (bool) |
Sets whether this stage is enabled. Disabled stages are not rendered by render tasks. | |
base::FrameRenderer & | renderer () |
References the renderer this stage belongs to. | |
const base::FrameRenderer & | renderer () const |
void | addRenderStageListener (RenderStageListener &listener) |
Adds listener to the set of listeners this instance notifies in \(\mathcal O\left(\log n\right)\). | |
void | removeRenderStageListener (RenderStageListener &listener) |
Removes listener from the set of listeners this instance notifies in \(\mathcal O\left(\log n\right)\). | |
Public Attributes | |
base::ColorMap | colorMap |
The color map used for the rendering. | |
![]() | |
const unsigned int | geometryType |
Renders such geometries whose type AND-linked with geometryTypeMask equals this. | |
const unsigned int | geometryTypeMask |
Renders such geometries whose type AND-linked with this equals geometryType. | |
Static Public Attributes | |
static const unsigned int | ROLE_INTENSITIES = 0 |
Holds the role that intensity volume data is expected to take when attached to base::Geometry nodes. | |
static const unsigned int | ROLE_NORMALS = 1 |
Holds the role that the normal map is expected to take when attached to base::Geometry nodes. | |
static const float | DEFAULT_TRANSLUCENCY |
Holds the default translucency. | |
static const float | DEFAULT_DIFFUSE_LIGHT |
Holds the default diffuse light amount. The ambient light amount is always one minus the diffuse light amount. | |
![]() | |
static const unsigned int | DEFAULT_SAMPLE_RATE = 200 |
Holds the default number of slices rendered per segment. | |
Protected Member Functions | |
virtual unsigned int | loadVideoResources () override |
Loads video resources when rendering is triggered for the first time. Override this method if you need any additional resources to be loaded, but always call the base implementation. | |
virtual void | createVolumeSamplers (const std::function< void(unsigned int, base::Sampler *) > ®isterSampler) override |
Creates texture samplers for volume textures and uses registerSampler to assign them to the roles that they should be used with. | |
virtual const base::ShaderProgram & | acquireShader () override |
Acquires the dvr shader from the base::ShaderManager. | |
virtual const std::string & | uniformName (unsigned int role) const override |
Maps ROLE_INTENSITIES to intensities and ROLE_NORMALS to normalMap . | |
virtual void | configureShader () override |
Performs custom shader configuration on a per-pass level. | |
virtual void | configureShader (const base::Renderable &) override |
Computes and uploads the normals transformation matrix. | |
![]() | |
virtual void | render (const base::Renderable &) override |
Renders the renderable. | |
![]() | |
void | activateGLContext () const |
Ensures that the OpenGL context of the hosting LibCarna::base::FrameRenderer is the current one. | |
virtual void | buildRenderQueues (Node &root, const math::Matrix4f &viewTransform) |
Builds the rendering queues of this stage. | |
virtual void | rewindRenderQueues () |
Rewinds the rendering queues of this stage. | |
virtual void | updateRenderQueues (const math::Matrix4f &viewTransform) |
Recomputes the model-view transforms of the renderables enqueued by this stage. | |
Additional Inherited Members | |
![]() | |
RenderQueue< base::Renderable::BackToFront > | rq |
Holds the predefined rendering queue of this rendering stage. | |
Performs direct volume renderings of the volume geometries in the scene.
The DVRStage
constructor takes a geometry type parameter:
The concept of geometry types is explained here.
The DVRStage
supports two types of rendering modes: Rendering with lighting enabled and rendering without lighting. In general, lighting produces more sculptural results, but it comes at the cost of additional requirements: Not only the intensity volume must be uploaded to the GPU, but also another 3D texture that maps texture space coordinates to the normal vectors of the surface at a particular location. Depending on the resolution of the data, this might cause noteworthy memory consumption.
Luckily the helpers::VolumeGridHelper class does everything that is needed in order to compute the normal vectors and upload them to the GPU, if it is instructed to do so: Its second type argument is optional and set to void
by default. This disables its normal vectors support. Setting it to anything different, like base::NormalMap3DInt8 for example, makes it compute the normal vectors when helpers::VolumeGridHelper::loadIntensities or its computeNormals
method are called.
The DVRStage
decides which mode to use depending on whether the normal vectors are provided or not.
The following example code configures the DVRStage
s.t. it produces the rendering presented further below:
This gives the following rendering:
The translucency scales the opacity values queried from the color map. Assuming that \(\alpha\) was the value from the color map, the translucency \(t \geq 0\) scales the actual opacity to \(\frac{\alpha}{1 + t}\).
The default translucency is quite high, which is fine for rendering without lighting. You might consider setting it down when rendering with lighting enabled:
This gives the following rendering:
Definition at line 105 of file DVRStage.hpp.
|
explicit |
Instantiates. The created stage will render such base::Geometry scene graph nodes, whose geometry types equal geometryType.
The parameter colorMapResolution determines the resolution of the color map. If your data is 8bit, using 8bit color map is sufficient. If your data is 32bit, you probably also want to use a 32bit color map.
|
overrideprotectedvirtual |
Acquires the dvr
shader from the base::ShaderManager.
Implements LibCarna::presets::VolumeRenderingStage.
|
overrideprotectedvirtual |
Performs custom shader configuration on a per-pass level.
Implements LibCarna::presets::VolumeRenderingStage.
|
overrideprotectedvirtual |
Computes and uploads the normals transformation matrix.
Implements LibCarna::presets::VolumeRenderingStage.
|
overrideprotectedvirtual |
Creates texture samplers for volume textures and uses registerSampler to assign them to the roles that they should be used with.
Implements LibCarna::presets::VolumeRenderingStage.
|
overrideprotectedvirtual |
Loads video resources when rendering is triggered for the first time. Override this method if you need any additional resources to be loaded, but always call the base implementation.
+1
. Reimplemented from LibCarna::presets::VolumeRenderingStage.
|
overridevirtual |
Triggers the volume rendering.
Reimplemented from LibCarna::presets::VolumeRenderingStage.
|
overridevirtual |
Orders this stage to reshape its buffers according to the specified width and height.
fr | references the frame renderer this stage belongs to. |
width | is the root viewport width. |
height | is the root viewport height. |
Reimplemented from LibCarna::base::RenderStage.
void LibCarna::presets::DVRStage::setDiffuseLight | ( | float | diffuseLight | ) |
Sets the diffuse light amount to diffuseLight and the ambient light amount to one minus diffuseLight.
diffuseLight >= 0 && diffuseLight <= 1
This only has an effect if lighting is enabled. If lighting is enabled, setting this to \(0\) virtually disables the lighting.
|
overrideprotectedvirtual |
Maps ROLE_INTENSITIES to intensities
and ROLE_NORMALS to normalMap
.
Implements LibCarna::presets::VolumeRenderingStage.
base::ColorMap LibCarna::presets::DVRStage::colorMap |
The color map used for the rendering.
Definition at line 163 of file DVRStage.hpp.
|
static |
Holds the default diffuse light amount. The ambient light amount is always one minus the diffuse light amount.
Definition at line 134 of file DVRStage.hpp.
|
static |
Holds the default translucency.
Definition at line 128 of file DVRStage.hpp.
|
static |
Holds the role that intensity volume data is expected to take when attached to base::Geometry nodes.
Definition at line 117 of file DVRStage.hpp.
|
static |
Holds the role that the normal map is expected to take when attached to base::Geometry nodes.
Definition at line 123 of file DVRStage.hpp.
Written by Leonid Kostrykin © 2021–2025. Based on Carna (© 2010-2016).
Documentation generated by Doxygen