36 float mr =
max(keys[1].
w, keys[2].
w);
44 const float *curve_radius,
49 P[0] = curve_keys[
max(first_key + k - 1, first_key)];
50 P[1] = curve_keys[first_key + k];
51 P[2] = curve_keys[first_key + k + 1];
52 P[3] = curve_keys[
min(first_key + k + 2, first_key +
num_keys - 1)];
61 float mr =
max(curve_radius[first_key + k], curve_radius[first_key + k + 1]);
69 const float *curve_radius,
75 P[0] = curve_keys[
max(first_key + k - 1, first_key)];
76 P[1] = curve_keys[first_key + k];
77 P[2] = curve_keys[first_key + k + 1];
78 P[3] = curve_keys[
min(first_key + k + 2, first_key +
num_keys - 1)];
92 float mr =
max(curve_radius[first_key + k], curve_radius[first_key + k + 1]);
114 float mr =
max(keys[1].
w, keys[2].
w);
121 const float *curve_radius,
122 const float4 *key_steps,
123 size_t num_curve_keys,
128 float4 r_keys[2])
const
131 const size_t max_step = num_steps - 1;
132 const size_t step = std::min((
size_t)(time * max_step), max_step - 1);
133 const float t = time * max_step - step;
138 curve_keys, curve_radius, key_steps, num_curve_keys, num_steps, step, k0, k1, curr_keys);
140 curve_keys, curve_radius, key_steps, num_curve_keys, num_steps, step + 1, k0, k1, next_keys);
142 r_keys[0] = (1.0f - t) * curr_keys[0] + t * next_keys[0];
143 r_keys[1] = (1.0f - t) * curr_keys[1] + t * next_keys[1];
147 const float *curve_radius,
148 const float4 *key_steps,
149 size_t num_curve_keys,
156 float4 r_keys[4])
const
159 const size_t max_step = num_steps - 1;
160 const size_t step =
min((
size_t)(time * max_step), max_step - 1);
161 const float t = time * max_step - step;
165 cardinal_keys_for_step(curve_keys,
176 cardinal_keys_for_step(curve_keys,
188 r_keys[0] = (1.0f - t) * curr_keys[0] + t * next_keys[0];
189 r_keys[1] = (1.0f - t) * curr_keys[1] + t * next_keys[1];
190 r_keys[2] = (1.0f - t) * curr_keys[2] + t * next_keys[2];
191 r_keys[3] = (1.0f - t) * curr_keys[3] + t * next_keys[3];
195 const float *curve_radius,
196 const float4 *key_steps,
197 size_t num_curve_keys,
202 float4 r_keys[2])
const
204 k0 =
max(k0, (
size_t)0);
206 const size_t center_step = ((num_steps - 1) / 2);
207 if (step == center_step) {
212 r_keys[0] =
make_float4(curve_keys[first_key + k0].x,
213 curve_keys[first_key + k0].y,
214 curve_keys[first_key + k0].
z,
215 curve_radius[first_key + k0]);
216 r_keys[1] =
make_float4(curve_keys[first_key + k1].x,
217 curve_keys[first_key + k1].y,
218 curve_keys[first_key + k1].
z,
219 curve_radius[first_key + k1]);
223 if (step > center_step) {
226 const size_t offset = first_key + step * num_curve_keys;
228 key_steps[offset + k0].y,
229 key_steps[offset + k0].
z,
230 curve_radius[first_key + k0]);
232 key_steps[offset + k1].y,
233 key_steps[offset + k1].
z,
234 curve_radius[first_key + k1]);
239 const float *curve_radius,
240 const float4 *key_steps,
241 size_t num_curve_keys,
248 float4 r_keys[4])
const
250 k0 =
max(k0, (
size_t)0);
252 const size_t center_step = ((num_steps - 1) / 2);
253 if (step == center_step) {
255 r_keys[0] =
make_float4(curve_keys[first_key + k0].x,
256 curve_keys[first_key + k0].y,
257 curve_keys[first_key + k0].
z,
258 curve_radius[first_key + k0]);
259 r_keys[1] =
make_float4(curve_keys[first_key + k1].x,
260 curve_keys[first_key + k1].y,
261 curve_keys[first_key + k1].
z,
262 curve_radius[first_key + k1]);
263 r_keys[2] =
make_float4(curve_keys[first_key + k2].x,
264 curve_keys[first_key + k2].y,
265 curve_keys[first_key + k2].
z,
266 curve_radius[first_key + k2]);
267 r_keys[3] =
make_float4(curve_keys[first_key + k3].x,
268 curve_keys[first_key + k3].y,
269 curve_keys[first_key + k3].
z,
270 curve_radius[first_key + k3]);
274 if (step > center_step) {
277 const size_t offset = first_key + step * num_curve_keys;
279 key_steps[offset + k0].y,
280 key_steps[offset + k0].
z,
281 curve_radius[first_key + k0]);
283 key_steps[offset + k1].y,
284 key_steps[offset + k1].
z,
285 curve_radius[first_key + k1]);
287 key_steps[offset + k2].y,
288 key_steps[offset + k2].
z,
289 curve_radius[first_key + k2]);
291 key_steps[offset + k3].y,
292 key_steps[offset + k3].
z,
293 curve_radius[first_key + k3]);
322 curve_keys.resize(numkeys);
323 curve_radius.resize(numkeys);
324 curve_first_key.resize(numcurves);
325 curve_shader.resize(numcurves);
332 curve_keys.reserve(numkeys);
333 curve_radius.reserve(numkeys);
334 curve_first_key.reserve(numcurves);
335 curve_shader.reserve(numcurves);
337 attributes.resize(
true);
345 curve_radius.clear();
346 curve_first_key.clear();
347 curve_shader.clear();
354 curve_keys.push_back_reserved(co);
355 curve_radius.push_back_reserved(radius);
357 tag_curve_keys_modified();
358 tag_curve_radius_modified();
363 curve_first_key.push_back_reserved(first_key);
364 curve_shader.push_back_reserved(shader);
366 tag_curve_first_key_modified();
367 tag_curve_shader_modified();
374 float3 *keys = &curve_keys[0];
375 size_t numkeys = curve_keys.size();
388 attr = attributes.find(map);
399 size_t curve_keys_size = curve_keys.
size();
402 if (curve_keys_size > 0) {
403 bnds.
grow(parallel_reduce(
404 blocked_range<size_t>(0, curve_num),
406 [&](
const blocked_range<size_t> &range,
const BoundBox &partial_bounds) {
407 BoundBox current_bounds = partial_bounds;
408 for (
size_t i = range.begin(); i < range.end(); ++i) {
412 curve.bounds_grow(k, curve_keys.data(), curve_radius.data(), current_bounds);
415 return current_bounds;
418 BoundBox combined_bounds = bounds_a;
419 combined_bounds.
grow(bounds_b);
420 return combined_bounds;
424 if (use_motion_blur && curve_attr) {
425 size_t steps_size = curve_keys.size() * (motion_steps - 1);
430 for (
size_t i = 0; i < steps_size; i++) {
439 for (
size_t i = 0; i < curve_keys_size; i++) {
440 bnds.
grow_safe(curve_keys[i], curve_radius[i]);
443 if (use_motion_blur && curve_attr) {
444 size_t steps_size = curve_keys.size() * (motion_steps - 1);
449 for (
size_t i = 0; i < steps_size; i++) {
473 for (
size_t i = 0; i < curve_keys.size(); i++) {
475 float radius = curve_radius[i] * scalar;
479 curve_radius[i] = radius;
482 tag_curve_keys_modified();
483 tag_curve_radius_modified();
485 if (apply_to_motion) {
490 size_t steps_size = curve_keys.size() * (motion_steps - 1);
493 for (
size_t i = 0; i < steps_size; i++) {
495 float radius = key_steps[i].w * scalar;
499 key_steps[i].w = radius;
506 float4 *curve_key_co,
510 size_t curve_keys_size = curve_keys.size();
513 if (curve_keys_size) {
514 float3 *keys_ptr = curve_keys.data();
515 float *radius_ptr = curve_radius.data();
517 for (
size_t i = 0; i < curve_keys_size; i++) {
518 curve_key_co[i] =
make_float4(keys_ptr[i].x, keys_ptr[i].y, keys_ptr[i].
z, radius_ptr[i]);
528 for (
size_t i = 0; i < curve_num; i++) {
530 int shader_id = curve_shader[i];
531 Shader *shader = (shader_id < used_shaders.size()) ?
532 static_cast<Shader *
>(used_shaders[shader_id]) :
533 scene->default_surface;
534 shader_id = scene->shader_manager->get_shader_id(shader,
false);
536 curves[i].shader_id = shader_id;
538 curves[i].num_keys = curve.num_keys;
541 for (
int k = 0; k < curve.num_segments(); ++k, ++
index) {
558 const size_t object_index,
561 int d_input_size = 0;
564 const int num_curves = hair->num_curves();
565 for (
int i = 0; i < num_curves; i++) {
569 for (
int j = 0; j < num_segments + 1; j++) {
572 in.prim = hair->prim_offset + i;
573 in.u = (j < num_segments) ? 0.0f : 1.0f;
575 d_input_data[d_input_size++] = in;
584 bool &is_fully_opaque,
587 const int num_keys = d_output.
size();
588 const float *output_data = d_output.
data();
589 bool is_opaque =
true;
591 for (
int i = 0; i < num_keys; i++) {
592 shadow_transparency[i] = output_data[i];
593 if (shadow_transparency[i] > 0.0f) {
598 is_fully_opaque = is_opaque;
603 for (
const Node *node : used_shaders) {
605 if (shader->has_surface_transparent && shader->get_use_transparent_shadow()) {
619 attributes.remove(attr);
627 string msg =
string_printf(
"Computing Shadow Transparency %s", name.c_str());
632 const bool attribute_exists = (attr !=
nullptr);
633 if (!attribute_exists) {
642 for (
size_t i = 0; i < scene->objects.size(); i++) {
643 if (scene->objects[i]->get_geometry() ==
this) {
651 bool is_fully_opaque =
false;
658 if (is_fully_opaque) {
659 attributes.remove(attr);
660 return attribute_exists;
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
void get_uv_tiles(Geometry *geom, AttributePrimitive prim, unordered_set< int > &tiles) const
int motion_step(float time) const
bool has_motion_blur() const
virtual void clear(bool preserve_shaders=false)
void resize_curves(int numcurves, int numkeys)
void add_curve(int first_key, int shader)
Curve get_curve(size_t i) const
bool need_shadow_transparency()
void compute_bounds() override
void reserve_curves(int numcurves, int numkeys)
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 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 add_curve_key(float3 loc, float radius)
void set_status(const string &status_, const string &substatus_="")
bool eval(const ShaderEvalType type, const int max_num_inputs, const int num_channels, const function< int(device_vector< KernelShaderEvalInput > &)> &fill_input, const function< void(device_vector< float > &)> &read_output)
additional_info("compositor_sum_squared_difference_float_shared") .push_constant(Type output_img float dot(value.rgb, luminance_coefficients)") .define("LOAD(value)"
#define CCL_NAMESPACE_END
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
#define PRIMITIVE_PACK_SEGMENT(type, segment)
@ PRIMITIVE_MOTION_CURVE_RIBBON
@ PRIMITIVE_MOTION_CURVE_THICK
@ ATTR_STD_MOTION_VERTEX_POSITION
@ ATTR_STD_SHADOW_TRANSPARENCY
ccl_device_inline float cross(const float2 a, const float2 b)
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, int dim)
@ SHADER_EVAL_CURVE_SHADOW_TRANSPARENCY
CCL_NAMESPACE_BEGIN string string_printf(const char *format,...)
__forceinline bool valid() const
__forceinline float3 size() const
__forceinline void grow_safe(const float3 &pt)
__forceinline void grow(const float3 &pt)
void cardinal_motion_keys(const float3 *curve_keys, const float *curve_radius, const float4 *key_steps, size_t num_curve_keys, size_t num_steps, 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 float3 *curve_keys, const float *curve_radius, BoundBox &bounds) const
void cardinal_keys_for_step(const float3 *curve_keys, const float *curve_radius, const float4 *key_steps, size_t num_curve_keys, size_t num_steps, 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, size_t num_curve_keys, size_t num_steps, 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, size_t num_curve_keys, size_t num_steps, 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=NULL)
ccl_device_inline float4 float3_to_float4(const float3 a)
ccl_device_inline float3 float4_to_float3(const float4 a)