77 unsigned char basetype;
78 unsigned char aggregate;
79 unsigned char vecsemantics;
80 unsigned char reserved;
85 VECSEMANTICS v = NOSEMANTICS,
87 : basetype(
b), aggregate(a), vecsemantics(
v), reserved(0), arraylen(
l)
93 return basetype == other.basetype && aggregate == other.aggregate &&
94 vecsemantics == other.vecsemantics && arraylen == other.arraylen;
99 return !(*
this == other);
113 return (t.basetype == TypeDesc::FLOAT && t.aggregate == TypeDesc::VEC2 && t.arraylen == 0) ||
114 t == TypeDesc(TypeDesc::FLOAT, TypeDesc::SCALAR, TypeDesc::NOSEMANTICS, 2);
119 return (t.basetype == TypeDesc::FLOAT && t.aggregate == TypeDesc::VEC3 && t.arraylen == 0) ||
120 t == TypeDesc(TypeDesc::FLOAT, TypeDesc::SCALAR, TypeDesc::NOSEMANTICS, 3);
125 return (t.basetype == TypeDesc::FLOAT && t.aggregate == TypeDesc::VEC4 && t.arraylen == 0) ||
126 t == TypeDesc(TypeDesc::FLOAT, TypeDesc::SCALAR, TypeDesc::NOSEMANTICS, 4);
131 return (t.basetype == TypeDesc::INT && t.aggregate == TypeDesc::VEC2 && t.arraylen == 0) ||
132 t == TypeDesc(TypeDesc::INT, TypeDesc::SCALAR, TypeDesc::NOSEMANTICS, 2);
137 return (t.basetype == TypeDesc::INT && t.aggregate == TypeDesc::VEC3 && t.arraylen == 0) ||
138 t == TypeDesc(TypeDesc::INT, TypeDesc::SCALAR, TypeDesc::NOSEMANTICS, 3);
239 const int object = sd->object;
253 const int object = sd->object;
255#ifdef __OBJECT_MOTION__
257 if (time == sd->time) {
276 const int object = sd->object;
288 const int object = sd->object;
290#ifdef __OBJECT_MOTION__
292 if (time == sd->time) {
311 if (from == DeviceStrings::u_ndc) {
315 if (from == DeviceStrings::u_raster) {
319 if (from == DeviceStrings::u_screen) {
323 if (from == DeviceStrings::u_camera) {
327 if (from == DeviceStrings::u_world) {
338 if (to == DeviceStrings::u_ndc) {
342 if (to == DeviceStrings::u_raster) {
346 if (to == DeviceStrings::u_screen) {
350 if (to == DeviceStrings::u_camera) {
354 if (to == DeviceStrings::u_world) {
376 if (type == TypeFloat) {
397 if (type == TypeFloat) {
418 if (type == TypeFloat) {
439 if (type == TypeFloat) {
459 if (type == TypeFloat) {
480 if (type == TypeInt) {
495#ifndef __KERNEL_GPU__
501 if (type == TypeString) {
521 if (type == TypeMatrix) {
534 if (type.vecsemantics == TypeDesc::POINT && type.arraylen >= 3) {
541 if (type.arraylen > 3) {
542 for (
int i = 3 * 3; i < type.arraylen * 3; i++) {
547 for (
int i = type.arraylen * 3; i < type.arraylen * 3 * 3; i++) {
570 float3 Ng = backfacing ? -sd->Ng : sd->Ng;
575 kg, Ng, sd->object, sd->object_flag, sd->prim, sd->u, sd->v, sd->du, sd->dv, f.dx, f.dy);
580 kg, Ng, sd->object, sd->prim, sd->time, sd->u, sd->v, sd->du, sd->dv, f.dx, f.dy);
627 result.x = missingcolor[0];
630 result.y = missingcolor[1];
633 result.z = missingcolor[2];
636 result.w = missingcolor[3];
646 result[0] = missingcolor[0];
649 result[1] = missingcolor[1];
652 result[2] = missingcolor[2];
655 result[3] = missingcolor[3];
664 const TypeDesc datatype,
674 int image_texture_id = image_texture_or_udim_id;
688 if (dataname == DeviceStrings::u_resolution) {
690 int *res =
static_cast<int *
>(data);
691 res[0] = int(tex.width);
692 res[1] = int(tex.height);
696 float *res =
static_cast<float *
>(data);
697 res[0] =
float(tex.width);
698 res[1] =
float(tex.height);
702 int *res =
static_cast<int *
>(data);
703 res[0] = int(tex.width);
704 res[1] = int(tex.height);
709 float *res =
static_cast<float *
>(data);
710 res[0] =
float(tex.width);
711 res[1] =
float(tex.height);
716 else if (dataname == DeviceStrings::u_channels) {
717 if (datatype == TypeInt) {
718 const int image_info_id = tex.image_info_id;
721 switch (info.data_type) {
745 *
static_cast<int *
>(data) = channels;
749 else if (dataname == DeviceStrings::u_exists) {
750 if (datatype == TypeInt) {
751 *
static_cast<int *
>(data) = 1;
755 else if (dataname == DeviceStrings::u_averagecolor) {
757 float *res = (
float *)data;
758 res[0] = tex.average_color.x;
759 res[1] = tex.average_color.y;
760 res[2] = tex.average_color.z;
762 res[3] = tex.average_color.w;
792 const dual2 uv({s, t}, {dsdx, dtdx}, {dsdy, dtdy});
794 kg, sd, image_texture_or_udim_id, uv,
get_missingcolor(opt->missingcolor, nchannels));
809#if !defined(__KERNEL_GPU__) && defined(__SHADER_RAYTRACE__)
812 if (nchannels >= 3 &&
state !=
nullptr) {
813 const int num_samples = int(s);
814 const float radius = t;
815 const float3 N = svm_bevel(kg,
state, sd, radius, num_samples);
822 if (nchannels >= 3) {
832#if !defined(__KERNEL_GPU__) && defined(__SHADER_RAYTRACE__)
835 if (
state !=
nullptr) {
836 const int num_samples = int(s);
837 const float radius = t;
849 result[0] = svm_ao(kg,
state, sd,
N, radius, num_samples, flags);
861 if (opt->missingcolor) {
889 const float4 rgba = kernel_image_interp_3d(
922 const dual3 R_dual(
R, dRdx, dRdy);
926 kg, sd, image_texture_or_udim_id, uv,
get_missingcolor(opt->missingcolor, nchannels));
931 if (opt->missingcolor) {
949 if (name == DeviceStrings::u_scene_time) {
952 if (name == DeviceStrings::u_scene_frame) {
970 if (primitive_is_volume_attribute(sd)) {
971 data.val = primitive_volume_attribute<T>(kg, sd, desc,
true);
1021 const TypeDesc type,
1025#ifdef __KERNEL_GPU__
1028# define READ_PATH_STATE(elem) \
1029 ((state != -1) ? INTEGRATOR_STATE(state, path, elem) : \
1030 (shadow_state != -1) ? INTEGRATOR_STATE(shadow_state, shadow_path, elem) : \
1035# define READ_PATH_STATE(elem) \
1036 ((state != nullptr) ? state->path.elem : \
1037 (shadow_state != nullptr) ? shadow_state->shadow_path.elem : \
1041 if (name == DeviceStrings::u_path_ray_length) {
1043 const float f = sd->ray_length;
1046 if (name == DeviceStrings::u_path_ray_depth) {
1061 if (name == DeviceStrings::u_path_diffuse_depth) {
1066 if (name == DeviceStrings::u_path_glossy_depth) {
1071 if (name == DeviceStrings::u_path_transmission_depth) {
1076 if (name == DeviceStrings::u_path_transparent_depth) {
1081 if (name == DeviceStrings::u_path_portal_depth) {
1087#undef READ_PATH_STATE
1089 if (name == DeviceStrings::u_ndc) {
1120 const TypeDesc type,
1125 if (name == DeviceStrings::u_object_location) {
1129 if (name == DeviceStrings::u_object_color) {
1133 if (name == DeviceStrings::u_object_alpha) {
1137 if (name == DeviceStrings::u_object_index) {
1141 if (name == DeviceStrings::u_object_is_light) {
1145 if (name == DeviceStrings::u_geom_dupli_generated) {
1149 if (name == DeviceStrings::u_geom_dupli_uv) {
1153 if (name == DeviceStrings::u_material_index) {
1157 if (name == DeviceStrings::u_object_random) {
1163 if (name == DeviceStrings::u_particle_index) {
1168 if (name == DeviceStrings::u_particle_random) {
1173 if (name == DeviceStrings::u_particle_age) {
1178 if (name == DeviceStrings::u_particle_lifetime) {
1183 if (name == DeviceStrings::u_particle_location) {
1189 if (name == DeviceStrings::u_particle_rotation) {
1195 if (name == DeviceStrings::u_particle_size) {
1200 if (name == DeviceStrings::u_particle_velocity) {
1205 if (name == DeviceStrings::u_particle_angular_velocity) {
1212 if (name == DeviceStrings::u_geom_numpolyvertices) {
1215 if ((name == DeviceStrings::u_geom_trianglevertices ||
1216 name == DeviceStrings::u_geom_polyvertices) &&
1236#ifndef __KERNEL_GPU__
1237 if (name == DeviceStrings::u_geom_name) {
1238 const ustring object_name = kg->osl.globals->object_names[sd->object];
1242 if (name == DeviceStrings::u_is_smooth) {
1248 if (name == DeviceStrings::u_is_curve) {
1252 if (name == DeviceStrings::u_curve_thickness) {
1253 const float f = curve_thickness(kg, sd);
1256 if (name == DeviceStrings::u_curve_tangent_normal) {
1257 const float3 f = curve_tangent_normal(sd);
1260 if (name == DeviceStrings::u_curve_random) {
1261 const float f = curve_random(kg, sd);
1265#ifdef __POINTCLOUD__
1267 if (name == DeviceStrings::u_is_point) {
1271 if (name == DeviceStrings::u_point_radius) {
1272 const float f = point_radius(kg, sd);
1275 if (name == DeviceStrings::u_point_position) {
1276 const float3 f = point_position(kg, sd);
1279 if (name == DeviceStrings::u_point_random) {
1280 const float f = point_random(kg, sd);
1284 if (name == DeviceStrings::u_normal_map_normal) {
1296 if (name == DeviceStrings::u_bump_map_normal) {
1303#if defined(__GSPLATS__)
1305 if (sd->type &
PRIMITIVE_GSPLAT && name == DeviceStrings::u_geom_radiance) {
1306 const float3 radiance = gsplat_radiance(kg, *sd);
1318 const TypeDesc type,
1322 if (name == DeviceStrings::u_sensor_size) {
1326 if (name == DeviceStrings::u_image_resolution) {
1330 if (name == DeviceStrings::u_aperture_aspect_ratio) {
1333 if (name == DeviceStrings::u_aperture_size) {
1336 if (name == DeviceStrings::u_aperture_position) {
1342 if (name == DeviceStrings::u_focal_distance) {
ccl_device float2 direction_to_equirectangular(const float3 dir)
ccl_device_forceinline float4 kernel_image_interp_with_udim(KernelGlobals kg, ccl_private ShaderData *sd, const int udim_id, dual2 uv, const float4 missing_rgba)
ccl_device_inline ProjectionTransform projection_identity()
#define kernel_assert(cond)
#define ccl_device_forceinline
#define kernel_data_fetch(name, index)
#define ccl_device_inline
#define OSL_RAYTYPE_TO_VISIBILITY(raytype)
#define ccl_device_template_spec
#define OSL_RAYTYPE_TO_PARTIAL_PATH_FLAG(raytype)
#define ccl_device_inline_method
#define ccl_device_constant
#define CCL_NAMESPACE_END
ccl_device_forceinline differential3 differential_from_compact(const float3 D, const float dD)
ccl_device_inline float3 triangle_smooth_normal(KernelGlobals kg, float3 Ng, int object, int object_flag, int prim, float u, float v)
ccl_device_inline float3 triangle_smooth_normal_unnormalized_object_space(KernelGlobals kg, ccl_private const ShaderData *sd)
ccl_device_inline void triangle_vertices(KernelGlobals kg, const int object, const int prim, float3 P[3])
float hash_uint2_to_float(uint kx, uint ky)
#define image(slot, qualifiers, format)
CCL_NAMESPACE_BEGIN ccl_device_forceinline int kernel_image_udim_map(KernelGlobals kg, const int id, ccl_private float2 &uv)
CCL_NAMESPACE_BEGIN ccl_device float2 camera_sample_aperture(ccl_constant KernelCamera *cam, const float2 rand)
ccl_device_inline float3 camera_world_to_ndc(KernelGlobals kg, ccl_private ShaderData *sd, float3 P)
CCL_NAMESPACE_BEGIN ccl_device_forceinline bool is_attribute_found(const ccl_private AttributeDescriptor &desc)
ccl_device Transform primitive_attribute_matrix(KernelGlobals kg, const AttributeDescriptor desc)
ccl_device_inline AttributeDescriptor find_attribute(const ccl_global AttributeMap *attributes_map, uint attr_offset, const int prim, const uint64_t id)
ccl_device_inline float3 object_dupli_uv(KernelGlobals kg, const int object)
ccl_device_inline int object_particle_id(KernelGlobals kg, const int object)
ccl_device int shader_pass_id(KernelGlobals kg, const ccl_private ShaderData *sd)
ccl_device_inline Transform object_get_inverse_transform(KernelGlobals kg, const ccl_private ShaderData *sd)
ccl_device float4 particle_rotation(KernelGlobals kg, const int particle)
ccl_device float3 particle_location(KernelGlobals kg, const int particle)
ccl_device float particle_lifetime(KernelGlobals kg, const int particle)
ccl_device float particle_age(KernelGlobals kg, const int particle)
ccl_device_inline uint particle_index(KernelGlobals kg, const int particle)
ccl_device_inline float3 object_color(KernelGlobals kg, const int object)
ccl_device_inline Transform object_get_transform(KernelGlobals kg, const ccl_private ShaderData *sd)
ccl_device float3 particle_velocity(KernelGlobals kg, const int particle)
ccl_device_inline float object_alpha(KernelGlobals kg, const int object)
ccl_device float3 particle_angular_velocity(KernelGlobals kg, const int particle)
ccl_device_inline float3 object_dupli_generated(KernelGlobals kg, const int object)
ccl_device_inline float object_pass_id(KernelGlobals kg, const int object)
ccl_device float particle_size(KernelGlobals kg, const int particle)
ccl_device_inline void object_position_transform(KernelGlobals kg, const ccl_private ShaderData *sd, ccl_private T *P)
ccl_device_inline void object_inverse_normal_transform(KernelGlobals kg, const ccl_private ShaderData *sd, ccl_private float3 *N)
ccl_device_inline float3 object_location(KernelGlobals kg, const ccl_private ShaderData *sd)
ccl_device_inline Transform object_fetch_transform_motion_test(KernelGlobals kg, const int object, const float time, ccl_private Transform *itfm)
ccl_device_inline float object_random_number(KernelGlobals kg, const int object)
#define OSL_TEXTURE_HANDLE_TYPE(handle)
#define OSL_TEXTURE_HANDLE_ID(handle)
const char * DeviceString
@ PRIMITIVE_MOTION_TRIANGLE
@ PATH_RAY_VISIBILITY_CAMERA
@ PATH_RAY_VISIBILITY_SHADOW
@ SD_OBJECT_TRANSFORM_APPLIED
@ ATTR_STD_NORMAL_UNDISPLACED
ccl_device_inline float kernel_ies_interp(KernelGlobals kg, const int slot, const float h_angle, const float v_angle)
ccl_device_inline bool operator!=(const float2 a, const float2 b)
ccl_device_inline bool operator==(const float2 a, const float2 b)
ccl_device_inline void copy_v3_v3(ccl_private float *r, const float3 val)
ccl_device_inline void copy_v4_v4(ccl_private float *r, const float4 val)
CCL_NAMESPACE_BEGIN ccl_device_inline float4 zero_float4()
ccl_device_inline void copy_v4_qt(ccl_private float *r, const Quaternion val)
#define KERNEL_IMAGE_NONE
#define IMAGE_MISSING_RGBA
ccl_device_inline void motion_triangle_vertices(KernelGlobals kg, const int object, const uint3 tri_vindex, const int numsteps, const int numverts, const int step, const float t, float3 verts[3])
ccl_device_inline float3 motion_triangle_smooth_normal(KernelGlobals kg, const float3 Ng, const int object, const int prim, const uint3 tri_vindex, const int numsteps, const int step, const float t, const float u, const float v)
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert * v
OSL::ustringhash OSLUStringHash
CCL_NAMESPACE_BEGIN ccl_device_forceinline T primitive_surface_attribute(KernelGlobals kg, const ccl_private ShaderData *sd, const AttributeDescriptor desc)
ccl_device_forceinline void rgba_to_nchannels(const float4 rgba, const int nchannels, ccl_private float *result)
ccl_device_forceinline void copy_matrix(ccl_private float *res, const Transform &tfm)
ccl_device_forceinline float4 get_missingcolor(const float *missingcolor, const int nchannels)
ccl_device_inline bool osl_shared_get_object_standard_attribute(KernelGlobals kg, ccl_private ShaderGlobals *sg, ccl_private ShaderData *sd, DeviceString name, const TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_inline bool is_type_float4(const TypeDesc t)
ccl_device_inline bool osl_shared_get_scene_attribute(KernelGlobals kg, DeviceString name, const TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_inline bool is_type_float3(const TypeDesc t)
ccl_device_inline void set_data_float3(const dual3 data, bool derivatives, ccl_private void *val)
ccl_device_inline void set_data_quaternion(const dual< Quaternion > data, bool derivatives, ccl_private void *val)
ccl_device bool attribute_bump_map_normal(KernelGlobals kg, ccl_private const ShaderData *sd, ccl_private dual3 &f)
ccl_device_inline void set_data_float4(const dual4 data, bool derivatives, ccl_private void *val)
ccl_device_inline bool osl_shared_get_object_inverse_matrix_motion(KernelGlobals kg, ccl_private const ShaderData *sd, ccl_private float *res, float time)
ccl_device_inline bool osl_shared_get_named_matrix(KernelGlobals kg, DeviceString from, ccl_private float *res)
ccl_device_inline bool osl_shared_get_object_matrix_motion(KernelGlobals kg, ccl_private const ShaderData *sd, ccl_private float *res, float time)
ccl_device_inline void set_data_float(const dual1 data, bool derivatives, ccl_private void *val)
ccl_device bool osl_shared_environment(KernelGlobals kg, ccl_private ShaderGlobals *sg, ccl_private void *texture_handle, ccl_private OSLTextureOptions *opt, float3 R, float3 dRdx, float3 dRdy, int nchannels, float *result)
ccl_device bool osl_shared_get_texture_info(KernelGlobals kg, ccl_private void *texture_handle, const float2 uv, const bool use_uv, DeviceString dataname, const TypeDesc datatype, void *data)
ccl_device_inline bool is_type_int3(const TypeDesc t)
ccl_device_inline bool osl_shared_get_camera_attribute(KernelGlobals kg, ccl_private ShaderGlobals *sg, DeviceString name, const TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_inline bool set_attribute(const dual< T > v, const TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_inline bool set_attribute_matrix(const Transform &tfm, const TypeDesc type, ccl_private void *val)
ccl_device_inline bool osl_shared_get_background_attribute(KernelGlobals kg, ccl_private ShaderGlobals *sg, ccl_private ShaderData *sd, DeviceString name, const TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_inline bool osl_shared_get_object_matrix(KernelGlobals kg, ccl_private const ShaderData *sd, ccl_private float *res)
ccl_device_inline bool is_type_int2(const TypeDesc t)
#define READ_PATH_STATE(elem)
ccl_device bool osl_shared_texture3d(KernelGlobals kg, ccl_private ShaderGlobals *sg, ccl_private void *texture_handle, float3 P, float3, float3, float3, int nchannels, float *result)
ccl_device_inline bool osl_shared_get_object_attribute(KernelGlobals kg, ccl_private ShaderData *sd, const AttributeDescriptor &desc, const TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device bool osl_shared_texture(KernelGlobals kg, ccl_private ShaderGlobals *sg, ccl_private void *texture_handle, ccl_private OSLTextureOptions *opt, float s, float t, float dsdx, float dtdx, float dsdy, float dtdy, int nchannels, float *result)
ccl_device_inline bool osl_shared_get_named_inverse_matrix(KernelGlobals kg, DeviceString to, ccl_private float *res)
ccl_device_inline bool osl_shared_get_object_inverse_matrix(KernelGlobals kg, ccl_private const ShaderData *sd, ccl_private float *res)
ccl_device_inline bool osl_shared_get_object_attribute_impl(KernelGlobals kg, ccl_private ShaderData *sd, const AttributeDescriptor &desc, const TypeDesc type, bool derivatives, ccl_private void *val)
CCL_NAMESPACE_BEGIN ccl_device_inline bool is_type_float2(const TypeDesc t)
ccl_device_inline bool set_attribute_float3_3(const float3 P[3], TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_forceinline void missingcolor_to_nchannels(const float *missingcolor, const int nchannels, ccl_private float *result)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
const IntegratorShadowStateCPU * ConstIntegratorShadowState
const IntegratorStateCPU * ConstIntegratorState
@ IMAGE_DATA_TYPE_NANOVDB_FP16
@ IMAGE_DATA_TYPE_USHORT4
@ IMAGE_DATA_TYPE_NANOVDB_EMPTY
@ IMAGE_DATA_TYPE_NANOVDB_FLOAT
@ IMAGE_DATA_TYPE_NANOVDB_FLOAT3
@ IMAGE_DATA_TYPE_NANOVDB_FLOAT4
@ IMAGE_DATA_TYPE_NANOVDB_FPN