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);
123 const float *curve_radius,
125 const size_t num_curve_keys,
126 const size_t num_steps,
133 const size_t max_step = num_steps - 1;
134 const size_t step = std::min((
size_t)(time * max_step), max_step - 1);
135 const float t = time * max_step -
step;
140 curve_keys, curve_radius, key_steps, num_curve_keys, num_steps,
step, k0, k1, curr_keys);
142 curve_keys, curve_radius, key_steps, num_curve_keys, num_steps,
step + 1, k0, k1, next_keys);
144 r_keys[0] = (1.0f - t) * curr_keys[0] + t * next_keys[0];
145 r_keys[1] = (1.0f - t) * curr_keys[1] + t * next_keys[1];
149 const float *curve_radius,
151 const size_t num_curve_keys,
152 const size_t num_steps,
161 const size_t max_step = num_steps - 1;
162 const size_t step =
min((
size_t)(time * max_step), max_step - 1);
163 const float t = time * max_step -
step;
190 r_keys[0] = (1.0f - t) * curr_keys[0] + t * next_keys[0];
191 r_keys[1] = (1.0f - t) * curr_keys[1] + t * next_keys[1];
192 r_keys[2] = (1.0f - t) * curr_keys[2] + t * next_keys[2];
193 r_keys[3] = (1.0f - t) * curr_keys[3] + t * next_keys[3];
197 const float *curve_radius,
199 const size_t num_curve_keys,
200 const size_t num_steps,
206 k0 =
max(k0, (
size_t)0);
208 const size_t center_step = ((num_steps - 1) / 2);
209 if (
step == center_step) {
216 if (
step > center_step) {
221 key_steps[offset + k0].
y,
222 key_steps[offset + k0].
z,
225 key_steps[offset + k1].
y,
226 key_steps[offset + k1].
z,
232 const float *curve_radius,
234 const size_t num_curve_keys,
235 const size_t num_steps,
243 k0 =
max(k0, (
size_t)0);
245 const size_t center_step = ((num_steps - 1) / 2);
246 if (
step == center_step) {
255 if (
step > center_step) {
260 key_steps[offset + k0].
y,
261 key_steps[offset + k0].
z,
264 key_steps[offset + k1].
y,
265 key_steps[offset + k1].
z,
268 key_steps[offset + k2].
y,
269 key_steps[offset + k2].
z,
272 key_steps[offset + k3].
y,
273 key_steps[offset + k3].
z,
303 curve_keys.resize(numkeys);
304 curve_radius.resize(numkeys);
305 curve_first_key.resize(numcurves);
306 curve_shader.resize(numcurves);
313 curve_keys.reserve(numkeys);
314 curve_radius.reserve(numkeys);
315 curve_first_key.reserve(numcurves);
316 curve_shader.reserve(numcurves);
326 curve_radius.clear();
327 curve_first_key.clear();
328 curve_shader.clear();
335 curve_keys.push_back_reserved(co);
336 curve_radius.push_back_reserved(radius);
338 tag_curve_keys_modified();
339 tag_curve_radius_modified();
344 curve_first_key.push_back_reserved(first_key);
345 curve_shader.push_back_reserved(shader);
347 tag_curve_first_key_modified();
348 tag_curve_shader_modified();
355 float3 *keys = curve_keys.data();
356 const size_t numkeys = curve_keys.size();
380 const size_t curve_keys_size = curve_keys.size();
383 if (curve_keys_size > 0) {
385 blocked_range<size_t>(0, curve_num),
387 [&](
const blocked_range<size_t> &range,
const BoundBox &partial_bounds) {
388 BoundBox current_bounds = partial_bounds;
389 for (
size_t i = range.begin();
i < range.end(); ++
i) {
393 curve.
bounds_grow(k, curve_keys.data(), curve_radius.data(), current_bounds);
396 return current_bounds;
399 BoundBox combined_bounds = bounds_a;
400 combined_bounds.
grow(bounds_b);
401 return combined_bounds;
405 if (use_motion_blur && curve_attr) {
406 const size_t steps_size = curve_keys.size() * (motion_steps - 1);
411 for (
size_t i = 0;
i < steps_size;
i++) {
420 for (
size_t i = 0;
i < curve_keys_size;
i++) {
424 if (use_motion_blur && curve_attr) {
425 const size_t steps_size = curve_keys.size() * (motion_steps - 1);
430 for (
size_t i = 0;
i < steps_size;
i++) {
454 for (
size_t i = 0;
i < curve_keys.size();
i++) {
456 const float radius = curve_radius[
i] * scalar;
460 curve_radius[
i] = radius;
463 tag_curve_keys_modified();
464 tag_curve_radius_modified();
466 if (apply_to_motion) {
471 const size_t steps_size = curve_keys.size() * (motion_steps - 1);
474 for (
size_t i = 0;
i < steps_size;
i++) {
476 const float radius = key_steps[
i].
w * scalar;
480 key_steps[
i].
w = radius;
491 const size_t curve_keys_size = curve_keys.size();
494 if (curve_keys_size) {
495 float3 *keys_ptr = curve_keys.data();
496 float *radius_ptr = curve_radius.data();
498 for (
size_t i = 0;
i < curve_keys_size;
i++) {
509 for (
size_t i = 0;
i < curve_num;
i++) {
511 int shader_id = curve_shader[
i];
512 Shader *shader = (shader_id < used_shaders.size()) ?
513 static_cast<Shader *
>(used_shaders[shader_id]) :
542 const size_t object_index,
545 int d_input_size = 0;
549 for (
int i = 0;
i < num_curves;
i++) {
553 for (
int j = 0; j < num_segments + 1; j++) {
555 in.object = object_index;
557 in.u = (j < num_segments) ? 0.0f : 1.0f;
559 d_input_data[d_input_size++] =
in;
568 bool &is_fully_opaque,
571 const int num_keys = d_output.
size();
572 const float *output_data = d_output.
data();
573 bool is_opaque =
true;
575 for (
int i = 0;
i < num_keys;
i++) {
576 shadow_transparency[
i] = output_data[
i];
577 if (shadow_transparency[
i] > 0.0f) {
582 is_fully_opaque = is_opaque;
591 for (
const Node *node : used_shaders) {
592 const Shader *shader =
static_cast<const Shader *
>(node);
613 const string msg =
string_printf(
"Computing Shadow Transparency %s",
name.c_str());
618 const bool attribute_exists = (attr !=
nullptr);
619 if (!attribute_exists) {
629 if (scene->
objects[
i]->get_geometry() ==
this) {
637 bool is_fully_opaque =
false;
649 if (is_fully_opaque) {
651 return attribute_exists;
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
int motion_step(const float time) const
virtual bool has_motion_blur() const
Geometry(const NodeType *node_type, const Type type)
virtual void clear(bool preserve_shaders=false)
bool is_traceable() const
void add_curve_key(const float3 co, const float radius)
bool need_shadow_transparency()
Curve get_curve(const size_t i) const
void compute_bounds() override
size_t curve_segment_offset
void add_curve(const int first_key, const int shader)
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)
void pack_curves(Scene *scene, float4 *curve_key_co, KernelCurve *curve, KernelCurveSegment *curve_segments)
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 reserve_curves(const int numcurves, const int numkeys)
void set_status(const string &status_, const string &substatus_="")
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
dot(value.rgb, luminance_coefficients)") DEFINE_VALUE("REDUCE(lhs
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
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 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_MOTION_VERTEX_POSITION
@ ATTR_STD_SHADOW_TRANSPARENCY
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
#define SOCKET_POINT_ARRAY(name, ui_name, default_value,...)
#define SOCKET_FLOAT_ARRAY(name, ui_name, default_value,...)
#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 get_uv_tiles(Geometry *geom, AttributePrimitive prim, unordered_set< int > &tiles) const
__forceinline bool valid() const
__forceinline void grow_safe(const float3 &pt)
__forceinline void grow(const float3 &pt)
void bounds_grow(const int k, const float3 *curve_keys, const float *curve_radius, BoundBox &bounds) const
void cardinal_motion_keys(const float3 *curve_keys, const float *curve_radius, const float4 *key_steps, const size_t num_curve_keys, 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 cardinal_keys_for_step(const float3 *curve_keys, const float *curve_radius, const float4 *key_steps, const size_t num_curve_keys, const size_t num_steps, 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 float3 *curve_keys, const float *curve_radius, const float4 *key_steps, const size_t num_curve_keys, const size_t num_steps, const float time, size_t k0, size_t k1, float4 r_keys[2]) const
void keys_for_step(const float3 *curve_keys, const float *curve_radius, const float4 *key_steps, const size_t num_curve_keys, const size_t num_steps, const size_t step, 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())
unique_ptr< ShaderManager > shader_manager
unique_ptr_vector< Object > objects
static Value parallel_reduce(const int range, const Value &identity, const Function &function, const Reduction &reduction)