diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2021-06-16 10:39:26 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2021-06-16 10:39:39 +0300 |
commit | 00fc110d3f9d33471af8e3f9f8a71c732e1a4bdd (patch) | |
tree | 4e153bcaa5c1860202eae8e30f13906998e0e5b9 /intern | |
parent | 1c0a490d0e76c56c2980bdf48b33b3e6bc981e5c (diff) |
Alembic procedural: support reading per-vertex UV sets
This adds support for importing UV sets which are defined per vertex,
instead of per face corners. Such UV sets can be generated when the
mesh is split according to UV islands, or when there is only one UV
island, in which cases only a single UV value can be stored per
vertex since vertices will never be on a seam.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/render/alembic_read.cpp | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/intern/cycles/render/alembic_read.cpp b/intern/cycles/render/alembic_read.cpp index 33ce3502879..c53ec668938 100644 --- a/intern/cycles/render/alembic_read.cpp +++ b/intern/cycles/render/alembic_read.cpp @@ -736,13 +736,14 @@ static void process_uvs(CachedData &cache, const IV2fGeomParam::Sample &sample, double time) { - if (scope != kFacevaryingScope) { + if (scope != kFacevaryingScope && scope != kVaryingScope && scope != kVertexScope) { return; } const array<int> *uv_loops = cache.uv_loops.data_for_time_no_check(time).get_data_or_null(); - if (!uv_loops) { + /* It's ok to not have loop indices, as long as the scope is not face-varying. */ + if (!uv_loops && scope == kFacevaryingScope) { return; } @@ -766,9 +767,27 @@ static void process_uvs(CachedData &cache, const uint32_t *indices = sample.getIndices()->get(); const V2f *values = sample.getVals()->get(); - for (const int uv_loop_index : *uv_loops) { - const uint32_t index = indices[uv_loop_index]; - *data_float2++ = make_float2(values[index][0], values[index][1]); + if (scope == kFacevaryingScope) { + for (const int uv_loop_index : *uv_loops) { + const uint32_t index = indices[uv_loop_index]; + *data_float2++ = make_float2(values[index][0], values[index][1]); + } + } + else if (scope == kVaryingScope || scope == kVertexScope) { + if (triangles) { + for (size_t i = 0; i < triangles->size(); i++) { + const int3 t = (*triangles)[i]; + *data_float2++ = make_float2(values[t.x][0], values[t.x][1]); + *data_float2++ = make_float2(values[t.y][0], values[t.y][1]); + *data_float2++ = make_float2(values[t.z][0], values[t.z][1]); + } + } + else if (corners) { + for (size_t i = 0; i < corners->size(); i++) { + const int c = (*corners)[i]; + *data_float2++ = make_float2(values[c][0], values[c][1]); + } + } } attribute.data.add_data(data, time); |