Blender V5.3
scene/pointcloud.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include "scene/geometry.h"
8
10
11class PointCloud : public Geometry {
12 public:
14
19
20 /* Default values for Gaussian splat attributes, matching defaults in Blender EEVEE.
21 * Default rotation is an identity quaternion. */
22 static inline const float4 DEFAULT_GSPLAT_RADIANCE_BASE = make_float4(0.0f, 0.0f, 0.0f, 0.5f);
23 static inline const float3 DEFAULT_GSPLAT_SCALE = make_float3(1e-3f, 1e-3f, 1e-3f);
24
25 /* PointCloud Point */
26 struct Point {
27 int index;
28
29 void bounds_grow(const packed_float3 *points, const float *radius, BoundBox &bounds) const;
30 void bounds_grow(const packed_float3 *points,
31 const float *radius,
32 const Transform &aligned_space,
33 BoundBox &bounds) const;
34 void bounds_grow(const float4 &point, BoundBox &bounds) const;
35
36 float4 motion_key(const float *radius,
37 const Attribute *attr_P,
38 const Attribute *attr_R,
39 const size_t num_steps,
40 const float time,
41 size_t p) const;
42 float4 point_for_step(const float *radius,
43 const Attribute *attr_P,
44 const Attribute *attr_R,
45 const size_t step,
46 size_t p) const;
47 };
48
50
51 /* Constructor/Destructor */
52 PointCloud();
53 ~PointCloud() override;
54
55 /* Geometry */
56 void clear_non_sockets();
57 void clear(const bool preserve_shaders = false) override;
58
59 void resize(const int numpoints);
60
62
63 void compute_bounds() override;
64 void apply_transform(const Transform &tfm, const bool apply_to_motion) override;
65
66 /* Points */
67 Point get_point(const int i) const
68 {
69 Point point = {i};
70 return point;
71 }
72
73 size_t num_points() const
74 {
76 return attr ? attr->size : 0;
77 }
78
79 size_t num_attributes() const
80 {
81 return 1;
82 }
83
84 /* UDIM */
85 void get_uv_tiles(ustring map, unordered_set<int> &tiles) override;
86
87 PrimitiveType primitive_type() const override;
88
89 /* BVH */
90 void pack(Scene *scene, uint *packed_shader);
91
92 /* Recalculate point radius to bound Gaussian splats. */
94
95 /* Create attributes that are required but missing for rendering the point cloud as a 3D
96 * gaussian splat. This includes radiance base, scale, and rotation. The attributes are filled
97 * with default values:
98 * - Radiance base is a half-opaque, neutral grey color.
99 * - Scale is a small value, mainly obtained empirically with the goal to provide a way to get
100 * an idea of the shape of the 3D Gaussian splat without requiring too much render time.
101 * - Rotation is defaulted to identity quaternion. */
103
104 NODE_SOCKET_API(RenderAs, render_as)
105
106 private:
107 void add_builtin_attributes();
108
109 friend class BVH2;
110 friend class BVHBuild;
111 friend class BVHSpatialSplit;
112 friend class DiagSplit;
113 friend class EdgeDice;
114 friend class GeometryManager;
115 friend class ObjectManager;
116};
117
Attribute * find(ustring name) const
int motion_step(const float time) const
BoundBox bounds
AttributeSet attributes
Geometry(const NodeType *node_type, const Type type)
size_t num_attributes() const
friend class EdgeDice
void update_gsplat_radii()
friend class BVHSpatialSplit
void clear(const bool preserve_shaders=false) override
Point get_point(const int i) const
void resize(const int numpoints)
friend class GeometryManager
void create_missing_gsplat_attributes()
friend class BVH2
friend class ObjectManager
void apply_transform(const Transform &tfm, const bool apply_to_motion) override
friend class BVHBuild
void get_uv_tiles(ustring map, unordered_set< int > &tiles) override
size_t num_points() const
static const float4 DEFAULT_GSPLAT_RADIANCE_BASE
~PointCloud() override
void copy_center_to_motion_step(const int motion_step)
void pack(Scene *scene, uint *packed_shader)
void compute_bounds() override
PrimitiveType primitive_type() const override
static const float3 DEFAULT_GSPLAT_SCALE
friend class DiagSplit
Definition scene.h:133
#define CCL_NAMESPACE_END
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
#define NODE_SOCKET_API_ARRAY(type_, name)
Definition graph/node.h:64
#define NODE_SOCKET_API(type_, name)
Definition graph/node.h:56
ccl_gpu_kernel_postfix ccl_global KernelWorkTile * tiles
PrimitiveType
@ ATTR_STD_POSITION
#define NODE_DECLARE
Definition node_type.h:150
#define make_float4
float4 point_for_step(const float *radius, const Attribute *attr_P, const Attribute *attr_R, const size_t step, size_t p) const
void bounds_grow(const packed_float3 *points, const float *radius, BoundBox &bounds) const
float4 motion_key(const float *radius, const Attribute *attr_P, const Attribute *attr_R, const size_t num_steps, const float time, size_t p) const