From 697fd86506fd0caaa41e2fbf0463b5229d09251e Mon Sep 17 00:00:00 2001 From: Mai Lavelle Date: Wed, 14 Aug 2019 01:53:09 -0400 Subject: Cycles: Stitching of subdivided and displaced meshes This patch stitches the vertices along patch edges so that cracks can no longer form when applying subdivision or displacement a mesh. Subpatches are now formed in a way that ensures vertex indices along subpatch edges are equal for adjacent subpatches. A mapping of vertices along patch edges is built to preform stitching. Overall performance is roughly the same, some gains were made in splitting, but some was lost in stitching. This fixes: - T49049 (cracks between patches from material and uv seams) - T49048 (discontinuous normals with true displacement) Reviewers: sergey, brecht Differential Revision: https://developer.blender.org/D3692 --- intern/cycles/subd/subd_split.h | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) (limited to 'intern/cycles/subd/subd_split.h') diff --git a/intern/cycles/subd/subd_split.h b/intern/cycles/subd/subd_split.h index 6e68d8ee598..0fc22872c62 100644 --- a/intern/cycles/subd/subd_split.h +++ b/intern/cycles/subd/subd_split.h @@ -23,35 +23,51 @@ * for more details. */ #include "subd/subd_dice.h" +#include "subd/subd_subpatch.h" +#include "util/util_deque.h" #include "util/util_types.h" #include "util/util_vector.h" +#include + CCL_NAMESPACE_BEGIN class Mesh; class Patch; -#define DSPLIT_NON_UNIFORM -1 - class DiagSplit { - public: - vector subpatches_quad; - vector edgefactors_quad; - SubdParams params; - explicit DiagSplit(const SubdParams ¶ms); + vector subpatches; + /* deque is used so that element pointers remain vaild when size is changed. */ + deque edges; float3 to_world(Patch *patch, float2 uv); - int T(Patch *patch, float2 Pstart, float2 Pend); + int T(Patch *patch, float2 Pstart, float2 Pend, bool recursive_resolve=false); + + void limit_edge_factor(int &T, Patch *patch, float2 Pstart, float2 Pend); + void resolve_edge_factors(Subpatch &sub); + void partition_edge( Patch *patch, float2 *P, int *t0, int *t1, float2 Pstart, float2 Pend, int t); - void dispatch(QuadDice::SubPatch &sub, QuadDice::EdgeFactors &ef); - void split(QuadDice::SubPatch &sub, QuadDice::EdgeFactors &ef, int depth = 0); + void split(Subpatch &sub, int depth = 0); + + int num_alloced_verts = 0; + int alloc_verts(int n); /* Returns start index of new verts. */ + + public: + Edge *alloc_edge(); + + explicit DiagSplit(const SubdParams ¶ms); + + void split_patches(Patch *patches, size_t patches_byte_stride); + + void split_quad(const Mesh::SubdFace &face, Patch *patch); + void split_ngon(const Mesh::SubdFace &face, Patch *patches, size_t patches_byte_stride); - void split_quad(Patch *patch, QuadDice::SubPatch *subpatch = NULL); + void post_split(); }; CCL_NAMESPACE_END -- cgit v1.2.3