[Bf-blender-cvs] [bbaa6a6728f] cycles_procedural_api: add support for RGBA attributes

Kévin Dietrich noreply at git.blender.org
Sat Oct 3 04:18:22 CEST 2020


Commit: bbaa6a6728fc7afa14114a106c2267ac6b3f9e3d
Author: Kévin Dietrich
Date:   Mon Sep 28 14:59:41 2020 +0200
Branches: cycles_procedural_api
https://developer.blender.org/rBbbaa6a6728fc7afa14114a106c2267ac6b3f9e3d

add support for RGBA attributes

===================================================================

M	intern/cycles/render/alembic.cpp

===================================================================

diff --git a/intern/cycles/render/alembic.cpp b/intern/cycles/render/alembic.cpp
index 1b60540ba27..e6559583c87 100644
--- a/intern/cycles/render/alembic.cpp
+++ b/intern/cycles/render/alembic.cpp
@@ -309,6 +309,40 @@ void AlembicObject::read_attribute(const ICompoundProperty &arb_geom_params,
           v = (*values)[tri.z];
           data_uchar4[offset + 2] = color_float_to_byte(make_float3(v.x, v.y, v.z));
 
+          offset += 3;
+        }
+      }
+    }
+    else if (IC4fProperty::matches(prop.getMetaData())) {
+      const IC4fGeomParam &param = IC4fGeomParam(arb_geom_params, prop.getName());
+
+      IC4fGeomParam::Sample sample;
+      param.getIndexed(sample, iss);
+
+      C4fArraySamplePtr values = sample.getVals();
+
+      AttributeData &attribute = data_cache.attributes.emplace_back();
+      attribute.std = ATTR_STD_NONE;
+      attribute.name = attr_name;
+
+      if (param.getScope() == kVaryingScope) {
+        attribute.element = ATTR_ELEMENT_CORNER_BYTE;
+        attribute.type_desc = TypeRGBA;
+        attribute.data.resize(data_cache.triangles.size() * 3 * sizeof(uchar4));
+
+        uchar4 *data_uchar4 = reinterpret_cast<uchar4 *>(attribute.data.data());
+
+        int offset = 0;
+        for (const int3 &tri : data_cache.triangles) {
+          Imath::C4f v = (*values)[tri.x];
+          data_uchar4[offset + 0] = color_float4_to_uchar4(make_float4(v.r, v.g, v.b, v.a));
+
+          v = (*values)[tri.y];
+          data_uchar4[offset + 1] = color_float4_to_uchar4(make_float4(v.r, v.g, v.b, v.a));
+
+          v = (*values)[tri.z];
+          data_uchar4[offset + 2] = color_float4_to_uchar4(make_float4(v.r, v.g, v.b, v.a));
+
           offset += 3;
         }
       }



More information about the Bf-blender-cvs mailing list