Carna
Version 3.0.1
|
Performs direct volume renderings of the volume geometries in the scene. More...
#include <DVRStage.h>
Public Member Functions | |
DVRStage (unsigned int geometryType) | |
Instantiates. The created stage will render such base::Geometry scene graph nodes, whose geometry types equal geometryType. | |
virtual | ~DVRStage () |
Deletes. | |
DVRStage * | clone () const override |
Returns same RenderStage implementation with same configuration. More... | |
virtual void | reshape (base::FrameRenderer &fr, unsigned int width, unsigned int height) override |
Orders this stage to reshape its buffers according to the specified dimensions. More... | |
virtual void | renderPass (const base::math::Matrix4f &viewTransform, base::RenderTask &rt, const base::Viewport &vp) override |
Triggers the volume rendering. | |
void | clearColorMap () |
Clears the color map. All HU values are mapped to base::Color::BLACK_NO_ALPHA after calling this method. | |
void | writeColorMap (const base::math::Span< base::HUV > &huRange, const base::math::Span< base::Color > colorRange) |
Maps all HU values from huRange to colorRange. The first/last HU value from huRange is mapped to the first/last value of colorRange, respectively. The values are interpolated linearly in between. More... | |
void | writeColorMap (base::HUV huFirst, base::HUV huLast, const base::Color &colorFirst, const base::Color &colorLast) |
void | setTranslucence (float translucence) |
Sets the translucence property. | |
float | translucence () const |
Tells current translucence. | |
void | setDiffuseLight (float diffuseLight) |
Sets the diffuse light amount to diffuseLight and the ambient light amount to one minus diffuseLight. More... | |
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. More... | |
unsigned int | sampleRate () const |
Tells number of slices to be rendered per segment. More... | |
![]() | |
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 Carna::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. More... | |
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. More... | |
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. More... | |
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. More... | |
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)\). | |
Static Public Attributes | |
static const unsigned int | ROLE_HU_VOLUME = 0 |
Holds the role that HU 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_TRANSLUCENCE |
Holds the default translucence. | |
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 = 100 |
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. More... | |
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_HU_VOLUME to huVolume 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 Carna::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 | |
![]() | |
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. | |
![]() | |
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 HU 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::loadData 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 translucence scales the opacity values queried from the color map. Assuming that \(\alpha\) was the value from the color map, the translucence \(t \geq 0\) scales the actual opacity to \(\frac{\alpha}{1 + t}\).
The default translucence 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 101 of file DVRStage.h.
|
overridevirtual |
Returns same RenderStage
implementation with same configuration.
The listeners and the rendering state are not copied.
Implements Carna::base::RenderStage.
|
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 Carna::presets::VolumeRenderingStage.
|
overridevirtual |
Orders this stage to reshape its buffers according to the specified dimensions.
fr | references the frame renderer this stage belongs to. |
width | is the root viewport width. |
height | is the root viewport height. |
Reimplemented from Carna::base::RenderStage.
void Carna::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.
void Carna::presets::DVRStage::writeColorMap | ( | const base::math::Span< base::HUV > & | huRange, |
const base::math::Span< base::Color > | colorRange | ||
) |
Maps all HU values from huRange to colorRange. The first/last HU value from huRange is mapped to the first/last value of colorRange, respectively. The values are interpolated linearly in between.
Nothing happens if the last HU value of huRange is smaller than the first. If the first and the last HU values of huRange are equal, they are mapped to the mean of the first and the last values from colorRange.
void Carna::presets::DVRStage::writeColorMap | ( | base::HUV | huFirst, |
base::HUV | huLast, | ||
const base::Color & | colorFirst, | ||
const base::Color & | colorLast | ||
) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Documentation generated by Doxygen