[PATCH] Exporting vertex colors to X3D always colors faces, not vertices #47647
Labels
No Label
Interest
Animation & Rigging
Interest
Blender Cloud
Interest
Collada
Interest
Core
Interest
Documentation
Interest
Eevee & Viewport
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
Import and Export
Interest
Modeling
Interest
Modifiers
Interest
Nodes & Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds, Tests & Devices
Interest
Python API
Interest
Rendering & Cycles
Interest
Sculpt, Paint & Texture
Interest
Translations
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Meta
Good First Issue
Meta
Papercut
Module
Add-ons (BF-Blender)
Module
Add-ons (Community)
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender-addons#47647
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Win10 x64
Blender Version
Broken: 2.76b
Worked: see commit https://developer.blender.org/rBAd33b3e15ca66
When exporting a mesh with vertex colors to X3D, the export module always assigns colors to faces, not to vertices.
The source of the bug is the discrepancy between vertex coloring model in Blender and X3D. Blender assigns colors to face vertices. X3D's IndexedFaceSet node has an option for mesh vertex colors, and also for face colors.
For example, imagine a mesh with two triangles with a common edge: ABC and ABD. Blender would store 6 color values: A in ABC, B in ABC, C in ABC, A in ABD, B in ABD, D in ABD. X3D has two options: either 2 color values, one for ABC, another for ABD, or 4 color values, for A, B, C, and D.
The existing export module, when processing a mesh with vertex colors, always assigns colors to faces, and always picks up the first one.
In the patch, the export logic first checks if the mesh coloring is compatible with X3D's per-vertex model (i. e. if the color of each mesh vertex matches between all faces that use that vertex). If so, it would assign color to vertices on export. If not, export falls back to the legacy node.
This behavior is especially relevant if the mesh in Blender was generated by importing from vertex-colored X3D in the first place.
In a better world, there would be logic for checking for compatibility between both X3D coloring modes, choosing one that fits, and an explicit parameter for preferring one of the two options if neither is a perfect fit (in the example above, if all 6 colors are different). Also, the logic of assigning colors to faces would average the vertex colors, as opposed to assigning the first one.
In an even better world, for cases where the exported mesh can't be faithfully colored, the export logic would generate a texture on the fly.
Exact steps for others to reproduce the error
Load the attached Blender file - VertColors.blend
Export as X3D.
Open the X3D with a viewer of your choice (e. g. InstantReality).
See how both faces are solid red.
Changed status to: 'Open'
Added subscriber: @sevaa
Added subscriber: @Sergey
The comment and title mentions patch, did you forgot to upload it perhaps?
This is not my first Blender-addons contribution. I went ahead and pushed my patch to git, the master branch. The link to that commit is under "worked".
I had to submit another commit for the issue - found a bug in an edge case.
Changed status from 'Open' to: 'Archived'