82 float cellPosition =
floorf(coord);
83 float localPosition = coord - cellPosition;
86 float targetOffset = 0.0f;
87 float targetPosition = 0.0f;
88 for (
int i = -1; i <= 1; i++) {
90 float pointPosition = cellOffset +
93 if (distanceToPoint < minDistance) {
94 targetOffset = cellOffset;
95 minDistance = distanceToPoint;
96 targetPosition = pointPosition;
110 float cellPosition =
floorf(coord);
111 float localPosition = coord - cellPosition;
113 float smoothDistance = 0.0f;
114 float smoothPosition = 0.0f;
117 for (
int i = -2; i <= 2; i++) {
118 float cellOffset = i;
119 float pointPosition = cellOffset +
125 0.0f, 1.0f, 0.5f + 0.5f * (smoothDistance - distanceToPoint) /
params.smoothness);
126 float correctionFactor =
params.smoothness * h * (1.0f - h);
127 smoothDistance =
mix(smoothDistance, distanceToPoint, h) - correctionFactor;
128 correctionFactor /= 1.0f + 3.0f *
params.smoothness;
130 smoothColor =
mix(smoothColor, cellColor, h) - correctionFactor;
131 smoothPosition =
mix(smoothPosition, pointPosition, h) - correctionFactor;
136 octave.
color = smoothColor;
143 float cellPosition =
floorf(coord);
144 float localPosition = coord - cellPosition;
148 float offsetF1 = 0.0f;
149 float positionF1 = 0.0f;
150 float offsetF2 = 0.0f;
151 float positionF2 = 0.0f;
152 for (
int i = -1; i <= 1; i++) {
153 float cellOffset = i;
154 float pointPosition = cellOffset +
157 if (distanceToPoint < distanceF1) {
158 distanceF2 = distanceF1;
159 distanceF1 = distanceToPoint;
161 offsetF1 = cellOffset;
162 positionF2 = positionF1;
163 positionF1 = pointPosition;
165 else if (distanceToPoint < distanceF2) {
166 distanceF2 = distanceToPoint;
167 offsetF2 = cellOffset;
168 positionF2 = pointPosition;
182 float cellPosition =
floorf(coord);
183 float localPosition = coord - cellPosition;
188 float distanceToMidLeft =
fabsf((midPointPosition + leftPointPosition) / 2.0f - localPosition);
189 float distanceToMidRight =
fabsf((midPointPosition + rightPointPosition) / 2.0f - localPosition);
191 return min(distanceToMidLeft, distanceToMidRight);
197 float cellPosition =
floorf(coord);
198 float localPosition = coord - cellPosition;
200 float closestPoint = 0.0f;
201 float closestPointOffset = 0.0f;
203 for (
int i = -1; i <= 1; i++) {
204 float cellOffset = i;
205 float pointPosition = cellOffset +
207 float distanceToPoint =
fabsf(pointPosition - localPosition);
208 if (distanceToPoint < minDistance) {
209 minDistance = distanceToPoint;
210 closestPoint = pointPosition;
211 closestPointOffset = cellOffset;
216 float closestPointToClosestPoint = 0.0f;
217 for (
int i = -1; i <= 1; i++) {
221 float cellOffset = i + closestPointOffset;
222 float pointPosition = cellOffset +
224 float distanceToPoint =
fabsf(closestPoint - pointPosition);
225 if (distanceToPoint < minDistance) {
226 minDistance = distanceToPoint;
227 closestPointToClosestPoint = pointPosition;
231 return fabsf(closestPointToClosestPoint - closestPoint) / 2.0f;
244 float2 localPosition = coord - cellPosition;
249 for (
int j = -1; j <= 1; j++) {
250 for (
int i = -1; i <= 1; i++) {
252 float2 pointPosition = cellOffset +
255 if (distanceToPoint < minDistance) {
256 targetOffset = cellOffset;
257 minDistance = distanceToPoint;
258 targetPosition = pointPosition;
274 float2 localPosition = coord - cellPosition;
276 float smoothDistance = 0.0f;
280 for (
int j = -2; j <= 2; j++) {
281 for (
int i = -2; i <= 2; i++) {
283 float2 pointPosition = cellOffset +
290 0.5f + 0.5f * (smoothDistance - distanceToPoint) /
params.smoothness);
291 float correctionFactor =
params.smoothness * h * (1.0f - h);
292 smoothDistance =
mix(smoothDistance, distanceToPoint, h) - correctionFactor;
293 correctionFactor /= 1.0f + 3.0f *
params.smoothness;
295 smoothColor =
mix(smoothColor, cellColor, h) - correctionFactor;
296 smoothPosition =
mix(smoothPosition, pointPosition, h) - correctionFactor;
302 octave.
color = smoothColor;
310 float2 localPosition = coord - cellPosition;
318 for (
int j = -1; j <= 1; j++) {
319 for (
int i = -1; i <= 1; i++) {
321 float2 pointPosition = cellOffset +
324 if (distanceToPoint < distanceF1) {
325 distanceF2 = distanceF1;
326 distanceF1 = distanceToPoint;
328 offsetF1 = cellOffset;
329 positionF2 = positionF1;
330 positionF1 = pointPosition;
332 else if (distanceToPoint < distanceF2) {
333 distanceF2 = distanceToPoint;
334 offsetF2 = cellOffset;
335 positionF2 = pointPosition;
351 float2 localPosition = coord - cellPosition;
355 for (
int j = -1; j <= 1; j++) {
356 for (
int i = -1; i <= 1; i++) {
358 float2 vectorToPoint = cellOffset +
361 float distanceToPoint =
dot(vectorToPoint, vectorToPoint);
362 if (distanceToPoint < minDistance) {
363 minDistance = distanceToPoint;
364 vectorToClosest = vectorToPoint;
370 for (
int j = -1; j <= 1; j++) {
371 for (
int i = -1; i <= 1; i++) {
373 float2 vectorToPoint = cellOffset +
376 float2 perpendicularToEdge = vectorToPoint - vectorToClosest;
377 if (
dot(perpendicularToEdge, perpendicularToEdge) > 0.0001f) {
378 float distanceToEdge =
dot((vectorToClosest + vectorToPoint) / 2.0f,
380 minDistance =
min(minDistance, distanceToEdge);
392 float2 localPosition = coord - cellPosition;
397 for (
int j = -1; j <= 1; j++) {
398 for (
int i = -1; i <= 1; i++) {
400 float2 pointPosition = cellOffset +
402 float distanceToPoint =
distance(pointPosition, localPosition);
403 if (distanceToPoint < minDistance) {
404 minDistance = distanceToPoint;
405 closestPoint = pointPosition;
406 closestPointOffset = cellOffset;
413 for (
int j = -1; j <= 1; j++) {
414 for (
int i = -1; i <= 1; i++) {
415 if (i == 0 && j == 0) {
419 float2 pointPosition = cellOffset +
421 float distanceToPoint =
distance(closestPoint, pointPosition);
422 if (distanceToPoint < minDistance) {
423 minDistance = distanceToPoint;
424 closestPointToClosestPoint = pointPosition;
429 return distance(closestPointToClosestPoint, closestPoint) / 2.0f;
442 float3 localPosition = coord - cellPosition;
447 for (
int k = -1; k <= 1; k++) {
448 for (
int j = -1; j <= 1; j++) {
449 for (
int i = -1; i <= 1; i++) {
454 if (distanceToPoint < minDistance) {
455 targetOffset = cellOffset;
456 minDistance = distanceToPoint;
457 targetPosition = pointPosition;
474 float3 localPosition = coord - cellPosition;
476 float smoothDistance = 0.0f;
480 for (
int k = -2; k <= 2; k++) {
481 for (
int j = -2; j <= 2; j++) {
482 for (
int i = -2; i <= 2; i++) {
491 0.5f + 0.5f * (smoothDistance - distanceToPoint) /
params.smoothness);
492 float correctionFactor =
params.smoothness * h * (1.0f - h);
493 smoothDistance =
mix(smoothDistance, distanceToPoint, h) - correctionFactor;
494 correctionFactor /= 1.0f + 3.0f *
params.smoothness;
496 smoothColor =
mix(smoothColor, cellColor, h) - correctionFactor;
497 smoothPosition =
mix(smoothPosition, pointPosition, h) - correctionFactor;
504 octave.
color = smoothColor;
512 float3 localPosition = coord - cellPosition;
520 for (
int k = -1; k <= 1; k++) {
521 for (
int j = -1; j <= 1; j++) {
522 for (
int i = -1; i <= 1; i++) {
527 if (distanceToPoint < distanceF1) {
528 distanceF2 = distanceF1;
529 distanceF1 = distanceToPoint;
531 offsetF1 = cellOffset;
532 positionF2 = positionF1;
533 positionF1 = pointPosition;
535 else if (distanceToPoint < distanceF2) {
536 distanceF2 = distanceToPoint;
537 offsetF2 = cellOffset;
538 positionF2 = pointPosition;
555 float3 localPosition = coord - cellPosition;
559 for (
int k = -1; k <= 1; k++) {
560 for (
int j = -1; j <= 1; j++) {
561 for (
int i = -1; i <= 1; i++) {
563 float3 vectorToPoint = cellOffset +
567 float distanceToPoint =
dot(vectorToPoint, vectorToPoint);
568 if (distanceToPoint < minDistance) {
569 minDistance = distanceToPoint;
570 vectorToClosest = vectorToPoint;
577 for (
int k = -1; k <= 1; k++) {
578 for (
int j = -1; j <= 1; j++) {
579 for (
int i = -1; i <= 1; i++) {
581 float3 vectorToPoint = cellOffset +
585 float3 perpendicularToEdge = vectorToPoint - vectorToClosest;
586 if (
dot(perpendicularToEdge, perpendicularToEdge) > 0.0001f) {
587 float distanceToEdge =
dot((vectorToClosest + vectorToPoint) / 2.0f,
589 minDistance =
min(minDistance, distanceToEdge);
602 float3 localPosition = coord - cellPosition;
607 for (
int k = -1; k <= 1; k++) {
608 for (
int j = -1; j <= 1; j++) {
609 for (
int i = -1; i <= 1; i++) {
613 float distanceToPoint =
distance(pointPosition, localPosition);
614 if (distanceToPoint < minDistance) {
615 minDistance = distanceToPoint;
616 closestPoint = pointPosition;
617 closestPointOffset = cellOffset;
625 for (
int k = -1; k <= 1; k++) {
626 for (
int j = -1; j <= 1; j++) {
627 for (
int i = -1; i <= 1; i++) {
628 if (i == 0 && j == 0 && k == 0) {
634 float distanceToPoint =
distance(closestPoint, pointPosition);
635 if (distanceToPoint < minDistance) {
636 minDistance = distanceToPoint;
637 closestPointToClosestPoint = pointPosition;
643 return distance(closestPointToClosestPoint, closestPoint) / 2.0f;
656 float4 localPosition = coord - cellPosition;
661 for (
int u = -1; u <= 1; u++) {
662 for (
int k = -1; k <= 1; k++) {
665 for (
int i = -1; i <= 1; i++) {
670 if (distanceToPoint < minDistance) {
671 targetOffset = cellOffset;
672 minDistance = distanceToPoint;
673 targetPosition = pointPosition;
691 float4 localPosition = coord - cellPosition;
693 float smoothDistance = 0.0f;
697 for (
int u = -2; u <= 2; u++) {
698 for (
int k = -2; k <= 2; k++) {
701 for (
int i = -2; i <= 2; i++) {
710 0.5f + 0.5f * (smoothDistance - distanceToPoint) /
params.smoothness);
711 float correctionFactor =
params.smoothness * h * (1.0f - h);
712 smoothDistance =
mix(smoothDistance, distanceToPoint, h) - correctionFactor;
713 correctionFactor /= 1.0f + 3.0f *
params.smoothness;
715 smoothColor =
mix(smoothColor, cellColor, h) - correctionFactor;
716 smoothPosition =
mix(smoothPosition, pointPosition, h) - correctionFactor;
724 octave.
color = smoothColor;
732 float4 localPosition = coord - cellPosition;
740 for (
int u = -1; u <= 1; u++) {
741 for (
int k = -1; k <= 1; k++) {
744 for (
int i = -1; i <= 1; i++) {
749 if (distanceToPoint < distanceF1) {
750 distanceF2 = distanceF1;
751 distanceF1 = distanceToPoint;
753 offsetF1 = cellOffset;
754 positionF2 = positionF1;
755 positionF1 = pointPosition;
757 else if (distanceToPoint < distanceF2) {
758 distanceF2 = distanceToPoint;
759 offsetF2 = cellOffset;
760 positionF2 = pointPosition;
778 float4 localPosition = coord - cellPosition;
782 for (
int u = -1; u <= 1; u++) {
783 for (
int k = -1; k <= 1; k++) {
786 for (
int i = -1; i <= 1; i++) {
788 float4 vectorToPoint = cellOffset +
792 float distanceToPoint =
dot(vectorToPoint, vectorToPoint);
793 if (distanceToPoint < minDistance) {
794 minDistance = distanceToPoint;
795 vectorToClosest = vectorToPoint;
803 for (
int u = -1; u <= 1; u++) {
804 for (
int k = -1; k <= 1; k++) {
807 for (
int i = -1; i <= 1; i++) {
809 float4 vectorToPoint = cellOffset +
813 float4 perpendicularToEdge = vectorToPoint - vectorToClosest;
814 if (
dot(perpendicularToEdge, perpendicularToEdge) > 0.0001f) {
815 float distanceToEdge =
dot((vectorToClosest + vectorToPoint) / 2.0f,
817 minDistance =
min(minDistance, distanceToEdge);
831 float4 localPosition = coord - cellPosition;
836 for (
int u = -1; u <= 1; u++) {
837 for (
int k = -1; k <= 1; k++) {
840 for (
int i = -1; i <= 1; i++) {
844 float distanceToPoint =
distance(pointPosition, localPosition);
845 if (distanceToPoint < minDistance) {
846 minDistance = distanceToPoint;
847 closestPoint = pointPosition;
848 closestPointOffset = cellOffset;
857 for (
int u = -1; u <= 1; u++) {
858 for (
int k = -1; k <= 1; k++) {
861 for (
int i = -1; i <= 1; i++) {
862 if (i == 0 && j == 0 && k == 0 && u == 0) {
868 float distanceToPoint =
distance(closestPoint, pointPosition);
869 if (distanceToPoint < minDistance) {
870 minDistance = distanceToPoint;
871 closestPointToClosestPoint = pointPosition;
878 return distance(closestPointToClosestPoint, closestPoint) / 2.0f;
889 float amplitude = 1.0f;
890 float max_amplitude = 0.0f;
894 const bool zero_input =
params.detail == 0.0f ||
params.roughness == 0.0f;
900 params.smoothness != 0.0f) ?
905 max_amplitude = 1.0f;
909 else if (i <=
params.detail) {
910 max_amplitude += amplitude;
914 scale *=
params.lacunarity;
915 amplitude *=
params.roughness;
919 if (remainder != 0.0f) {
920 max_amplitude =
mix(max_amplitude, max_amplitude + amplitude, remainder);
932 output.color /= max_amplitude;
946 float amplitude = 1.0f;
947 float max_amplitude =
params.max_distance;
951 const bool zero_input =
params.detail == 0.0f ||
params.roughness == 0.0f;
960 else if (i <=
params.detail) {
961 max_amplitude =
mix(max_amplitude,
params.max_distance / scale, amplitude);
963 scale *=
params.lacunarity;
964 amplitude *=
params.roughness;
968 if (remainder != 0.0f) {
969 float lerp_amplitude =
mix(max_amplitude,
params.max_distance / scale, amplitude);
970 max_amplitude =
mix(max_amplitude, lerp_amplitude, remainder);
992 uint distance_stack_offset, color_stack_offset, position_stack_offset;
993 uint w_out_stack_offset, radius_stack_offset, unused;
996 stack_offsets.
z, &unused, &unused, &distance_stack_offset, &color_stack_offset);
998 stack_offsets.
w, &position_stack_offset, &w_out_stack_offset, &radius_stack_offset);
1012template<u
int node_feature_mask>
1026 uint coord_stack_offset, w_stack_offset, scale_stack_offset, detail_stack_offset;
1027 uint roughness_stack_offset, lacunarity_stack_offset, smoothness_stack_offset,
1028 exponent_stack_offset;
1032 &coord_stack_offset,
1034 &scale_stack_offset,
1035 &detail_stack_offset);
1037 &roughness_stack_offset,
1038 &lacunarity_stack_offset,
1039 &smoothness_stack_offset,
1040 &exponent_stack_offset);
1057 params.max_distance = 0.0f;
1069 switch (
params.feature) {
1073 switch (dimensions) {
1092 float radius = 0.0f;
1093 switch (dimensions) {
1113 switch (dimensions) {
1115 params.max_distance = (0.5f + 0.5f *
params.randomness) *
1124 0.5f + 0.5f *
params.randomness),
1135 0.5f + 0.5f *
params.randomness,
1136 0.5f + 0.5f *
params.randomness),
1147 0.5f + 0.5f *
params.randomness,
1148 0.5f + 0.5f *
params.randomness,
1149 0.5f + 0.5f *
params.randomness),
MINLINE float safe_divide(float a, float b)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
SIMD_FORCE_INLINE btVector3 & normalize()
Normalize this vector x^2 + y^2 + z^2 = 1.
local_group_size(16, 16) .push_constant(Type b
additional_info("compositor_sum_squared_difference_float_shared") .push_constant(Type output_img float dot(value.rgb, luminance_coefficients)") .define("LOAD(value)"
const KernelGlobalsCPU *ccl_restrict KernelGlobals
#define ccl_loop_no_unroll
#define ccl_device_noinline
#define CCL_NAMESPACE_END
ccl_device_inline float3 hash_float_to_float3(float k)
ccl_device_inline float3 hash_float4_to_float3(float4 k)
ccl_device_inline float3 hash_float2_to_float3(float2 k)
ccl_device_inline float2 hash_float2_to_float2(float2 k)
ccl_device_inline float4 hash_float4_to_float4(float4 k)
ccl_device_inline float3 hash_float3_to_float3(float3 k)
ccl_device_inline void stack_store_float3(ccl_private float *stack, uint a, float3 f)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 stack_load_float3(ccl_private float *stack, uint a)
ccl_device_inline uint4 read_node(KernelGlobals kg, ccl_private int *offset)
ccl_device_forceinline void svm_unpack_node_uchar3(uint i, ccl_private uint *x, ccl_private uint *y, ccl_private uint *z)
ccl_device_forceinline void svm_unpack_node_uchar2(uint i, ccl_private uint *x, ccl_private uint *y)
ccl_device_inline float stack_load_float_default(ccl_private float *stack, uint a, uint value)
ccl_device_inline void stack_store_float(ccl_private float *stack, uint a, float f)
ccl_device_forceinline void svm_unpack_node_uchar4(uint i, ccl_private uint *x, ccl_private uint *y, ccl_private uint *z, ccl_private uint *w)
ccl_device_inline bool stack_valid(uint a)
@ NODE_VORONOI_N_SPHERE_RADIUS
@ NODE_VORONOI_DISTANCE_TO_EDGE
NodeVoronoiDistanceMetric
#define IF_KERNEL_NODES_FEATURE(feature)
MINLINE float smoothstep(float edge0, float edge1, float x)
CCL_NAMESPACE_BEGIN ccl_device_inline float2 zero_float2()
ccl_device_inline float2 floor(const float2 a)
ccl_device_inline float reduce_max(const float2 a)
ccl_device_inline float reduce_add(const float2 a)
ccl_device_inline float2 normalize(const float2 a)
ccl_device_inline float2 power(float2 v, float e)
ccl_device_inline float2 fabs(const float2 a)
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
CCL_NAMESPACE_BEGIN ccl_device_inline float4 zero_float4()
float hash_float_to_float(float k)
float distance(float a, float b)
VecBase< float, 4 > float4
ccl_device_inline float4 float3_to_float4(const float3 a)
ccl_device_inline float3 float4_to_float3(const float4 a)
ccl_device_inline float2 float3_to_float2(const float3 a)
ccl_device_inline int clamp(int a, int mn, int mx)
ccl_device VoronoiOutput voronoi_smooth_f1(ccl_private const VoronoiParams ¶ms, const float coord)
ccl_device VoronoiOutput fractal_voronoi_x_fx(ccl_private const VoronoiParams ¶ms, const T coord)
ccl_device VoronoiOutput voronoi_f2(ccl_private const VoronoiParams ¶ms, const float coord)
ccl_device_noinline int svm_node_tex_voronoi(KernelGlobals kg, ccl_private ShaderData *sd, ccl_private float *stack, uint dimensions, uint feature, uint metric, int offset)
ccl_device float voronoi_distance(const float a, const float b)
ccl_device VoronoiOutput voronoi_f1(ccl_private const VoronoiParams ¶ms, const float coord)
ccl_device float fractal_voronoi_distance_to_edge(ccl_private const VoronoiParams ¶ms, const T coord)
ccl_device float voronoi_distance_to_edge(ccl_private const VoronoiParams ¶ms, const float coord)
ccl_device float4 voronoi_position(const float coord)
ccl_device void svm_voronoi_output(const uint4 stack_offsets, ccl_private float *stack, const float distance, const float3 color, const float3 position, const float w, const float radius)
ccl_device float voronoi_n_sphere_radius(ccl_private const VoronoiParams ¶ms, const float coord)