NVIDIA IndeX API nvidia_logo_transpbg.gif Up
nv::index::IVolume_sample_program Class Reference

An interface class representing rendering kernel programs applied to volume primitives (e.g., ISparse_volume_scene_element). More...

#include <irendering_kernel_programs.h>

Inherits mi::base::Interface_declare< 0x4c2b9169, ... >.

Detailed Description

An interface class representing rendering kernel programs applied to volume primitives (e.g., ISparse_volume_scene_element).

The programs applied to volumes are evaluated for each sample taken during the rendering process. An example of a volume sample program is:

NV_IDX_XAC_VERSION_1_0
class Volume_sample_program
{
public:
void initialize() {}
int execute(
const Sample_info_self& sample_info,
Sample_output& sample_output)
{
// Scalar volume sample
const float volume_sample = state.volume.sample(sample_info.sample_position);
// Look up color and opacity values from colormap
const float4 sample_color = state.colormap.lookup(volume_sample);
if (0.3f < volume_sample && volume_sample < 0.7f)
{
}
// Output swizzled color
sample_output.color = make_float4(
sample_color.y,
sample_color.z,
sample_color.x,
sample_color.w);
}
};
@ NV_IDX_PROG_DISCARD_SAMPLE
Indicate that the resulting sampling result should be discarded.
Definition: xac_interface_return_codes_doc.h:15
@ NV_IDX_PROG_OK
Indicate the sucessfull execution of the sampling program.
Definition: xac_interface_return_codes_doc.h:12
#define NV_IDX_DEVICE_INLINE_MEMBER
A member method's qualifier macro.
Definition: xac_interface_standard_lib_doc.h:15
#define NV_IDX_VOLUME_SAMPLE_PROGRAM
An initializing macro of a volume sample program.
Definition: xac_interface_standard_lib_doc.h:23

Currently the class representing a volume sample program needs to follow the template set in the example above. It has to be called Volume_sample_program and is required to expose two public methods called initialize(), which is executed once per rendering instance of a subregion, and execute(), which is then executed for each sample taken along a viewing ray.

Each volume sample program is also required to have the NV_IDX_VOLUME_SAMPLE_PROGRAM macro as the first definition inside the program class. This macro initializes the internal state of the program exposed to the user. Later revisions of the rendering kernel programs feature will make the definition more straightforward.

The initialize() method can be used to initialize variables used in the per-sample computation of the execute() method. The initializations can encompass the calculation of static data such as lighting or material properties.

The execute() method always receives the current sample position as input and the output color as output. Through the return value of this method the rendering kernel can be informed to use the generated output sample or to discard the current sample. For this purpose there are two return values for the execute() method:

  • NV_IDX_PROG_OK
  • NV_IDX_PROG_DISCARD_SAMPLE

The list of return values may be extended in the future to, for instance, discard entire ray segments.

Each instance of a volume sample program has access to a state variable allowing access to the current volume data set as well as the current colormap. The contents of this state is derived from the scene definition. The state is accessed through the state variable available to each instance. The state contains a volume and colormap variable, which can be used to sample the volume and lookup color and opacity values from a colormap, as demonstrated in the example above. It is important to note that the return value of the sample() method is dependent on the actual volume type. A scalar volume, such as uint8 or float32 volumes return a simple float value, whereas RGBA- volumes return a float4 value.


The documentation for this class was generated from the following file: