7#ifndef MI_NEURAYLIB_TARGET_CODE_TYPES_H
8#define MI_NEURAYLIB_TARGET_CODE_TYPES_H
13#if defined(TARGET_CODE_USE_CUDA_TYPES) && defined(TARGET_CODE_USE_NEURAY_TYPES)
14#error "Only one of TARGET_CODE_USE_CUDA_TYPES and TARGET_CODE_USE_NEURAY_TYPES may be defined."
17#if !defined(TARGET_CODE_USE_NEURAY_TYPES) && \
18 (defined(TARGET_CODE_USE_CUDA_TYPES) || defined(__CUDA_ARCH__))
20#include <vector_types.h>
23#define MI_NEURAYLIB_DEPRECATED_ENUM_VALUE(X,Y)
96template<
bool with_derivatives>
106 using tct_coord2_type =
const tct_float[2];
116 using tct_coord2_type =
const tct_derivable_float2 *;
204template<
bool with_derivatives = false>
335struct Texture_handler_base;
340template<
bool with_derivatives = false>
346 void (*m_tex_lookup_float4_2d)(
350 typename traits::tct_coord2_type coord,
358 void (*m_tex_lookup_float3_2d)(
362 typename traits::tct_coord2_type coord,
370 void (*m_tex_texel_float4_2d)(
379 void (*m_tex_lookup_float4_3d)(
393 void (*m_tex_lookup_float3_3d)(
407 void (*m_tex_texel_float4_3d)(
415 void (*m_tex_lookup_float4_cube)(
422 void (*m_tex_lookup_float3_cube)(
431 void (*m_tex_resolution_2d)(
441 void (*m_tex_resolution_3d)(
481 void (*m_df_light_profile_sample)(
503 void (*m_df_bsdf_measurement_resolution)(
510 void (*m_df_bsdf_measurement_evaluate)(
519 void (*m_df_bsdf_measurement_sample)(
538 void (*m_df_bsdf_measurement_albedos)(
550 void (*m_adapt_normal)(
571 void (*m_scene_data_lookup_float2)(
580 void (*m_scene_data_lookup_float3)(
589 void (*m_scene_data_lookup_float4)(
606 void (*m_scene_data_lookup_int2)(
611 tct_int const default_value[2],
615 void (*m_scene_data_lookup_int3)(
620 tct_int const default_value[3],
624 void (*m_scene_data_lookup_int4)(
629 tct_int const default_value[4],
633 void (*m_scene_data_lookup_color)(
643 void (*m_scene_data_lookup_float4x4)(
656 void (*m_scene_data_lookup_deriv_float)(
665 void (*m_scene_data_lookup_deriv_float2)(
674 void (*m_scene_data_lookup_deriv_float3)(
683 void (*m_scene_data_lookup_deriv_float4)(
692 void (*m_scene_data_lookup_deriv_color)(
739 BSDF_EVENT_ABSORB = 0,
741 BSDF_EVENT_DIFFUSE = 1,
742 BSDF_EVENT_GLOSSY = 1 << 1,
743 BSDF_EVENT_SPECULAR = 1 << 2,
744 BSDF_EVENT_REFLECTION = 1 << 3,
745 BSDF_EVENT_TRANSMISSION = 1 << 4,
747 BSDF_EVENT_DIFFUSE_REFLECTION =
BSDF_EVENT_DIFFUSE |
BSDF_EVENT_REFLECTION,
748 BSDF_EVENT_DIFFUSE_TRANSMISSION =
BSDF_EVENT_DIFFUSE |
BSDF_EVENT_TRANSMISSION,
749 BSDF_EVENT_GLOSSY_REFLECTION =
BSDF_EVENT_GLOSSY |
BSDF_EVENT_REFLECTION,
750 BSDF_EVENT_GLOSSY_TRANSMISSION =
BSDF_EVENT_GLOSSY |
BSDF_EVENT_TRANSMISSION,
751 BSDF_EVENT_SPECULAR_REFLECTION =
BSDF_EVENT_SPECULAR |
BSDF_EVENT_REFLECTION,
752 BSDF_EVENT_SPECULAR_TRANSMISSION =
BSDF_EVENT_SPECULAR |
BSDF_EVENT_TRANSMISSION
753 MI_NEURAYLIB_DEPRECATED_ENUM_VALUE(BSDF_EVENT_FORCE_32_BIT, 0xffffffffU)
759#define MI_NEURAYLIB_BSDF_USE_MATERIAL_IOR (-1.0f)
766 DF_FLAGS_ALLOW_REFLECT = 1,
767 DF_FLAGS_ALLOW_TRANSMIT = 2,
768 DF_FLAGS_ALLOW_REFLECT_AND_TRANSMIT =
DF_FLAGS_ALLOW_REFLECT |
DF_FLAGS_ALLOW_TRANSMIT,
769 DF_FLAGS_ALLOWED_SCATTER_MODE_MASK =
DF_FLAGS_ALLOW_REFLECT_AND_TRANSMIT
770 MI_NEURAYLIB_DEPRECATED_ENUM_VALUE(DF_FLAGS_FORCE_32_BIT, 0xffffffffU)
805template<Df_handle_slot_mode N>
816 tct_float3 bsdf_diffuse[
static_cast<size_t>(N)];
818 tct_float3 bsdf_glossy[
static_cast<size_t>(N)];
827struct Bsdf_evaluate_data<
DF_HSM_POINTER> :
public Bsdf_evaluate_data_base
846struct Bsdf_evaluate_data<
DF_HSM_NONE> :
public Bsdf_evaluate_data_base
878template<Df_handle_slot_mode N>
888 tct_float3 albedo_diffuse[
static_cast<size_t>(N)];
890 tct_float3 albedo_glossy[
static_cast<size_t>(N)];
900struct Bsdf_auxiliary_data<
DF_HSM_POINTER> :
public Bsdf_auxiliary_data_base
921struct Bsdf_auxiliary_data<
DF_HSM_NONE> :
public Bsdf_auxiliary_data_base
951 char const *arg_block_data);
966 char const *arg_block_data);
981 char const *arg_block_data);
987struct Material_function
1001 char const *arg_block_data);
1012 using Type_with_derivs = T(
1015 char const *arg_block_data);
1034 char const *arg_block_data);
1051 char const *arg_block_data);
1066 char const *arg_block_data);
1081 char const *arg_block_data);
1096 char const *arg_block_data);
1111 char const *arg_block_data);
1126 char const *arg_block_data);
1141 char const *arg_block_data);
1155 char const *arg_block_data);
1170 char const *arg_block_data);
1176 EDF_EVENT_EMISSION = 1
1177 MI_NEURAYLIB_DEPRECATED_ENUM_VALUE(EDF_EVENT_FORCE_32_BIT, 0xffffffffU)
1195template<Df_handle_slot_mode N>
1208struct Edf_evaluate_data<
DF_HSM_POINTER> :
public Edf_evaluate_data_base
1221struct Edf_evaluate_data<
DF_HSM_NONE> :
public Edf_evaluate_data_base
1239template<Df_handle_slot_mode N>
1251struct Edf_auxiliary_data<
DF_HSM_POINTER> :
public Edf_auxiliary_data_base
1263struct Edf_auxiliary_data<
DF_HSM_NONE> :
public Edf_auxiliary_data_base
1284 char const *arg_block_data);
1301 char const *arg_block_data);
1316 char const *arg_block_data);
1331 char const *arg_block_data);
1346 char const *arg_block_data);
1361 char const *arg_block_data);
1376 char const *arg_block_data);
1391 char const *arg_block_data);
1405 char const *arg_block_data);
1420 char const *arg_block_data);
int Sint32
32-bit signed integer.
Definition: types.h:46
unsigned int Uint32
32-bit unsigned integer.
Definition: types.h:49
Color cos(const Color &c)
Returns a color with the elementwise cosine of the color c.
Definition: color.h:546
math::Vector_struct<Float32, 2> Float32_2_struct
Vector of two Float32 (underlying POD type).
Definition: vector_typedefs.h:187
math::Vector_struct<Float32, 4> Float32_4_struct
Vector of four Float32 (underlying POD type).
Definition: vector_typedefs.h:201
math::Vector_struct<Float32, 3> Float32_3_struct
Vector of three Float32 (underlying POD type).
Definition: vector_typedefs.h:194
bool tct_bool
A bool.
Definition: target_code_types.h:85
float tct_float
A float.
Definition: target_code_types.h:65
void(void *result, Shading_state_environment const *state, Resource_data const *res_data, char const *arg_block_data) Environment_function
Signature of environment functions created via mi::neuraylib::IMdl_backend::translate_environment() a...
Definition: target_code_types.h:951
Df_handle_slot_mode
Type of Bsdf_evaluate_data variants, depending on the backend and its configuration.
Definition: target_code_types.h:793
mi::Float32_4_struct tct_float4
A float4.
Definition: target_code_types.h:74
mi::Float32_2_struct tct_float2
A float2.
Definition: target_code_types.h:68
Bsdf_event_type
The type of events created by BSDF importance sampling.
Definition: target_code_types.h:738
void(Edf_auxiliary_data_base *data, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data) Edf_auxiliary_function_with_derivs
Signature of the auxiliary function for material distribution functions created via mi::neuraylib::IM...
Definition: target_code_types.h:1420
void(Bsdf_auxiliary_data_base *data, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data) Bsdf_auxiliary_function
Signature of the auxiliary function for material distribution functions created via mi::neuraylib::IM...
Definition: target_code_types.h:1155
tct_traits<true>::tct_derivable_float tct_deriv_float
A float with derivatives.
Definition: target_code_types.h:120
void(void *result, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data) Material_expr_function
Signature of material expression functions created via mi::neuraylib::IMdl_backend::translate_materia...
Definition: target_code_types.h:966
void(Bsdf_evaluate_data_base *data, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data) Bsdf_evaluate_function_with_derivs
Signature of the evaluation function for material distribution functions created via mi::neuraylib::I...
Definition: target_code_types.h:1111
void(Edf_evaluate_data_base *data, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data) Edf_evaluate_function
Signature of the evaluation function for material distribution functions created via mi::neuraylib::I...
Definition: target_code_types.h:1346
void(Edf_auxiliary_data_base *data, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data) Edf_auxiliary_function
Signature of the auxiliary function for material distribution functions created via mi::neuraylib::IM...
Definition: target_code_types.h:1405
Mbsdf_part
MBSDFs can consist of two parts, which can be selected using this enumeration.
Definition: target_code_types.h:325
void(Shading_state_material *state, Resource_data const *res_data, char const *arg_block_data) Bsdf_init_function
Signature of the initialization function for material distribution functions created via mi::neurayli...
Definition: target_code_types.h:1034
Tex_wrap_mode
The texture wrap modes as defined by tex::wrap_mode in the MDL specification.
Definition: target_code_types.h:306
void(Bsdf_sample_data *data, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data) Bsdf_sample_function_with_derivs
Signature of the importance sampling function for material distribution functions created via mi::neu...
Definition: target_code_types.h:1081
void(Edf_sample_data *data, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data) Edf_sample_function_with_derivs
Signature of the importance sampling function for material distribution functions created via mi::neu...
Definition: target_code_types.h:1331
void(Shading_state_material_with_derivs *state, Resource_data const *res_data, char const *arg_block_data) Bsdf_init_function_with_derivs
Signature of the initialization function for material distribution functions created via mi::neurayli...
Definition: target_code_types.h:1051
mi::Float32_3_struct tct_float3
A float3.
Definition: target_code_types.h:71
void(Edf_evaluate_data_base *data, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data) Edf_evaluate_function_with_derivs
Signature of the evaluation function for material distribution functions created via mi::neuraylib::I...
Definition: target_code_types.h:1361
void(void *result, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data) Material_expr_function_with_derivs
Signature of material expression functions created via mi::neuraylib::IMdl_backend::translate_materia...
Definition: target_code_types.h:981
void(Bsdf_auxiliary_data_base *data, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data) Bsdf_auxiliary_function_with_derivs
Signature of the auxiliary function for material distribution functions created via mi::neuraylib::IM...
Definition: target_code_types.h:1170
void(Bsdf_sample_data *data, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data) Bsdf_sample_function
Signature of the importance sampling function for material distribution functions created via mi::neu...
Definition: target_code_types.h:1066
Edf_event_type
The type of events created by EDF importance sampling.
Definition: target_code_types.h:1174
mi::Sint32 tct_int
An int.
Definition: target_code_types.h:77
void(Edf_pdf_data *data, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data) Edf_pdf_function
Signature of the probability density function for material distribution functions created via mi::neu...
Definition: target_code_types.h:1376
mi::Uint32 tct_uint
An unsigned int.
Definition: target_code_types.h:80
void(Shading_state_material_with_derivs *state, Resource_data const *res_data, char const *arg_block_data) Edf_init_function_with_derivs
Signature of the initialization function for material distribution functions created via mi::neurayli...
Definition: target_code_types.h:1301
void(Bsdf_pdf_data *data, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data) Bsdf_pdf_function
Signature of the probability density function for material distribution functions created via mi::neu...
Definition: target_code_types.h:1126
Df_flags
Flags controlling the calculation of DF results.
Definition: target_code_types.h:763
tct_traits<true>::tct_derivable_float2 tct_deriv_float2
A float2 with derivatives.
Definition: target_code_types.h:123
void(Bsdf_evaluate_data_base *data, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data) Bsdf_evaluate_function
Signature of the evaluation function for material distribution functions created via mi::neuraylib::I...
Definition: target_code_types.h:1096
void(Edf_pdf_data *data, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data) Edf_pdf_function_with_derivs
Signature of the probability density function for material distribution functions created via mi::neu...
Definition: target_code_types.h:1391
void(Edf_sample_data *data, Shading_state_material const *state, Resource_data const *res_data, char const *arg_block_data) Edf_sample_function
Signature of the importance sampling function for material distribution functions created via mi::neu...
Definition: target_code_types.h:1316
void(Bsdf_pdf_data *data, Shading_state_material_with_derivs const *state, Resource_data const *res_data, char const *arg_block_data) Bsdf_pdf_function_with_derivs
Signature of the probability density function for material distribution functions created via mi::neu...
Definition: target_code_types.h:1141
tct_traits<true>::tct_derivable_float4 tct_deriv_float4
A float4 with derivatives.
Definition: target_code_types.h:129
void(Shading_state_material *state, Resource_data const *res_data, char const *arg_block_data) Edf_init_function
Signature of the initialization function for material distribution functions created via mi::neurayli...
Definition: target_code_types.h:1284
tct_traits<true>::tct_derivable_float3 tct_deriv_float3
A float3 with derivatives.
Definition: target_code_types.h:126
@ DF_HSM_POINTER
Uses renderer defined buffers; not supported by all backends.
Definition: target_code_types.h:794
@ DF_HSM_FIXED_2
fixed size array for processing 2 handle at a time
Definition: target_code_types.h:797
@ DF_HSM_NONE
No slots, handles are ignored completely.
Definition: target_code_types.h:795
@ DF_HSM_FIXED_8
fixed size array for processing 8 handle at a time
Definition: target_code_types.h:799
@ DF_HSM_FIXED_1
fixed size array for processing 1 handle at a time
Definition: target_code_types.h:796
@ DF_HSM_FIXED_4
fixed size array for processing 4 handle at a time
Definition: target_code_types.h:798
@ MBSDF_DATA_TRANSMISSION
the bidirectional transmission distribution function (BTDF)
Definition: target_code_types.h:330
@ MBSDF_DATA_REFLECTION
the bidirectional reflection distribution function (BRDF)
Definition: target_code_types.h:327
@ TEX_WRAP_CLIP
tex::wrap_clip: makes the texture lookup return zero for texture coordinates outside of the range
Definition: target_code_types.h:320
@ TEX_WRAP_MIRRORED_REPEAT
tex::wrap_mirrored_repeat: like wrap_repeat but takes one minus the fractional part every other inter...
Definition: target_code_types.h:316
@ TEX_WRAP_REPEAT
tex::wrap_repeat: takes the fractional part of the lookup coordinate effectively repeating the textur...
Definition: target_code_types.h:312
@ TEX_WRAP_CLAMP
tex::wrap_clamp: clamps the lookup coordinate to the range
Definition: target_code_types.h:308
@ DF_FLAGS_NONE
allows nothing -> black
Definition: target_code_types.h:764
Common namespace for APIs of NVIDIA Advanced Rendering Center GmbH.
Definition: neuraylib.h:179
Major and minor version number and an optional qualifier.
Generic storage class template for math vector representations storing DIM elements of type T.
Definition: vector.h:135
Input and output structure for BSDF auxiliary calculation data.
Definition: target_code_types.h:876
Input and output structure for BSDF evaluation data.
Definition: target_code_types.h:803
Input and output structure for BSDF PDF calculation data.
Definition: target_code_types.h:863
tct_float3 ior2
mutual input: IOR other side
Definition: target_code_types.h:865
Df_flags flags
input: flags controlling calculation of result (optional depending on backend options)
Definition: target_code_types.h:871
tct_float3 k2
input: incoming direction
Definition: target_code_types.h:868
tct_float3 ior1
mutual input: IOR current medium
Definition: target_code_types.h:864
tct_float pdf
output: pdf (non-projected hemisphere)
Definition: target_code_types.h:869
tct_float3 k1
mutual input: outgoing direction
Definition: target_code_types.h:866
Input and output structure for BSDF sampling data.
Definition: target_code_types.h:775
tct_float4 xi
input: pseudo-random sample numbers in range [0, 1)
Definition: target_code_types.h:781
tct_float pdf
output: pdf (non-projected hemisphere)
Definition: target_code_types.h:782
Df_flags flags
input: flags controlling calculation of result (optional depending on backend options)
Definition: target_code_types.h:787
tct_int handle
output: handle of the sampled elemental BSDF (lobe)
Definition: target_code_types.h:785
tct_float3 ior2
mutual input: IOR other side
Definition: target_code_types.h:777
tct_float3 k1
mutual input: outgoing direction
Definition: target_code_types.h:778
tct_float3 k2
output: incoming direction
Definition: target_code_types.h:780
Bsdf_event_type event_type
output: the type of event for the generated sample
Definition: target_code_types.h:784
tct_float3 ior1
mutual input: IOR current medium
Definition: target_code_types.h:776
tct_float3 bsdf_over_pdf
output: bsdf * dot(normal, k2) / pdf
Definition: target_code_types.h:783
Input and output structure for EDF auxiliary calculation data.
Definition: target_code_types.h:1237
Input and output structure for EDF evaluation data.
Definition: target_code_types.h:1193
Input and output structure for EDF PDF calculation data.
Definition: target_code_types.h:1231
tct_float pdf
output: pdf (non-projected hemisphere)
Definition: target_code_types.h:1233
tct_float3 k1
input: outgoing direction
Definition: target_code_types.h:1232
Input and output structure for EDF sampling data.
Definition: target_code_types.h:1183
tct_int handle
output: handle of the sampled elemental EDF (lobe)
Definition: target_code_types.h:1189
tct_float3 k1
output: outgoing direction
Definition: target_code_types.h:1185
tct_float3 edf_over_pdf
output: edf * dot(normal,k1) / pdf
Definition: target_code_types.h:1187
tct_float pdf
output: pdf (non-projected hemisphere)
Definition: target_code_types.h:1186
tct_float4 xi
input: pseudo-random sample numbers in range [0, 1)
Definition: target_code_types.h:1184
Edf_event_type event_type
output: the type of event for the generated sample
Definition: target_code_types.h:1188
The data structure providing access to resources for generated code.
Definition: target_code_types.h:730
void const * shared_data
currently unused, should be nullptr
Definition: target_code_types.h:731
Texture_handler_base const * texture_handler
will be provided as "self" parameter to texture functions
Definition: target_code_types.h:732
The MDL environment state structure inside the MDL SDK is a representation of the renderer state in t...
Definition: target_code_types.h:155
tct_float3 direction
The result of state::direction().
Definition: target_code_types.h:158
char const * ro_data_segment
A pointer to a read-only data segment.
Definition: target_code_types.h:173
The MDL material state structure inside the MDL SDK is a representation of the renderer state as defi...
Definition: target_code_types.h:206
tct_float3 normal
The result of state::normal().
Definition: target_code_types.h:213
char const * ro_data_segment
A pointer to a read-only data segment.
Definition: target_code_types.h:267
tct_int object_id
The result of state::object_id().
Definition: target_code_types.h:287
traits::tct_derivable_float3 position
The result of state::position().
Definition: target_code_types.h:221
tct_float4 const * world_to_object
A 4x4 transformation matrix in row-major order transforming from world to object coordinates.
Definition: target_code_types.h:274
tct_float3 const * tangent_v
An array containing the results of state::texture_tangent_v(i).
Definition: target_code_types.h:244
tct_float4 const * object_to_world
A 4x4 transformation matrix in row-major order transforming from object to world coordinates.
Definition: target_code_types.h:281
traits::tct_derivable_float3 const * text_coords
An array containing the results of state::texture_coordinate(i).
Definition: target_code_types.h:230
tct_float animation_time
The result of state::animation_time().
Definition: target_code_types.h:225
tct_float3 geom_normal
The result of state::geometry_normal().
Definition: target_code_types.h:217
tct_float3 const * tangent_u
An array containing the results of state::texture_tangent_u(i).
Definition: target_code_types.h:237
tct_float meters_per_scene_unit
The result of state::meters_per_scene_unit().
Definition: target_code_types.h:292
tct_float4 * text_results
The texture results lookup table.
Definition: target_code_types.h:252
The texture handler structure that is passed to the texturing functions.
Definition: target_code_types.h:711
Texture_handler_vtable const * vtable
In vtable-mode, the vtable field is used to call the texturing functions.
Definition: target_code_types.h:714
The texture handler structure that is passed to the texturing functions with derivative support.
Definition: target_code_types.h:721
Texture_handler_deriv_vtable const * vtable
In vtable-mode, the vtable field is used to call the texturing functions.
Definition: target_code_types.h:724
The runtime for bitmap texture access for the generated target code can optionally be implemented in ...
Definition: target_code_types.h:342
A template struct with derivatives.
Definition: target_code_types.h:91
Helper traits struct to switch between derivative and non-derivative types.
Definition: target_code_types.h:97
Typedefs for types from the math API.