Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/svm/svm_voronoi.h
| Show First 20 Lines • Show All 896 Lines • ▼ Show 20 Lines | for (int k = -1; k <= 1; k++) { | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| *outRadius = distance(closestPointToClosestPoint, closestPoint) / 2.0f; | *outRadius = distance(closestPointToClosestPoint, closestPoint) / 2.0f; | ||||
| } | } | ||||
| ccl_device void svm_node_tex_voronoi(KernelGlobals *kg, | template<uint node_feature_mask> | ||||
| ccl_device_noinline int svm_node_tex_voronoi(const KernelGlobals *kg, | |||||
| ShaderData *sd, | ShaderData *sd, | ||||
| float *stack, | float *stack, | ||||
| uint dimensions, | uint dimensions, | ||||
| uint feature, | uint feature, | ||||
| uint metric, | uint metric, | ||||
| int *offset) | int offset) | ||||
| { | { | ||||
| uint4 stack_offsets = read_node(kg, offset); | uint4 stack_offsets = read_node(kg, &offset); | ||||
| uint4 defaults = read_node(kg, offset); | uint4 defaults = read_node(kg, &offset); | ||||
| uint coord_stack_offset, w_stack_offset, scale_stack_offset, smoothness_stack_offset; | uint coord_stack_offset, w_stack_offset, scale_stack_offset, smoothness_stack_offset; | ||||
| uint exponent_stack_offset, randomness_stack_offset, distance_out_stack_offset, | uint exponent_stack_offset, randomness_stack_offset, distance_out_stack_offset, | ||||
| color_out_stack_offset; | color_out_stack_offset; | ||||
| uint position_out_stack_offset, w_out_stack_offset, radius_out_stack_offset; | uint position_out_stack_offset, w_out_stack_offset, radius_out_stack_offset; | ||||
| svm_unpack_node_uchar4(stack_offsets.x, | svm_unpack_node_uchar4(stack_offsets.x, | ||||
| &coord_stack_offset, | &coord_stack_offset, | ||||
| ▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Lines | case 2: { | ||||
| voronoi_f1_2d(coord_2d, | voronoi_f1_2d(coord_2d, | ||||
| exponent, | exponent, | ||||
| randomness, | randomness, | ||||
| voronoi_metric, | voronoi_metric, | ||||
| &distance_out, | &distance_out, | ||||
| &color_out, | &color_out, | ||||
| &position_out_2d); | &position_out_2d); | ||||
| break; | break; | ||||
| #if NODES_FEATURE(NODE_FEATURE_VORONOI_EXTRA) | |||||
| case NODE_VORONOI_SMOOTH_F1: | case NODE_VORONOI_SMOOTH_F1: | ||||
| if (KERNEL_NODES_FEATURE(VORONOI_EXTRA)) { | |||||
| voronoi_smooth_f1_2d(coord_2d, | voronoi_smooth_f1_2d(coord_2d, | ||||
| smoothness, | smoothness, | ||||
| exponent, | exponent, | ||||
| randomness, | randomness, | ||||
| voronoi_metric, | voronoi_metric, | ||||
| &distance_out, | &distance_out, | ||||
| &color_out, | &color_out, | ||||
| &position_out_2d); | &position_out_2d); | ||||
| } | |||||
| break; | break; | ||||
| #endif | |||||
| case NODE_VORONOI_F2: | case NODE_VORONOI_F2: | ||||
| voronoi_f2_2d(coord_2d, | voronoi_f2_2d(coord_2d, | ||||
| exponent, | exponent, | ||||
| randomness, | randomness, | ||||
| voronoi_metric, | voronoi_metric, | ||||
| &distance_out, | &distance_out, | ||||
| &color_out, | &color_out, | ||||
| &position_out_2d); | &position_out_2d); | ||||
| Show All 17 Lines | case 3: { | ||||
| voronoi_f1_3d(coord, | voronoi_f1_3d(coord, | ||||
| exponent, | exponent, | ||||
| randomness, | randomness, | ||||
| voronoi_metric, | voronoi_metric, | ||||
| &distance_out, | &distance_out, | ||||
| &color_out, | &color_out, | ||||
| &position_out); | &position_out); | ||||
| break; | break; | ||||
| #if NODES_FEATURE(NODE_FEATURE_VORONOI_EXTRA) | |||||
| case NODE_VORONOI_SMOOTH_F1: | case NODE_VORONOI_SMOOTH_F1: | ||||
| if (KERNEL_NODES_FEATURE(VORONOI_EXTRA)) { | |||||
| voronoi_smooth_f1_3d(coord, | voronoi_smooth_f1_3d(coord, | ||||
| smoothness, | smoothness, | ||||
| exponent, | exponent, | ||||
| randomness, | randomness, | ||||
| voronoi_metric, | voronoi_metric, | ||||
| &distance_out, | &distance_out, | ||||
| &color_out, | &color_out, | ||||
| &position_out); | &position_out); | ||||
| } | |||||
| break; | break; | ||||
| #endif | |||||
| case NODE_VORONOI_F2: | case NODE_VORONOI_F2: | ||||
| voronoi_f2_3d(coord, | voronoi_f2_3d(coord, | ||||
| exponent, | exponent, | ||||
| randomness, | randomness, | ||||
| voronoi_metric, | voronoi_metric, | ||||
| &distance_out, | &distance_out, | ||||
| &color_out, | &color_out, | ||||
| &position_out); | &position_out); | ||||
| break; | break; | ||||
| case NODE_VORONOI_DISTANCE_TO_EDGE: | case NODE_VORONOI_DISTANCE_TO_EDGE: | ||||
| voronoi_distance_to_edge_3d(coord, randomness, &distance_out); | voronoi_distance_to_edge_3d(coord, randomness, &distance_out); | ||||
| break; | break; | ||||
| case NODE_VORONOI_N_SPHERE_RADIUS: | case NODE_VORONOI_N_SPHERE_RADIUS: | ||||
| voronoi_n_sphere_radius_3d(coord, randomness, &radius_out); | voronoi_n_sphere_radius_3d(coord, randomness, &radius_out); | ||||
| break; | break; | ||||
| default: | default: | ||||
| kernel_assert(0); | kernel_assert(0); | ||||
| } | } | ||||
| position_out = safe_divide_float3_float(position_out, scale); | position_out = safe_divide_float3_float(position_out, scale); | ||||
| break; | break; | ||||
| } | } | ||||
| #if NODES_FEATURE(NODE_FEATURE_VORONOI_EXTRA) | |||||
| case 4: { | case 4: { | ||||
| if (KERNEL_NODES_FEATURE(VORONOI_EXTRA)) { | |||||
| float4 coord_4d = make_float4(coord.x, coord.y, coord.z, w); | float4 coord_4d = make_float4(coord.x, coord.y, coord.z, w); | ||||
| float4 position_out_4d; | float4 position_out_4d; | ||||
| switch (voronoi_feature) { | switch (voronoi_feature) { | ||||
| case NODE_VORONOI_F1: | case NODE_VORONOI_F1: | ||||
| voronoi_f1_4d(coord_4d, | voronoi_f1_4d(coord_4d, | ||||
| exponent, | exponent, | ||||
| randomness, | randomness, | ||||
| voronoi_metric, | voronoi_metric, | ||||
| &distance_out, | &distance_out, | ||||
| &color_out, | &color_out, | ||||
| &position_out_4d); | &position_out_4d); | ||||
| break; | break; | ||||
| case NODE_VORONOI_SMOOTH_F1: | case NODE_VORONOI_SMOOTH_F1: | ||||
| voronoi_smooth_f1_4d(coord_4d, | voronoi_smooth_f1_4d(coord_4d, | ||||
| smoothness, | smoothness, | ||||
| exponent, | exponent, | ||||
| randomness, | randomness, | ||||
| voronoi_metric, | voronoi_metric, | ||||
| &distance_out, | &distance_out, | ||||
| &color_out, | &color_out, | ||||
| &position_out_4d); | &position_out_4d); | ||||
| break; | break; | ||||
| case NODE_VORONOI_F2: | case NODE_VORONOI_F2: | ||||
| voronoi_f2_4d(coord_4d, | voronoi_f2_4d(coord_4d, | ||||
| exponent, | exponent, | ||||
| randomness, | randomness, | ||||
| voronoi_metric, | voronoi_metric, | ||||
| &distance_out, | &distance_out, | ||||
| &color_out, | &color_out, | ||||
| &position_out_4d); | &position_out_4d); | ||||
| break; | break; | ||||
| case NODE_VORONOI_DISTANCE_TO_EDGE: | case NODE_VORONOI_DISTANCE_TO_EDGE: | ||||
| voronoi_distance_to_edge_4d(coord_4d, randomness, &distance_out); | voronoi_distance_to_edge_4d(coord_4d, randomness, &distance_out); | ||||
| break; | break; | ||||
| case NODE_VORONOI_N_SPHERE_RADIUS: | case NODE_VORONOI_N_SPHERE_RADIUS: | ||||
| voronoi_n_sphere_radius_4d(coord_4d, randomness, &radius_out); | voronoi_n_sphere_radius_4d(coord_4d, randomness, &radius_out); | ||||
| break; | break; | ||||
| default: | default: | ||||
| kernel_assert(0); | kernel_assert(0); | ||||
| } | } | ||||
| position_out_4d = safe_divide_float4_float(position_out_4d, scale); | position_out_4d = safe_divide_float4_float(position_out_4d, scale); | ||||
| position_out = make_float3(position_out_4d.x, position_out_4d.y, position_out_4d.z); | position_out = make_float3(position_out_4d.x, position_out_4d.y, position_out_4d.z); | ||||
| w_out = position_out_4d.w; | w_out = position_out_4d.w; | ||||
| } | |||||
| break; | break; | ||||
| } | } | ||||
| #endif | |||||
| default: | default: | ||||
| kernel_assert(0); | kernel_assert(0); | ||||
| } | } | ||||
| if (stack_valid(distance_out_stack_offset)) | if (stack_valid(distance_out_stack_offset)) | ||||
| stack_store_float(stack, distance_out_stack_offset, distance_out); | stack_store_float(stack, distance_out_stack_offset, distance_out); | ||||
| if (stack_valid(color_out_stack_offset)) | if (stack_valid(color_out_stack_offset)) | ||||
| stack_store_float3(stack, color_out_stack_offset, color_out); | stack_store_float3(stack, color_out_stack_offset, color_out); | ||||
| if (stack_valid(position_out_stack_offset)) | if (stack_valid(position_out_stack_offset)) | ||||
| stack_store_float3(stack, position_out_stack_offset, position_out); | stack_store_float3(stack, position_out_stack_offset, position_out); | ||||
| if (stack_valid(w_out_stack_offset)) | if (stack_valid(w_out_stack_offset)) | ||||
| stack_store_float(stack, w_out_stack_offset, w_out); | stack_store_float(stack, w_out_stack_offset, w_out); | ||||
| if (stack_valid(radius_out_stack_offset)) | if (stack_valid(radius_out_stack_offset)) | ||||
| stack_store_float(stack, radius_out_stack_offset, radius_out); | stack_store_float(stack, radius_out_stack_offset, radius_out); | ||||
| return offset; | |||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||