26 b.add_input<
decl::Int>(
N_(
"Level")).default_value(1).min(0).max(6);
44 uiItemR(layout,
ptr,
"uv_smooth", 0,
"", ICON_NONE);
45 uiItemR(layout,
ptr,
"boundary_smooth", 0,
"", ICON_NONE);
56 #ifdef WITH_OPENSUBDIV
57 static void materialize_and_clamp_creases(
const VArray<float> &crease_varray,
61 crease_varray.materialize(range, creases);
62 for (const int i : range) {
63 creases[i] = std::clamp(creases[i], 0.0f, 1.0f);
68 static void write_vertex_creases(
Mesh &
mesh,
const VArray<float> &crease_varray)
75 crease =
static_cast<float *
>(
78 materialize_and_clamp_creases(crease_varray, {crease,
mesh.
totvert});
81 static void write_edge_creases(
MeshComponent &
mesh,
const VArray<float> &crease_varray)
83 bke::SpanAttributeWriter<float>
attribute =
84 mesh.attributes_for_write()->lookup_or_add_for_write_only_span<
float>(
"crease",
86 materialize_and_clamp_creases(crease_varray,
attribute.span);
90 static bool varray_is_nonzero(
const VArray<float> &varray)
92 return !(varray.is_single() && varray.get_internal_single() == 0.0f);
99 #ifndef WITH_OPENSUBDIV
100 params.error_message_add(NodeWarningType::Error,
101 TIP_(
"Disabled, Blender was compiled without OpenSubdiv"));
107 const int uv_smooth = storage.uv_smooth;
108 const int boundary_smooth = storage.boundary_smooth;
109 const int subdiv_level =
clamp_i(
params.extract_input<
int>(
"Level"), 0, 30);
112 if (subdiv_level == 0) {
113 params.set_output(
"Mesh", std::move(geometry_set));
124 const int edges_num = mesh_component.attribute_domain_size(
ATTR_DOMAIN_EDGE);
125 if (verts_num == 0 || edges_num == 0) {
131 point_evaluator.
add(vertex_crease_field);
137 edge_evaluator.
add(edge_crease_field);
141 const bool use_creases = varray_is_nonzero(vertex_creases) || varray_is_nonzero(edge_creases);
150 mesh_settings.
resolution = (1 << subdiv_level) + 1;
158 subdiv_settings.
level = subdiv_level;
171 if (subdiv ==
nullptr) {
182 params.set_output(
"Mesh", std::move(geometry_set));
201 "NodeGeometrySubdivisionSurface",
bool CustomData_has_layer(const struct CustomData *data, int type)
void * CustomData_get_layer(const struct CustomData *data, int type)
void * CustomData_add_layer(struct CustomData *data, int type, eCDAllocType alloctype, void *layer, int totelem)
@ GEO_COMPONENT_TYPE_MESH
#define GEO_NODE_SUBDIVISION_SURFACE
#define NODE_STORAGE_FUNCS(StorageT)
void node_type_init(struct bNodeType *ntype, void(*initfunc)(struct bNodeTree *ntree, struct bNode *node))
void node_type_size_preset(struct bNodeType *ntype, eNodeSizePreset size)
#define NODE_CLASS_GEOMETRY
void node_type_storage(struct bNodeType *ntype, const char *storagename, void(*freefunc)(struct bNode *node), void(*copyfunc)(struct bNodeTree *dest_ntree, struct bNode *dest_node, const struct bNode *src_node))
void nodeRegisterType(struct bNodeType *ntype)
eSubdivVtxBoundaryInterpolation BKE_subdiv_vtx_boundary_interpolation_from_subsurf(int boundary_smooth)
void BKE_subdiv_free(Subdiv *subdiv)
Subdiv * BKE_subdiv_update_from_mesh(Subdiv *subdiv, const SubdivSettings *settings, const struct Mesh *mesh)
eSubdivFVarLinearInterpolation BKE_subdiv_fvar_interpolation_from_uv_smooth(int uv_smooth)
struct Mesh * BKE_subdiv_to_mesh(struct Subdiv *subdiv, const SubdivToMeshSettings *settings, const struct Mesh *coarse_mesh)
MINLINE int clamp_i(int value, int min, int max)
@ SUBSURF_BOUNDARY_SMOOTH_ALL
@ SUBSURF_UV_SMOOTH_PRESERVE_BOUNDARIES
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Sky Generate a procedural sky texture Noise Generate fractal Perlin noise Wave Generate procedural bands or rings with noise Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a or normal between and object coordinate space Combine Create a color from its and value channels Color Retrieve a color attribute
void uiItemR(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int flag, const char *name, int icon)
int attribute_domain_size(eAttrDomain domain) const
constexpr IndexRange index_range() const
int add(GField field, GVArray *varray_ptr)
const GVArray & get_evaluated(const int field_index) const
static void node_geo_exec(GeoNodeExecParams params)
static void node_layout(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
static void node_declare(NodeDeclarationBuilder &b)
static void node_init(bNodeTree *UNUSED(ntree), bNode *node)
void parallel_for(IndexRange range, int64_t grain_size, const Function &function)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static void node_init(const struct bContext *C, bNodeTree *ntree, bNode *node)
void register_node_type_geo_subdivision_surface()
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
void node_copy_standard_storage(bNodeTree *UNUSED(dest_ntree), bNode *dest_node, const bNode *src_node)
void node_free_standard_storage(bNode *node)
void replace_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
GeometryComponent & get_component_for_write(GeometryComponentType component_type)
const GeometryComponent * get_component_for_read(GeometryComponentType component_type) const
const Mesh * get_mesh_for_read() const
Mesh * get_mesh_for_write()
void modify_geometry_sets(ForeachSubGeometryCallback callback)
eSubdivFVarLinearInterpolation fvar_linear_interpolation
eSubdivVtxBoundaryInterpolation vtx_boundary_interpolation
NodeGeometryExecFunction geometry_node_execute
void(* draw_buttons)(struct uiLayout *, struct bContext *C, struct PointerRNA *ptr)
NodeDeclareFunction declare