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, ... >.
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:
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.