159 ccl_private uint8_t *closure_pool = sg->closure_pool;
161 closure_pool =
reinterpret_cast<uint8_t *
>(
162 (
reinterpret_cast<size_t>(closure_pool) +
alignof(OSLClosureMul) - 1) &
163 (-
alignof(OSLClosureMul)));
164 sg->closure_pool = closure_pool +
sizeof(OSLClosureMul);
169 closure->weight = *weight;
170 closure->closure = a;
179 if (weight == 0.0f || !a) {
182 else if (weight == 1.0f) {
186 ccl_private uint8_t *closure_pool = sg->closure_pool;
188 closure_pool =
reinterpret_cast<uint8_t *
>(
189 (
reinterpret_cast<size_t>(closure_pool) +
alignof(OSLClosureMul) - 1) &
190 (-
alignof(OSLClosureMul)));
191 sg->closure_pool = closure_pool +
sizeof(OSLClosureMul);
196 closure->weight =
make_float3(weight, weight, weight);
197 closure->closure = a;
213 ccl_private uint8_t *closure_pool = sg->closure_pool;
215 closure_pool =
reinterpret_cast<uint8_t *
>(
216 (
reinterpret_cast<size_t>(closure_pool) +
alignof(OSLClosureAdd) - 1) &
217 (-
alignof(OSLClosureAdd)));
218 sg->closure_pool = closure_pool +
sizeof(OSLClosureAdd);
223 closure->closureA = a;
224 closure->closureB =
b;
232 ccl_private uint8_t *closure_pool = sg->closure_pool;
234 closure_pool =
reinterpret_cast<uint8_t *
>(
235 (
reinterpret_cast<size_t>(closure_pool) +
alignof(OSLClosureComponent) - 1) &
236 (-
alignof(OSLClosureComponent)));
237 sg->closure_pool = closure_pool +
sizeof(OSLClosureComponent) +
size;
240 reinterpret_cast<ccl_private OSLClosureComponent *
>(closure_pool);
250 ccl_private uint8_t *closure_pool = sg->closure_pool;
252 closure_pool =
reinterpret_cast<uint8_t *
>(
253 (
reinterpret_cast<size_t>(closure_pool) +
alignof(OSLClosureComponent) - 1) &
254 (-
alignof(OSLClosureComponent)));
255 sg->closure_pool = closure_pool +
sizeof(OSLClosureComponent) +
size;
258 reinterpret_cast<ccl_private OSLClosureComponent *
>(closure_pool);
260 closure->weight = *weight;
289 const int sourceline,
295 const int result = indexvalue < 0 ? 0 : indexvalue >=
length ?
length - 1 : indexvalue;
297 if (
result != indexvalue) {
298 printf(
"Index [%d] out of range\n", indexvalue);
356 int object = sd->object;
395 int object = sd->object;
436 const float v,
const float dx,
const float dy,
bool derivatives,
ccl_private void *val)
490 const unsigned char type_basetype = type & 0xFF;
491 const unsigned char type_aggregate = (type >> 8) & 0xFF;
492 const int type_arraylen = type >> 32;
494 if (type_basetype == 11 ) {
495 if ((type_aggregate == 3 ) || (type_aggregate == 1 && type_arraylen == 3))
500 if ((type_aggregate == 4 ) || (type_aggregate == 1 && type_arraylen == 4))
509 if ((type_aggregate == 1 )) {
524 const unsigned char type_basetype = type & 0xFF;
525 const unsigned char type_aggregate = (type >> 8) & 0xFF;
526 const int type_arraylen = type >> 32;
528 if (type_basetype == 11 ) {
529 if ((type_aggregate == 3 ) || (type_aggregate == 1 && type_arraylen == 3))
534 if ((type_aggregate == 4 ) || (type_aggregate == 1 && type_arraylen == 4))
542 if ((type_aggregate == 1 )) {
557 const unsigned char type_basetype = type & 0xFF;
558 const unsigned char type_aggregate = (type >> 8) & 0xFF;
559 const int type_arraylen = type >> 32;
561 if (type_basetype == 11 ) {
562 if ((type_aggregate == 3 ) || (type_aggregate == 1 && type_arraylen == 3))
567 if ((type_aggregate == 4 ) || (type_aggregate == 1 && type_arraylen == 4))
573 if ((type_aggregate == 1 )) {
588 const unsigned char type_basetype = type & 0xFF;
589 const unsigned char type_aggregate = (type >> 8) & 0xFF;
590 const int type_arraylen = type >> 32;
592 if (type_basetype == 11 ) {
593 if ((type_aggregate == 3 ) || (type_aggregate == 1 && type_arraylen == 3))
598 if ((type_aggregate == 4 ) || (type_aggregate == 1 && type_arraylen == 4))
603 if ((type_aggregate == 1 )) {
629 const unsigned char type_basetype = type & 0xFF;
630 const unsigned char type_aggregate = (type >> 8) & 0xFF;
632 if (type_basetype == 11 && type_aggregate == 16 ) {
647 const unsigned char type_basetype = type & 0xFF;
648 const unsigned char type_aggregate = (type >> 8) & 0xFF;
649 const int type_arraylen = type >> 32;
651 if ((type_basetype == 7 ) && (type_aggregate == 1 ) &&
679 float f = sd->ray_length;
683#define READ_PATH_STATE(elem) \
684 ((state != -1) ? INTEGRATOR_STATE(state, path, elem) : \
685 (shadow_state != -1) ? INTEGRATOR_STATE(shadow_state, shadow_path, elem) : \
721#undef READ_PATH_STATE
747 return set_attribute(ndc[0], ndc[1], ndc[2], type, derivatives, val);
765 if (primitive_is_volume_attribute(sd, desc)) {
766 v = primitive_volume_attribute<T>(kg, sd, desc);
772 kg, sd, desc, derivatives ? &dx :
nullptr, derivatives ? &dy :
nullptr);
882 return set_attribute4(f, type, derivatives, val);
926 float f = curve_thickness(kg, sd);
930 float3 f = curve_tangent_normal(kg, sd);
934 float f = curve_random(kg, sd);
946 float f = point_radius(kg, sd);
950 float3 f = point_position(kg, sd);
954 float f = point_random(kg, sd);
973 return set_attribute(f[0], f[1], f[2], type, derivatives, val);
1013 const int derivatives,
1016 const int array_lookup,
1025 if (sd ==
nullptr) {
1035 object = sd->object;
1069#ifdef __KERNEL_OPTIX__
1071 *ptr_data = kernel_params.osl_colorsystem;
1090 const int nchannels,
1102 if (nchannels > 0) {
1105 if (nchannels > 1) {
1108 if (nchannels > 2) {
1111 if (nchannels > 3) {
1117 if (nchannels > 0) {
1137 const int nchannels,
1150 if (nchannels > 0) {
1153 if (nchannels > 1) {
1156 if (nchannels > 2) {
1159 if (nchannels > 3) {
1178 const int nchannels,
1184 if (nchannels > 0) {
1187 if (nchannels > 1) {
1190 if (nchannels > 2) {
1193 if (nchannels > 3) {
1290#if (OSL_LIBRARY_VERSION_CODE >= 11405) || (OSL_LIBRARY_VERSION_CODE < 11403)
1292 const int firstchannel)
1386 const int nchannels,
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMVert * v
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
static DBVT_INLINE btDbvtNode * sort(btDbvtNode *n, btDbvtNode *&r)
ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals kg, const int id, float3 P, InterpolationType interp)
ccl_device float4 kernel_tex_image_interp(KernelGlobals kg, const int id, const float x, float y)
ccl_device_inline ProjectionTransform projection_identity()
CCL_NAMESPACE_BEGIN struct Options options
#define kernel_assert(cond)
#define ccl_device_forceinline
const ThreadKernelGlobalsCPU * KernelGlobals
#define ccl_device_inline
#define ccl_device_extern
#define ccl_device_template_spec
#define ccl_device_constant
ccl_device_forceinline differential3 differential_from_compact(const float3 D, const float dD)
ccl_device_inline float3 triangle_smooth_normal_unnormalized(KernelGlobals kg, const ccl_private ShaderData *sd, const float3 Ng, const int prim, const float u, float v)
VecBase< float, 4 > float4
float length(VecOp< float, D >) RET
ccl_device_inline float hash_uint2_to_float(const uint kx, const uint ky)
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_device Transform primitive_attribute_matrix(KernelGlobals kg, const AttributeDescriptor desc)
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 float3 object_location(KernelGlobals kg, const ccl_private ShaderData *sd)
ccl_device_inline float object_random_number(KernelGlobals kg, const int object)
#define OSL_TEXTURE_HANDLE_SLOT(handle)
#define OSL_TEXTURE_HANDLE_TYPE(handle)
#define OSL_TEXTURE_HANDLE_TYPE_SVM
#define OSL_TEXTURE_HANDLE_TYPE_IES
const char * DeviceString
ccl_device_inline float kernel_ies_interp(KernelGlobals kg, const int slot, const float h_angle, const float v_angle)
ccl_device_inline T make_zero()
ccl_device_inline float average(const float2 a)
ccl_device_inline float3 one_float3()
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
ccl_device_constant DeviceString u_particle_rotation
ccl_device_constant DeviceString u_point_position
ccl_device_constant DeviceString u_path_transparent_depth
ccl_device_constant DeviceString u_object_color
ccl_device_constant DeviceString u_is_point
ccl_device_constant DeviceString u_particle_lifetime
ccl_device_constant DeviceString u_geom_numpolyvertices
ccl_device_constant DeviceString u_sensor_size
ccl_device_constant DeviceString u_is_curve
ccl_device_constant DeviceString u_material_index
ccl_device_constant DeviceString u_aperture_size
ccl_device_constant DeviceString u_point_radius
ccl_device_constant DeviceString u_aperture_position
ccl_device_constant DeviceString u_particle_location
ccl_device_constant DeviceString u_object_is_light
ccl_device_constant DeviceString u_path_ray_length
ccl_device_constant DeviceString u_path_diffuse_depth
ccl_device_constant DeviceString u_path_transmission_depth
ccl_device_constant DeviceString u_geom_dupli_uv
ccl_device_constant DeviceString u_colorsystem
ccl_device_constant DeviceString u_aperture_aspect_ratio
ccl_device_constant DeviceString u_object_location
ccl_device_constant DeviceString u_focal_distance
ccl_device_constant DeviceString u_particle_age
ccl_device_constant DeviceString u_screen
ccl_device_constant DeviceString _emptystring_
ccl_device_constant DeviceString u_is_smooth
ccl_device_constant DeviceString u_normal_map_normal
ccl_device_constant DeviceString u_path_ray_depth
ccl_device_constant DeviceString u_path_glossy_depth
ccl_device_constant DeviceString u_world
ccl_device_constant DeviceString u_object_alpha
ccl_device_constant DeviceString u_object
ccl_device_constant DeviceString u_particle_velocity
ccl_device_constant DeviceString u_raster
ccl_device_constant DeviceString u_image_resolution
ccl_device_constant DeviceString u_common
ccl_device_constant DeviceString u_camera
ccl_device_constant DeviceString u_curve_length
ccl_device_constant DeviceString u_particle_index
ccl_device_constant DeviceString u_particle_size
ccl_device_constant DeviceString u_bump_map_normal
ccl_device_constant DeviceString u_point_random
ccl_device_constant DeviceString u_geom_dupli_generated
ccl_device_constant DeviceString u_particle_angular_velocity
ccl_device_constant DeviceString u_shader
ccl_device_constant DeviceString u_object_random
ccl_device_constant DeviceString u_ndc
ccl_device_constant DeviceString u_object_index
ccl_device_constant DeviceString u_curve_tangent_normal
ccl_device_constant DeviceString u_geom_polyvertices
ccl_device_constant DeviceString u_geom_name
ccl_device_constant DeviceString u_curve_thickness
ccl_device_constant DeviceString u_particle_random
ccl_device_constant DeviceString u_geom_undisplaced
ccl_device_constant DeviceString u_curve_random
ccl_device_constant DeviceString u_geom_trianglevertices
CCL_NAMESPACE_BEGIN ccl_device_forceinline T primitive_surface_attribute(KernelGlobals kg, const ccl_private ShaderData *sd, const AttributeDescriptor desc, ccl_private T *dfdx, ccl_private T *dfdy)
ccl_device_extern bool osl_get_attribute(ccl_private ShaderGlobals *sg, const int derivatives, DeviceString object_name, DeviceString name, const int array_lookup, const int index, const TypeDesc type, ccl_private void *res)
ccl_device_forceinline void copy_matrix(ccl_private float *res, const Transform &tfm)
ccl_device_extern bool rs_environment(ccl_private ShaderGlobals *sg, RSDeviceString filename, ccl_private void *texture_handle, ccl_private void *texture_thread_info, ccl_private OSLTextureOptions *opt, const ccl_private float3 *R, const ccl_private float3 *dRdx, const ccl_private float3 *dRdy, const int nchannels, ccl_private float *result, ccl_private float *dresultds, ccl_private float *dresultdt, ccl_private void *errormessage)
ccl_device_extern int rs_pointcloud_get(ccl_private ShaderGlobals *sg, RSDeviceString filename, const ccl_private int *indices, int count, RSDeviceString attr_name, RSTypeDesc attr_type, ccl_private void *out_data)
ccl_device_extern void osl_trace_set_shade(ccl_private void *opt, int x)
ccl_device_extern ccl_private OSLClosure * osl_allocate_closure_component(ccl_private ShaderGlobals *sg, const int id, const int size)
ccl_device_extern void osl_texture_set_sblur(ccl_private OSLTextureOptions *opt, const float blur)
ccl_device_inline bool set_attribute(const T v, const T dx, const T dy, const TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_extern ccl_private OSLClosure * osl_add_closure_closure(ccl_private ShaderGlobals *sg, ccl_private OSLClosure *a, ccl_private OSLClosure *b)
ccl_device_extern void osl_texture_set_time(ccl_private OSLTextureOptions *opt, const float time)
ccl_device_extern void osl_texture_set_stblur(ccl_private OSLTextureOptions *opt, const float blur)
ccl_device_extern int rs_pointcloud_search(ccl_private ShaderGlobals *sg, RSDeviceString filename, const ccl_private float3 *center, float radius, int max_points, bool sort, ccl_private int *out_indices, ccl_private float *out_distances, int derivs_offset)
ccl_device_extern void osl_texture_set_fill(ccl_private OSLTextureOptions *opt, const float fill)
ccl_device_extern bool rs_trace(ccl_private ShaderGlobals *sg, ccl_private void *options, const ccl_private float3 *P, const ccl_private float3 *dPdx, const ccl_private float3 *dPdy, const ccl_private float3 *R, const ccl_private float3 *dRdx, const ccl_private float3 *dRdy)
ccl_device_extern void osl_fprintf(ccl_private ShaderGlobals *sg, DeviceString filename, DeviceString format, void *args)
ccl_device_inline bool get_object_attribute_impl(KernelGlobals kg, ccl_private ShaderData *sd, const AttributeDescriptor &desc, const TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_extern bool rs_texture3d(ccl_private ShaderGlobals *sg, RSDeviceString filename, ccl_private void *texture_handle, ccl_private void *texture_thread_info, ccl_private OSLTextureOptions *opt, const ccl_private float3 *P, const ccl_private float3 *dPdx, const ccl_private float3 *dPdy, const ccl_private float3 *dPdz, const int nchannels, ccl_private float *result, ccl_private float *dresultds, ccl_private float *dresultdt, ccl_private float *dresultdr, ccl_private void *errormessage)
ccl_device_extern bool rs_texture(ccl_private ShaderGlobals *sg, RSDeviceString filename, ccl_private void *texture_handle, ccl_private void *texture_thread_info, ccl_private OSLTextureOptions *opt, const float s, const float t, const float dsdx, const float dtdx, const float dsdy, const float dtdy, const int nchannels, ccl_private float *result, ccl_private float *dresultds, ccl_private float *dresultdt, ccl_private void *errormessage)
ccl_device_extern void osl_texture_set_swidth(ccl_private OSLTextureOptions *opt, const float width)
ccl_device_extern void osl_trace_set_maxdist(ccl_private void *opt, float x)
ccl_device_extern void osl_texture_set_interp_code(ccl_private OSLTextureOptions *opt, const int mode)
ccl_device_extern bool rs_trace_get(ccl_private ShaderGlobals *sg, RSDeviceString name, RSTypeDesc type, ccl_private void *data, bool derivatives)
ccl_device_extern void osl_texture_set_twidth(ccl_private OSLTextureOptions *opt, const float width)
ccl_device_inline bool 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_extern void osl_texture_set_rwrap_code(ccl_private OSLTextureOptions *opt, const int mode)
ccl_device_extern bool rs_pointcloud_write(ccl_private ShaderGlobals *sg, RSDeviceString filename, const ccl_private float3 *pos, int nattribs, const ccl_private DeviceString *names, const ccl_private RSTypeDesc *types, const ccl_private void **data)
ccl_device_inline void set_data_float4(const float4 v, const float4 dx, const float4 dy, bool derivatives, ccl_private void *val)
ccl_device_extern bool osl_get_inverse_matrix(ccl_private ShaderGlobals *sg, ccl_private float *res, DeviceString to)
ccl_device_extern void osl_texture_set_subimagename(ccl_private OSLTextureOptions *opt, DeviceString subimagename_)
ccl_device_extern void osl_warning(ccl_private ShaderGlobals *sg, DeviceString format, void *args)
ccl_device_extern void osl_texture_set_swrap_code(ccl_private OSLTextureOptions *opt, const int mode)
ccl_device_inline bool get_object_attribute(KernelGlobals kg, ccl_private ShaderData *sd, const AttributeDescriptor &desc, const TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_extern void osl_init_trace_options(ccl_private void *oec, ccl_private void *opt)
ccl_device_extern void osl_texture_set_stwrap_code(ccl_private OSLTextureOptions *opt, const int mode)
ccl_device_extern void osl_trace_set_mindist(ccl_private void *opt, float x)
ccl_device_inline bool set_attribute_matrix(const ccl_private Transform &tfm, const TypeDesc type, ccl_private void *val)
ccl_device_extern uint osl_range_check_err(const int indexvalue, const int length, DeviceString symname, ccl_private ShaderGlobals *sg, DeviceString sourcefile, const int sourceline, DeviceString groupname, const int layer, DeviceString layername, DeviceString shadername)
ccl_device_inline bool get_camera_attribute(ccl_private ShaderGlobals *sg, KernelGlobals kg, DeviceString name, TypeDesc type, bool derivatives, ccl_private void *val)
ccl_device_extern void osl_texture_set_missingcolor_arena(ccl_private OSLTextureOptions *opt, ccl_private float3 *color)
ccl_device_extern void osl_trace_set_traceset(ccl_private void *opt, const DeviceString x)
ccl_device_extern void osl_texture_set_twrap_code(ccl_private OSLTextureOptions *opt, const int mode)
ccl_device_extern void osl_texture_set_tblur(ccl_private OSLTextureOptions *opt, const float blur)
ccl_device_extern ccl_private OSLClosure * osl_allocate_weighted_closure_component(ccl_private ShaderGlobals *sg, const int id, const int size, const ccl_private float3 *weight)
ccl_device_extern ccl_private OSLClosure * osl_mul_closure_float(ccl_private ShaderGlobals *sg, ccl_private OSLClosure *a, const float weight)
ccl_device_extern void osl_texture_set_firstchannel(ccl_private OSLTextureOptions *opt, const int firstchannel)
ccl_device_extern void osl_texture_set_stwidth(ccl_private OSLTextureOptions *opt, const float width)
ccl_device_inline void set_data_float3(const float3 v, const float3 dx, const float3 dy, bool derivatives, ccl_private void *val)
ccl_device_inline bool 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)
#define READ_PATH_STATE(elem)
ccl_device_inline void set_data_float(const float v, const float dx, const float dy, bool derivatives, ccl_private void *val)
ccl_device_extern void osl_printf(ccl_private ShaderGlobals *sg, DeviceString format, void *args)
ccl_device_extern void osl_texture_set_missingcolor_alpha(ccl_private OSLTextureOptions *opt, const int nchannels, const float alpha)
ccl_device_extern bool rs_get_texture_info(ccl_private ShaderGlobals *sg, RSDeviceString filename, ccl_private void *texture_handle, ccl_private void *texture_thread_info, int subimage, RSDeviceString dataname, RSTypeDesc datatype, ccl_private void *data, ccl_private void *errormessage)
ccl_device_extern int osl_texture_decode_wrapmode(DeviceString name_)
ccl_device_extern void osl_texture_set_rwidth(ccl_private OSLTextureOptions *opt, const float width)
ccl_device_extern ccl_private OSLClosure * osl_mul_closure_color(ccl_private ShaderGlobals *sg, ccl_private OSLClosure *a, const ccl_private float3 *weight)
ccl_device_extern void osl_texture_set_rblur(ccl_private OSLTextureOptions *opt, const float blur)
ccl_device_extern bool osl_get_matrix(ccl_private ShaderGlobals *sg, ccl_private float *res, DeviceString from)
ccl_device_extern void osl_error(ccl_private ShaderGlobals *sg, DeviceString format, void *args)
ccl_device_extern void osl_texture_set_subimage(ccl_private OSLTextureOptions *opt, const int subimage)
ccl_device_extern bool rend_get_userdata(RSDeviceString name, ccl_private void *data, int data_size, const RSTypeDesc &type, int index)
ccl_device_extern bool rs_get_texture_info_st(ccl_private ShaderGlobals *sg, RSDeviceString filename, ccl_private void *texture_handle, const float s, const float t, ccl_private void *texture_thread_info, int subimage, RSDeviceString dataname, RSTypeDesc datatype, ccl_private void *data, ccl_private void *errormessage)
CCL_NAMESPACE_BEGIN ccl_device bool attribute_bump_map_normal(KernelGlobals kg, ccl_private const ShaderData *sd, float3 f[3])
const IntegratorShadowStateCPU * ConstIntegratorShadowState
const IntegratorStateCPU * ConstIntegratorState
static bool find_attribute(const std::string &attributes, const char *search_attribute)
unsigned char vecsemantics