diff options
author | Brecht Van Lommel <brecht@blender.org> | 2021-12-01 19:30:46 +0300 |
---|---|---|
committer | Brecht Van Lommel <brecht@blender.org> | 2021-12-16 22:54:04 +0300 |
commit | 35b1e9fc3acd6db565e7e54252a4a4152d8343d9 (patch) | |
tree | 8599df3b2be192d1fe19d30a8afb7e8d8729499e /intern/cycles/kernel/geom/primitive.h | |
parent | 2229179faa44e2c685b4eabd0c51d4c7d5c1f193 (diff) |
Cycles: pointcloud rendering
This add support for rendering of the point cloud object in Blender, as a native
geometry type in Cycles that is more memory and time efficient than instancing
sphere meshes. This can be useful for rendering sand, water splashes, particles,
motion graphics, etc.
Points are currently always rendered as spheres, with backface culling. More
shapes are likely to be added later, but this is the most important one and can
be customized with shaders.
For CPU rendering the Embree primitive is used, for GPU there is our own
intersection code. Motion blur is suppored. Volumes inside points are not
currently supported.
Implemented with help from:
* Kévin Dietrich: Alembic procedural integration
* Patrick Mourse: OptiX integration
* Josh Whelchel: update for cycles-x changes
Ref T92573
Differential Revision: https://developer.blender.org/D9887
Diffstat (limited to 'intern/cycles/kernel/geom/primitive.h')
-rw-r--r-- | intern/cycles/kernel/geom/primitive.h | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/intern/cycles/kernel/geom/primitive.h b/intern/cycles/kernel/geom/primitive.h index 6d7b550d82f..9416385638c 100644 --- a/intern/cycles/kernel/geom/primitive.h +++ b/intern/cycles/kernel/geom/primitive.h @@ -48,6 +48,11 @@ ccl_device_inline float primitive_surface_attribute_float(KernelGlobals kg, return curve_attribute_float(kg, sd, desc, dx, dy); } #endif +#ifdef __POINTCLOUD__ + else if (sd->type & PRIMITIVE_ALL_POINT) { + return point_attribute_float(kg, sd, desc, dx, dy); + } +#endif else { if (dx) *dx = 0.0f; @@ -74,6 +79,11 @@ ccl_device_inline float2 primitive_surface_attribute_float2(KernelGlobals kg, return curve_attribute_float2(kg, sd, desc, dx, dy); } #endif +#ifdef __POINTCLOUD__ + else if (sd->type & PRIMITIVE_ALL_POINT) { + return point_attribute_float2(kg, sd, desc, dx, dy); + } +#endif else { if (dx) *dx = make_float2(0.0f, 0.0f); @@ -100,6 +110,11 @@ ccl_device_inline float3 primitive_surface_attribute_float3(KernelGlobals kg, return curve_attribute_float3(kg, sd, desc, dx, dy); } #endif +#ifdef __POINTCLOUD__ + else if (sd->type & PRIMITIVE_ALL_POINT) { + return point_attribute_float3(kg, sd, desc, dx, dy); + } +#endif else { if (dx) *dx = make_float3(0.0f, 0.0f, 0.0f); @@ -126,6 +141,11 @@ ccl_device_forceinline float4 primitive_surface_attribute_float4(KernelGlobals k return curve_attribute_float4(kg, sd, desc, dx, dy); } #endif +#ifdef __POINTCLOUD__ + else if (sd->type & PRIMITIVE_ALL_POINT) { + return point_attribute_float4(kg, sd, desc, dx, dy); + } +#endif else { if (dx) *dx = make_float4(0.0f, 0.0f, 0.0f, 0.0f); @@ -225,8 +245,8 @@ ccl_device bool primitive_ptex(KernelGlobals kg, ccl_device float3 primitive_tangent(KernelGlobals kg, ccl_private ShaderData *sd) { -#ifdef __HAIR__ - if (sd->type & PRIMITIVE_ALL_CURVE) +#if defined(__HAIR__) || defined(__POINTCLOUD__) + if (sd->type & (PRIMITIVE_ALL_CURVE | PRIMITIVE_ALL_POINT)) # ifdef __DPDU__ return normalize(sd->dPdu); # else @@ -261,10 +281,21 @@ ccl_device_inline float4 primitive_motion_vector(KernelGlobals kg, /* center position */ float3 center; -#ifdef __HAIR__ - bool is_curve_primitive = sd->type & PRIMITIVE_ALL_CURVE; - if (is_curve_primitive) { - center = curve_motion_center_location(kg, sd); +#if defined(__HAIR__) || defined(__POINTCLOUD__) + bool is_curve_or_point = sd->type & (PRIMITIVE_ALL_CURVE | PRIMITIVE_ALL_POINT); + if (is_curve_or_point) { + center = make_float3(0.0f, 0.0f, 0.0f); + + if (sd->type & PRIMITIVE_ALL_CURVE) { +# if defined(__HAIR__) + center = curve_motion_center_location(kg, sd); +# endif + } + else if (sd->type & PRIMITIVE_ALL_POINT) { +# if defined(__POINTCLOUD__) + center = point_motion_center_location(kg, sd); +# endif + } if (!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) { object_position_transform(kg, sd, ¢er); @@ -272,7 +303,9 @@ ccl_device_inline float4 primitive_motion_vector(KernelGlobals kg, } else #endif + { center = sd->P; + } float3 motion_pre = center, motion_post = center; @@ -284,8 +317,8 @@ ccl_device_inline float4 primitive_motion_vector(KernelGlobals kg, int numverts, numkeys; object_motion_info(kg, sd->object, NULL, &numverts, &numkeys); -#ifdef __HAIR__ - if (is_curve_primitive) { +#if defined(__HAIR__) || defined(__POINTCLOUD__) + if (is_curve_or_point) { motion_pre = float4_to_float3(curve_attribute_float4(kg, sd, desc, NULL, NULL)); desc.offset += numkeys; motion_post = float4_to_float3(curve_attribute_float4(kg, sd, desc, NULL, NULL)); |