Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2022-01-25 15:25:33 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-01-25 19:14:20 +0300
commitc813a1b3583e9a3bf17c75e16995ebadb046361a (patch)
tree8f5405c7f0a05aef8d43342764fc0a42ef577a54 /intern/cycles/kernel/geom/point.h
parenteab066cbf2da1fdb8162d9ed814a9491f9acf02d (diff)
Cycles: add Point Info node
With (center) position, radius and random value outputs. Eevee does not yet support rendering point clouds, but an untested implementation of this node was added for when it does. Ref T92573
Diffstat (limited to 'intern/cycles/kernel/geom/point.h')
-rw-r--r--intern/cycles/kernel/geom/point.h44
1 files changed, 43 insertions, 1 deletions
diff --git a/intern/cycles/kernel/geom/point.h b/intern/cycles/kernel/geom/point.h
index 23764d49095..545b5c7fa43 100644
--- a/intern/cycles/kernel/geom/point.h
+++ b/intern/cycles/kernel/geom/point.h
@@ -109,17 +109,59 @@ ccl_device float4 point_attribute_float4(KernelGlobals kg,
}
}
+/* Point position */
+
+ccl_device float3 point_position(KernelGlobals kg, ccl_private const ShaderData *sd)
+{
+ if (sd->type & PRIMITIVE_POINT) {
+ /* World space center. */
+ float3 P = (sd->type & PRIMITIVE_MOTION) ?
+ float4_to_float3(motion_point(kg, sd->object, sd->prim, sd->time)) :
+ float4_to_float3(kernel_tex_fetch(__points, sd->prim));
+
+ if (!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
+ object_position_transform(kg, sd, &P);
+ }
+
+ return P;
+ }
+
+ return zero_float3();
+}
+
/* Point radius */
ccl_device float point_radius(KernelGlobals kg, ccl_private const ShaderData *sd)
{
if (sd->type & PRIMITIVE_POINT) {
- return kernel_tex_fetch(__points, sd->prim).w;
+ /* World space radius. */
+ const float r = kernel_tex_fetch(__points, sd->prim).w;
+
+ if (sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED) {
+ return r;
+ }
+ else {
+ float3 dir = make_float3(r, r, r);
+ object_dir_transform(kg, sd, &dir);
+ return average(dir);
+ }
}
return 0.0f;
}
+/* Point random */
+
+ccl_device float point_random(KernelGlobals kg, ccl_private const ShaderData *sd)
+{
+ if (sd->type & PRIMITIVE_POINT) {
+ const AttributeDescriptor desc = find_attribute(kg, sd, ATTR_STD_POINT_RANDOM);
+ return (desc.offset != ATTR_STD_NOT_FOUND) ? point_attribute_float(kg, sd, desc, NULL, NULL) :
+ 0.0f;
+ }
+ return 0.0f;
+}
+
/* Point location for motion pass, linear interpolation between keys and
* ignoring radius because we do the same for the motion keys */