cgv
Loading...
Searching...
No Matches
volume_renderer.h
1#pragma once
2
3#include "renderer.h"
4
5#include "gl/lib_begin.h"
6
7namespace cgv { // @<
8 namespace render { // @<
9
10 class CGV_API volume_renderer;
11
13
16 extern CGV_API volume_renderer& ref_volume_renderer(context& ctx, int ref_count_change = 0);
17
19 struct CGV_API volume_render_style : public render_style {
20 /*@name global volume rendering options*/
22
24 IQ_8 = 8,
25 IQ_16 = 16,
26 IQ_32 = 32,
27 IQ_64 = 64,
28 IQ_128 = 128,
29 IQ_256 = 256,
30 IQ_512 = 512,
31 IQ_1024 = 1024,
32 IQ_2048 = 2048,
33 IQ_4096 = 4096
34 } integration_quality;
39 IP_NEAREST = 0,
40 IP_SMOOTHED = 1,
41 IP_LINEAR = 2,
42 IP_CUBIC = 3
43 } interpolation_mode;
46
49 CM_MAXIMUM_INTENSITY_PROJECTION = 0,
50 CM_AVERAGE = 1,
51 CM_BLEND = 2 // using transfer function
52 } compositing_mode;
53
56
72 float roughness;
75
80
83 IM_NONE = 0,
84 IM_ISOVALUE = 1,
85 IM_ALPHA_THRESHOLD = 2
86 } isosurface_mode;
88 float isovalue;
93
95 enum SliceMode {
96 SM_DISABLED = 0, // no slice
97 SM_OPAQUE = 1, // opaque slice rendering
98 SM_TRANSPARENT = 2 // transparent slice rendering
99 } slice_mode;
106
109
110 //}@
113 };
114
116 class CGV_API volume_renderer : public renderer
117 {
118 private:
121 protected:
139 render_style* create_render_style() const;
141 void update_defines(shader_define_map& defines);
143 bool build_shader_program(context& ctx, shader_program& prog, const shader_define_map& defines);
145 void init_noise_texture(context& ctx);
146 public:
150 bool init(context& ctx);
152 virtual void clear (const context& ctx);
154 bool set_volume_texture(texture* tex);
156 bool set_transfer_function_texture(texture* tex);
158 bool set_gradient_texture(texture* tex);
160 bool set_depth_texture(texture* tex);
162 void set_bounding_box(const box3& bbox);
164 void transform_to_bounding_box(bool flag);
166 void set_noise_offset(const vec2& offset);
168 bool enable(context& ctx);
170 bool validate_attributes(const context& ctx) const;
172 bool disable(context& ctx);
174 void draw(context& ctx, size_t start, size_t count,
175 bool use_strips = false, bool use_adjacency = false, uint32_t strip_restart_index = -1);
176 };
177 }
178}
179
180#include <cgv/config/lib_end.h>
attribute array manager used to upload arrays to gpu
base class for all drawables, which is independent of the used rendering API.
Definition context.h:621
abstract base class for all renderers that handles a shader program and position / color attribute
Definition renderer.h:22
a shader program combines several shader code fragments to a complete definition of the shading pipel...
the texture class encapsulates all functionality independent of the rendering api.
Definition texture.h:15
renderer that supports point splatting
texture * gradient_texture
the 3D texture containing vector gradients used for lighting normal calculation
texture * depth_texture
a 2D texture from a frame buffer depth buffer used to combine volume rendering with opaque geometry
texture * transfer_function_texture
the 2D transfer function texture used for classification of the volume values
bool apply_bounding_box_transformation
whether to translate and scale the volume to the given bounding box during rendering
vec2 noise_offset
offset applied to the noise texture (can be used in conjunction with temporal anti aliasing)
texture * volume_texture
the 3D texture used for rendering
texture noise_texture
a 2D texture containing random noise used to offset ray start positions in order to reduce ring artif...
box3 bounding_box
the bounding box of the volume in scene units
std::map< std::string, std::string > shader_define_map
typedef for shader define map data structure
Definition shader_code.h:52
volume_renderer & ref_volume_renderer(context &ctx, int ref_count_change)
reference to a singleton volume renderer that is shared among drawables
the cgv namespace
Definition print.h:11
base class for all render styles
Definition renderer.h:16
bool light_local_to_eye
whether the light is local to the eye position (moves with the eye) or is static to the scene
bool enable_noise_offset
whether to use the noise texture to offset ray start positions in order to reduce sampling artifacts
bool enable_lighting
whether to enable lighting
CompositingMode
the compositing mode used
float specular_strength
material specular component strength
float ambient_strength
light ambient component strength
rgb isosurface_color
the default constant isosurface color
bool enable_depth_test
whether to enable depth testing by reading depth from a texture to allow geometry intersecting the vo...
float isovalue
the value used to check for an isosurface
float gradient_lambda
influence scale for gradient-based opacity modulation
bool isosurface_color_from_transfer_function
whether to color the isosurface based on the transfer function
IsosurfaceMode
mode of a single supported isosurface
float scale_adjustment_factor
the coefficient used to adjust sample opacity based on volume scaling (useful range between 50 and 50...
float slice_opacity
in case of transparent mode, slice opacity
SliceMode
mode of slice rendering
float specular_color_mix
material specular color mix factor (0 = color from transfer function, 1 = pure white)
vec3 light_direction
the direction of the directional light
float roughness
material roughness (inversely proportional to specular shininess)
bool use_gradient_texture
whether to use a supplied gradient texture or compute gradients on the fly via central differences (d...
int slice_axis
coordinate axis orthogonal to which slice is rendered
InterpolationMode
the interpolation method used (supplied volume texture should be set to GL_LINEAR)
float diffuse_strength
material diffuse component strength
bool enable_gradient_modulation
whether to enable modulating the volume opacity by the gradient magnitude
box3 clip_box
a bounding box used to define a subspace of the volume to be visualized
float slice_coordinate
coordinate value along axis defining slice in range [0,1]
IntegrationQuality
quality measure for the number of steps used during ray marching