38 const float mr =
max(keys[1].
w, keys[2].
w);
46 const float *curve_radius,
71 const float *curve_radius,
116 const float mr =
max(keys[1].
w, keys[2].
w);
138 const size_t num_steps,
145 const size_t max_step = num_steps - 1;
146 const size_t step = std::min((
size_t)(time * max_step), max_step - 1);
147 const float t = time * max_step -
step;
154 r_keys[0] = (1.0f - t) * curr_keys[0] + t * next_keys[0];
155 r_keys[1] = (1.0f - t) * curr_keys[1] + t * next_keys[1];
160 const size_t num_steps,
169 const size_t max_step = num_steps - 1;
170 const size_t step =
min((
size_t)(time * max_step), max_step - 1);
171 const float t = time * max_step -
step;
178 r_keys[0] = (1.0f - t) * curr_keys[0] + t * next_keys[0];
179 r_keys[1] = (1.0f - t) * curr_keys[1] + t * next_keys[1];
180 r_keys[2] = (1.0f - t) * curr_keys[2] + t * next_keys[2];
181 r_keys[3] = (1.0f - t) * curr_keys[3] + t * next_keys[3];
191 k0 =
max(k0, (
size_t)0);
209 k0 =
max(k0, (
size_t)0);
237 add_builtin_attributes();
242void Hair::add_builtin_attributes()
254 curve_first_key.resize(numcurves);
255 curve_shader.resize(numcurves);
264 curve_first_key.clear();
265 curve_shader.clear();
268 add_builtin_attributes();
313 const size_t curve_keys_size =
num_keys();
315 const float *curve_radius_data =
get_radius();
318 if (curve_keys_size > 0) {
319 bnds.
grow(parallel_reduce(
320 blocked_range<size_t>(0, curve_num),
322 [&](
const blocked_range<size_t> &range,
const BoundBox &partial_bounds) {
323 BoundBox current_bounds = partial_bounds;
324 for (
size_t i = range.begin(); i < range.end(); ++i) {
328 curve.
bounds_grow(k, curve_keys_data, curve_radius_data, current_bounds);
331 return current_bounds;
334 BoundBox combined_bounds = bounds_a;
335 combined_bounds.
grow(bounds_b);
336 return combined_bounds;
340 if (use_motion_blur && attr_P->
has_motion()) {
341 for (
int attr_step = 1; attr_step < attr_P->
num_motion_steps(); attr_step++) {
343 for (
size_t i = 0; i < curve_keys_size; i++) {
344 bnds.
grow(key_step[i]);
353 for (
size_t i = 0; i < curve_keys_size; i++) {
354 bnds.
grow_safe(curve_keys_data[i], curve_radius_data[i]);
357 if (use_motion_blur && attr_P->
has_motion()) {
358 for (
int attr_step = 1; attr_step < attr_P->
num_motion_steps(); attr_step++) {
360 for (
size_t i = 0; i < curve_keys_size; i++) {
388 for (
size_t i = 0; i < numkeys; i++) {
390 const float r = radius[i] * scalar;
400 if (apply_to_motion) {
405 const bool has_motion_radius = attr_R->
has_motion();
410 for (
size_t i = 0; i < nk; i++) {
413 motion_R[i] *= scalar;
429 for (
size_t i = 0; i < curve_num; i++) {
431 int shader_id = curve_shader[i];
432 Shader *shader = (shader_id < used_shaders.size()) ?
433 static_cast<Shader *
>(used_shaders[shader_id]) :
437 curves[i].shader_id = shader_id;
462 const size_t object_index,
465 int d_input_size = 0;
469 for (
int i = 0; i < num_curves; i++) {
473 for (
int j = 0; j < num_segments + 1; j++) {
475 in.object = object_index;
477 in.u = (j < num_segments) ? 0.0f : 1.0f;
479 d_input_data[d_input_size++] =
in;
488 bool &is_fully_opaque,
491 const int num_keys = d_output.
size();
492 const float *output_data = d_output.
data();
493 bool is_opaque =
true;
495 for (
int i = 0; i < num_keys; i++) {
496 shadow_transparency[i] = output_data[i];
497 if (shadow_transparency[i] > 0.0f) {
502 is_fully_opaque = is_opaque;
511 for (
const Node *
node : used_shaders) {
527 for (
const Node *
node : used_shaders) {
554 const string msg =
string_printf(
"Computing Shadow Transparency %s",
name.c_str());
559 const bool attribute_exists = (attr !=
nullptr);
560 if (!attribute_exists) {
569 for (
size_t i = 0; i < scene->
objects.
size(); i++) {
570 if (scene->
objects[i]->get_geometry() ==
this) {
578 bool is_fully_opaque =
false;
590 if (is_fully_opaque) {
592 return attribute_exists;
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Attribute * find(ustring name) const
Attribute * add(ustring name, const TypeDesc type, AttributeElement element)
void remove(ustring name)
void clear(bool preserve_voxel_data=false)
const T * data(const int step=0) const
void resize(Geometry *geom, AttributePrimitive prim)
T * data_for_write(const int step=0)
void get_uv_tiles(Geometry *geom, AttributePrimitive prim, unordered_set< int > &tiles) const
int num_motion_steps() const
const T * data_at_time_step(const int step, const int num_time_steps) const
__forceinline BoundBox()=default
__forceinline bool valid() const
__forceinline void grow_safe(const float3 &pt)
__forceinline void grow(const float3 &pt)
int motion_step(const float time) const
void tag_position_modified()
const packed_float3 * get_position() const
virtual bool has_motion_blur() const
float * get_radius_for_write()
const float * get_radius() const
Geometry(const NodeType *node_type, const Type type)
void tag_radius_modified()
virtual void clear(bool preserve_shaders=false)
packed_float3 * get_position_for_write()
bool need_update_shadow_transparency() const
bool is_traceable() const
bool need_shadow_transparency() const
void pack_curves(Scene *scene, KernelCurve *curve, KernelCurveSegment *curve_segments)
Curve get_curve(const size_t i) const
void compute_bounds() override
size_t curve_segment_offset
size_t num_curves() const
bool update_shadow_transparency(Device *device, Scene *scene, Progress &progress)
void get_uv_tiles(ustring map, unordered_set< int > &tiles) override
void copy_center_to_motion_step(const int motion_step)
void resize_curves(const int numcurves, const int numkeys)
size_t num_segments() const
CurveShapeType curve_shape
void clear(bool preserve_shaders=false) override
void apply_transform(const Transform &tfm, const bool apply_to_motion) override
PrimitiveType primitive_type() const override
void set_status(const string &status_, const string &substatus_="")
unique_ptr< ShaderManager > shader_manager
unique_ptr_vector< Object > objects
bool eval(const ShaderEvalType type, const int max_num_inputs, const int num_channels, const std::function< int(device_vector< KernelShaderEvalInput > &)> &fill_input, const std::function< void(device_vector< float > &)> &read_output)
bool has_surface_transparent
bool need_update_shadow_transparency
static void fill_shader_input(device_vector< KernelShaderEvalInput > &d_input, const Octree *octree, const Object *object, const Shader *shader, const int resolution)
static void read_shader_output(const device_vector< float > &d_output, const Octree *octree, const int num_channels, const int resolution, vector< Extrema< float > > &sigmas)
#define PRIMITIVE_PACK_SEGMENT(type, segment)
#define CCL_NAMESPACE_END
float dot(VecOp< float, D >, VecOp< float, D >) RET
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
VecBase< float, 3 > cross(VecOp< float, 3 >, VecOp< float, 3 >) RET
static void read_shader_output(float *shadow_transparency, bool &is_fully_opaque, const device_vector< float > &d_output)
static void hair_step_buffers(const Attribute *attr_P, const Attribute *attr_R, const size_t step, const packed_float3 *&P, const float *&R)
static int fill_shader_input(const Hair *hair, const size_t object_index, device_vector< KernelShaderEvalInput > &d_input)
ccl_gpu_kernel_postfix ccl_global KernelWorkTile * tiles
@ PRIMITIVE_MOTION_CURVE_RIBBON
@ PRIMITIVE_CURVE_THICK_LINEAR
@ PRIMITIVE_MOTION_CURVE_THICK
@ PRIMITIVE_MOTION_CURVE_THICK_LINEAR
@ ATTR_STD_SHADOW_TRANSPARENCY
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
#define SOCKET_INT_ARRAY(name, ui_name, default_value,...)
#define NODE_DEFINE(structname)
CCL_NAMESPACE_BEGIN void curvebounds(float *lower, float *upper, float3 *p, const int dim)
@ SHADER_EVAL_CURVE_SHADOW_TRANSPARENCY
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
void keys_for_step(const Attribute *attr_P, const Attribute *attr_R, const size_t step, size_t k0, size_t k1, float4 r_keys[2]) const
void cardinal_motion_keys(const Attribute *attr_P, const Attribute *attr_R, const size_t num_steps, const float time, size_t k0, size_t k1, size_t k2, size_t k3, float4 r_keys[4]) const
void bounds_grow(const int k, const packed_float3 *curve_keys, const float *curve_radius, BoundBox &bounds) const
void cardinal_keys_for_step(const Attribute *attr_P, const Attribute *attr_R, const size_t step, size_t k0, size_t k1, size_t k2, size_t k3, float4 r_keys[4]) const
void motion_keys(const Attribute *attr_P, const Attribute *attr_R, const size_t num_steps, const float time, size_t k0, size_t k1, float4 r_keys[2]) const
static NodeType * add(const char *name, CreateFunc create, Type type=NONE, const NodeType *base=nullptr)
Node(const NodeType *type, ustring name=ustring())