NVIDIA IndeX API nvidia_logo_transpbg.gif Up
xac_interface_standard_lib_doc.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright 2023 NVIDIA Corporation. All rights reserved.
3 *****************************************************************************/
6
7namespace nv {
8namespace index {
9
11namespace xac {
12
15#define NV_IDX_DEVICE_INLINE_MEMBER
16
19#define NV_IDX_SURFACE_SAMPLE_PROGRAM
20
23#define NV_IDX_VOLUME_SAMPLE_PROGRAM
24
25}
26
27
29namespace xaclib {
30
31/* Free Function Macros */
32
33// debug print using define macros
34
37#define printf_condition(PRINT_CONDITION, ...) \
38do { \
39 if ((bool)PRINT_CONDITION) \
40 printf(__VA_ARGS__); \
41} while (0)
42
45#define printf_thread(THREAD_ID_X, THREAD_ID_Y, ...) \
46do { \
47 if (threadIdx.x==THREAD_ID_X && threadIdx.y==THREAD_ID_Y) \
48 printf(__VA_ARGS__); \
49} while (0)
50
53#define printf_block(BLOCK_ID_X, BLOCK_ID_Y, ...) \
54do { \
55 if (blockIdx.x == BLOCK_ID_X && blockIdx.y == BLOCK_ID_Y) \
56 printf(__VA_ARGS__); \
57} while (0)
58
61#define printf_pixel(STATE, PX, PY, ...) \
62do { \
63 const uint2 pixc = nv::index::xaclib::get_pixel_position(STATE.scene); \
64 if (pixc.x == PX && pixc.y == PY) \
65 printf(__VA_ARGS__); \
66} while (0)
67
70#define printf_box(BOX_MIN, BOX_MAX, POSITION, ...) \
71do { \
72 if (is_inside_bounding_box(BOX_MIN, BOX_MAX, POSITION)) \
73 printf(__VA_ARGS__); \
74} while (0)
75
76/* Free Functions */
77
80float4 gamma_correct(const float4& color, float gamma_exp);
81
84bool is_inside_bounding_box(const float3& box_min, const float3& box_max, const float3& position);
85
88uint2 get_pixel_position(const xac::Scene& scene);
89
92xac::Ray transform_ray(const cuda::Mat4x4f& m, const xac::Ray& r);
93
96template<const xac::NV_IDX_volume_filter_types filter_type>
98 const xac::Sparse_volume& volume,
99 const float3& sample_position,
100 float dh = 1.0f);
101
104template<const xac::Volume_filter_mode filter_mode,
105 const xac::Volume_classification_mode classification_mode>
107 const xac::Sparse_volume_sampler<float, filter_mode, classification_mode>& sampler,
108 const float3& sample_position,
109 float dh = 1.0f);
110
113template<xac::Volume_filter_mode filter_mode,
114 xac::Volume_classification_mode classification_mode>
117 const xac::Sparse_volume& sparse_volume,
118 const xac::Sparse_volume_sample_context& sparse_volume_sample_context,
119 const float3& sample_position,
120 unsigned sparse_volume_attrib_idx = 0u,
121 float dh = 1.0f);
122
125float4 headlight_shading( const xac::Scene& scene,
126 const float3& normal,
127 const float3& view_direction,
128 const float4& sample_color,
129 const float4& specular_color,
130 const float diffuse_falloff = 1.0f,
131 const float shininess = 100.0f,
132 const float ambient_factor = 0.f);
133
136float4 phong_shading( const xac::Scene& scene,
137 const xac::Material_phong& material,
138 const xac::Light& light,
139 const float3& view_direction,
140 const float3& normal,
141 const bool two_sided = false);
142
145float4 phong_shading( const xac::Scene& scene,
146 const uint material_id,
147 const uint light_id,
148 const float3& view_direction,
149 const float3& normal,
150 const bool two_sided = false);
151
155 const xac::Plane& plane,
156 float& t_hit,
157 float2& tex_coord_hit);
158
162 const float3& box_min,
163 const float3& box_max,
164 float& t_near,
165 float& t_far);
166
170 const xac::Cylinder& cylinder,
171 float& t_hit,
172 float3& hit_normal);
173
177 const xac::Ellipsoid& ellipsoid,
178 float& t_hit,
179 float3& hit_normal);
180
183bool intersect_ray_cone ( const xac::Ray& ray,
184 const xac::Cone& cone,
185 float& t_hit,
186 float3& hit_normal);
187
217template<typename TYPE>
218const TYPE* bind_device_buffer( uint slot_id,
219 uint buffer_index) const;
220
223bool device_buffer_available( uint slot_id) const;
224
225// Forward use decalarations of convenience functions (for documentation)
226// using default CUDA library functions
227
228// matrix, vector functions
229using ::transform_point;
230using ::transform_point2;
231using ::transform_vector;
232using ::transform_normal_inv;
233using ::transform_plane_inv;
234
235// matrix functions
236using ::transpose;
237using ::inverse;
238
239// vector functions
240using ::dot;
241using ::length;
242using ::normalize;
243using ::floorf;
244using ::fracf;
245using ::cross;
246using ::reflect;
247using ::smoothstep;
248
249// general component (scalar/float) utility functions
250using ::min;
251using ::max;
252using ::fminf;
253using ::fmaxf;
254using ::lerp;
255using ::clamp;
256using ::fmod;
257using ::fmodf;
258using ::abs;
259using ::fabs;
260using ::powf;
261
262} // namespace xaclib
263} // namespace index
264} // namespace nv
Cone.
Definition: xac_interface_scene_elements_doc.h:456
Cylinder.
Definition: xac_interface_scene_elements_doc.h:419
Ellipsoid.
Definition: xac_interface_scene_elements_doc.h:345
Generic directional light struct.
Definition: xac_interface_scene_elements_doc.h:19
Generic phong material struct.
Definition: xac_interface_scene_elements_doc.h:36
Plane.
Definition: xac_interface_scene_elements_doc.h:493
Ray data structure.
Definition: xac_interface_scene_elements_doc.h:112
Generic scene descriptor class.
Definition: xac_interface_scene_doc.h:17
bool intersect_ray_box(const xac::Ray &ray, const float3 &box_min, const float3 &box_max, float &t_near, float &t_far)
Ray-box intersection tests.
xac::Ray transform_ray(const cuda::Mat4x4f &m, const xac::Ray &r)
Transform a ray using the given matrix.
const TYPE * bind_device_buffer(uint slot_id, uint buffer_index) const
Retrieve a CUDA buffer that has been assigned to the XAC program.
bool intersect_ray_plane(const xac::Ray &ray, const xac::Plane &plane, float &t_hit, float2 &tex_coord_hit)
Ray-plane intersection.
bool device_buffer_available(uint slot_id) const
Determines if a CUDA buffer that has been assigned to the XAC program.
float4 headlight_shading(const xac::Scene &scene, const float3 &normal, const float3 &view_direction, const float4 &sample_color, const float4 &specular_color, const float diffuse_falloff=1.0f, const float shininess=100.0f, const float ambient_factor=0.f)
Compute fixed headlight shading (light direction is view direction)
float4 gamma_correct(const float4 &color, float gamma_exp)
Compute gamma correction of a given input color.
bool is_inside_bounding_box(const float3 &box_min, const float3 &box_max, const float3 &position)
Check if a given position inside an axis aligned bounding box.
float4 phong_shading(const xac::Scene &scene, const xac::Material_phong &material, const xac::Light &light, const float3 &view_direction, const float3 &normal, const bool two_sided=false)
Compute Phong shaded color with predefined colors (ambient, diffuse, specular)
bool intersect_ray_cone(const xac::Ray &ray, const xac::Cone &cone, float &t_hit, float3 &hit_normal)
Ray-cylinder intersection tests.
float3 volume_gradient(const xac::Sparse_volume &volume, const float3 &sample_position, float dh=1.0f)
Sample the gradient vector of a scalar volume using the reference volume.
uint2 get_pixel_position(const xac::Scene &scene)
Retrieve the pixel position for the current thread.
bool intersect_ray_ellipsoid(const xac::Ray &ray, const xac::Ellipsoid &ellipsoid, float &t_hit, float3 &hit_normal)
Ray-cylinder intersection tests.
bool intersect_ray_cylinder(const xac::Ray &ray, const xac::Cylinder &cylinder, float &t_hit, float3 &hit_normal)
Ray-cylinder intersection tests.
Volume_classification_mode
Sparse volume sample classification modes.
Definition: xac_interface_scene_elements_sparse_volume_doc.h:89
Volume_filter_mode
Sparse volume filter modes.
Definition: xac_interface_scene_elements_sparse_volume_doc.h:79
Common namespace for all NVIDIA APIs.
Definition: iindex.h:349
Sparse volume sample context that stores internal information for validating sample information again...
Definition: xac_interface_scene_elements_sparse_volume_doc.h:15
#define NV_IDX_DEVICE_INLINE_MEMBER
A member method's qualifier macro.
Definition: xac_interface_standard_lib_doc.h:15