blender/intern/cycles/scene/alembic_read.h
Kévin Dietrich 4425e0cd64 Subdivision: add support for vertex creasing
This adds vertex creasing support for OpenSubDiv for modeling, rendering,
Alembic and USD I/O.

For modeling, vertex creasing follows the edge creasing implementation with an
operator accessible through the Vertex menu in Edit Mode, and some parameter in
the properties panel. The option in the Subsurf and Multires to use edge
creasing also affects vertex creasing.

The vertex crease data is stored as a CustomData layer, unlike edge creases
which for now are stored in `MEdge`, but will in the future also be moved to
a `CustomData` layer. See comments for details on the difference in behavior
for the `CD_CREASE` layer between egdes and vertices.

For Cycles this adds sockets on the Mesh node to hold data about which vertices
are creased (one socket for the indices, one for the weigths).

Viewport rendering of vertex creasing reuses the same color scheme as for edges
and creased vertices are drawn bigger than uncreased vertices.

For Alembic and USD, vertex crease support follows the edge crease
implementation, they are always read, but only exported if a `Subsurf` modifier
is present on the Mesh.

Reviewed By: brecht, fclem, sergey, sybren, campbellbarton

Differential Revision: https://developer.blender.org/D10145
2022-01-20 12:21:34 +01:00

156 lines
5.0 KiB
C++

/*
* Copyright 2021 Blender Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#ifdef WITH_ALEMBIC
# include <Alembic/AbcCoreFactory/All.h>
# include <Alembic/AbcGeom/All.h>
# include "util/vector.h"
CCL_NAMESPACE_BEGIN
class AlembicProcedural;
class AttributeRequestSet;
class Progress;
struct CachedData;
/* Maps a FaceSet whose name matches that of a Shader to the index of said shader in the Geometry's
* used_shaders list. */
struct FaceSetShaderIndexPair {
Alembic::AbcGeom::IFaceSet face_set;
int shader_index;
};
/* Data of an IPolyMeshSchema that we need to read. */
struct PolyMeshSchemaData {
Alembic::AbcGeom::TimeSamplingPtr time_sampling;
size_t num_samples;
Alembic::AbcGeom::MeshTopologyVariance topology_variance;
Alembic::AbcGeom::IP3fArrayProperty positions;
Alembic::AbcGeom::IInt32ArrayProperty face_indices;
Alembic::AbcGeom::IInt32ArrayProperty face_counts;
Alembic::AbcGeom::IN3fGeomParam normals;
vector<FaceSetShaderIndexPair> shader_face_sets;
// Unsupported for now.
Alembic::AbcGeom::IV3fArrayProperty velocities;
};
void read_geometry_data(AlembicProcedural *proc,
CachedData &cached_data,
const PolyMeshSchemaData &data,
Progress &progress);
/* Data of an ISubDSchema that we need to read. */
struct SubDSchemaData {
Alembic::AbcGeom::TimeSamplingPtr time_sampling;
size_t num_samples;
Alembic::AbcGeom::MeshTopologyVariance topology_variance;
Alembic::AbcGeom::IInt32ArrayProperty face_counts;
Alembic::AbcGeom::IInt32ArrayProperty face_indices;
Alembic::AbcGeom::IP3fArrayProperty positions;
Alembic::AbcGeom::IInt32ArrayProperty crease_indices;
Alembic::AbcGeom::IInt32ArrayProperty crease_lengths;
Alembic::AbcGeom::IFloatArrayProperty crease_sharpnesses;
vector<FaceSetShaderIndexPair> shader_face_sets;
Alembic::AbcGeom::IInt32ArrayProperty corner_indices;
Alembic::AbcGeom::IFloatArrayProperty corner_sharpnesses;
// Those are unsupported for now.
Alembic::AbcGeom::IInt32Property face_varying_interpolate_boundary;
Alembic::AbcGeom::IInt32Property face_varying_propagate_corners;
Alembic::AbcGeom::IInt32Property interpolate_boundary;
Alembic::AbcGeom::IInt32ArrayProperty holes;
Alembic::AbcGeom::IStringProperty subdivision_scheme;
Alembic::AbcGeom::IV3fArrayProperty velocities;
};
void read_geometry_data(AlembicProcedural *proc,
CachedData &cached_data,
const SubDSchemaData &data,
Progress &progress);
/* Data of a ICurvesSchema that we need to read. */
struct CurvesSchemaData {
Alembic::AbcGeom::TimeSamplingPtr time_sampling;
size_t num_samples;
Alembic::AbcGeom::MeshTopologyVariance topology_variance;
Alembic::AbcGeom::IP3fArrayProperty positions;
Alembic::AbcGeom::IInt32ArrayProperty num_vertices;
float default_radius;
float radius_scale;
// Those are unsupported for now.
Alembic::AbcGeom::IV3fArrayProperty velocities;
// if this property is invalid then the weight for every point is 1
Alembic::AbcGeom::IFloatArrayProperty position_weights;
Alembic::AbcGeom::IN3fGeomParam normals;
Alembic::AbcGeom::IFloatGeomParam widths;
Alembic::AbcGeom::IUcharArrayProperty orders;
Alembic::AbcGeom::IFloatArrayProperty knots;
// TODO(@kevindietrich): type, basis, wrap
};
void read_geometry_data(AlembicProcedural *proc,
CachedData &cached_data,
const CurvesSchemaData &data,
Progress &progress);
/* Data of a ICurvesSchema that we need to read. */
struct PointsSchemaData {
Alembic::AbcGeom::TimeSamplingPtr time_sampling;
size_t num_samples;
float default_radius;
float radius_scale;
Alembic::AbcGeom::IP3fArrayProperty positions;
Alembic::AbcGeom::IInt32ArrayProperty num_points;
Alembic::AbcGeom::IFloatGeomParam radiuses;
// Those are unsupported for now.
Alembic::AbcGeom::IV3fArrayProperty velocities;
};
void read_geometry_data(AlembicProcedural *proc,
CachedData &cached_data,
const PointsSchemaData &data,
Progress &progress);
void read_attributes(AlembicProcedural *proc,
CachedData &cache,
const Alembic::AbcGeom::ICompoundProperty &arb_geom_params,
const Alembic::AbcGeom::IV2fGeomParam &default_uvs_param,
const AttributeRequestSet &requested_attributes,
Progress &progress);
CCL_NAMESPACE_END
#endif