Fix: USD: Support color attributes on all relevant domains
Color primvars/attributes were historically treated as a special case for both import and export. This was mostly done to align with how painting and viewport display works in Blender. Export would generally ignore color attributes except when they were found on a Mesh's Point or FaceCorner domains. And import went out of its way to map incoming color primvars to the FaceCorner domain in more situations than necessary. To facilitate better roundtripping in Blender<=>USD workflows, and to reduce code duplication, this PR teaches the common attribute utilities how to handle color types. The color attributes will now work on all relevant Mesh and Curve domains. There were tests in place for this already but they were set to verify the inverse state, i.e. the technically broken state, until this could be fixed. There remains one special case: "displayColor" primvars and attributes. The "displayColor" is a special primvar in USD and is the de-facto way to set a simple viewport color in that ecosystem. It must also be a color3f type. In order to not regress import, if a "displayColor" primvar is found on the Face domain we will map it to FaceCorner instead so it can be displayed in the viewport; which has been the case for the past several releases. We can drop this special-case if/when Blender can display Face colors through the Viewport Shading "Attribute" color type. Additionally, Blender will export this, and only this, color attribute as a color3f. Note: As was the case prior to this PR, the following 2 discrepancies still prevent "perfect" round-trips: - USD does not have an equivalent to Blender's byte colors; they are treated as float during IO - Blender does not have an equivalent to USD's color3 types; they are treated as color4 during IO Pull Request: https://projects.blender.org/blender/blender/pulls/127784
This commit is contained in:
committed by
Jesse Yurkovich
parent
a6d5652043
commit
2cdbe7b5f3
@@ -270,8 +270,8 @@ class USDExportTest(AbstractUSDTest):
|
||||
self.check_primvar(prim, "f_int8", "VtArray<unsigned char>", "uniform", 1)
|
||||
self.check_primvar(prim, "f_int32", "VtArray<int>", "uniform", 1)
|
||||
self.check_primvar(prim, "f_float", "VtArray<float>", "uniform", 1)
|
||||
self.check_primvar_missing(prim, "f_color")
|
||||
self.check_primvar_missing(prim, "f_byte_color")
|
||||
self.check_primvar(prim, "f_color", "VtArray<GfVec4f>", "uniform", 1)
|
||||
self.check_primvar(prim, "f_byte_color", "VtArray<GfVec4f>", "uniform", 1)
|
||||
self.check_primvar(prim, "f_vec2", "VtArray<GfVec2f>", "uniform", 1)
|
||||
self.check_primvar(prim, "f_vec3", "VtArray<GfVec3f>", "uniform", 1)
|
||||
self.check_primvar(prim, "f_quat", "VtArray<GfQuatf>", "uniform", 1)
|
||||
@@ -294,8 +294,8 @@ class USDExportTest(AbstractUSDTest):
|
||||
self.check_primvar(prim, "p_int8", "VtArray<unsigned char>", "vertex", 24)
|
||||
self.check_primvar(prim, "p_int32", "VtArray<int>", "vertex", 24)
|
||||
self.check_primvar(prim, "p_float", "VtArray<float>", "vertex", 24)
|
||||
self.check_primvar_missing(prim, "p_color")
|
||||
self.check_primvar_missing(prim, "p_byte_color")
|
||||
self.check_primvar(prim, "p_color", "VtArray<GfVec4f>", "vertex", 24)
|
||||
self.check_primvar(prim, "p_byte_color", "VtArray<GfVec4f>", "vertex", 24)
|
||||
self.check_primvar(prim, "p_vec2", "VtArray<GfVec2f>", "vertex", 24)
|
||||
self.check_primvar(prim, "p_vec3", "VtArray<GfVec3f>", "vertex", 24)
|
||||
self.check_primvar(prim, "p_quat", "VtArray<GfQuatf>", "vertex", 24)
|
||||
@@ -305,8 +305,8 @@ class USDExportTest(AbstractUSDTest):
|
||||
self.check_primvar(prim, "sp_int8", "VtArray<unsigned char>", "uniform", 2)
|
||||
self.check_primvar(prim, "sp_int32", "VtArray<int>", "uniform", 2)
|
||||
self.check_primvar(prim, "sp_float", "VtArray<float>", "uniform", 2)
|
||||
self.check_primvar_missing(prim, "sp_color")
|
||||
self.check_primvar_missing(prim, "sp_byte_color")
|
||||
self.check_primvar(prim, "sp_color", "VtArray<GfVec4f>", "uniform", 2)
|
||||
self.check_primvar(prim, "sp_byte_color", "VtArray<GfVec4f>", "uniform", 2)
|
||||
self.check_primvar(prim, "sp_vec2", "VtArray<GfVec2f>", "uniform", 2)
|
||||
self.check_primvar(prim, "sp_vec3", "VtArray<GfVec3f>", "uniform", 2)
|
||||
self.check_primvar(prim, "sp_quat", "VtArray<GfQuatf>", "uniform", 2)
|
||||
@@ -318,8 +318,8 @@ class USDExportTest(AbstractUSDTest):
|
||||
self.check_primvar(prim, "p_int8", "VtArray<unsigned char>", "varying", 10)
|
||||
self.check_primvar(prim, "p_int32", "VtArray<int>", "varying", 10)
|
||||
self.check_primvar(prim, "p_float", "VtArray<float>", "varying", 10)
|
||||
self.check_primvar_missing(prim, "p_color")
|
||||
self.check_primvar_missing(prim, "p_byte_color")
|
||||
self.check_primvar(prim, "p_color", "VtArray<GfVec4f>", "varying", 10)
|
||||
self.check_primvar(prim, "p_byte_color", "VtArray<GfVec4f>", "varying", 10)
|
||||
self.check_primvar(prim, "p_vec2", "VtArray<GfVec2f>", "varying", 10)
|
||||
self.check_primvar(prim, "p_vec3", "VtArray<GfVec3f>", "varying", 10)
|
||||
self.check_primvar(prim, "p_quat", "VtArray<GfQuatf>", "varying", 10)
|
||||
@@ -329,8 +329,8 @@ class USDExportTest(AbstractUSDTest):
|
||||
self.check_primvar(prim, "sp_int8", "VtArray<unsigned char>", "uniform", 3)
|
||||
self.check_primvar(prim, "sp_int32", "VtArray<int>", "uniform", 3)
|
||||
self.check_primvar(prim, "sp_float", "VtArray<float>", "uniform", 3)
|
||||
self.check_primvar_missing(prim, "sp_color")
|
||||
self.check_primvar_missing(prim, "sp_byte_color")
|
||||
self.check_primvar(prim, "sp_color", "VtArray<GfVec4f>", "uniform", 3)
|
||||
self.check_primvar(prim, "sp_byte_color", "VtArray<GfVec4f>", "uniform", 3)
|
||||
self.check_primvar(prim, "sp_vec2", "VtArray<GfVec2f>", "uniform", 3)
|
||||
self.check_primvar(prim, "sp_vec3", "VtArray<GfVec3f>", "uniform", 3)
|
||||
self.check_primvar(prim, "sp_quat", "VtArray<GfQuatf>", "uniform", 3)
|
||||
|
||||
Reference in New Issue
Block a user