Inconsistent .mtl file interpretation of opacity/transparency during Import and Export
Files to be discussed:
- https://gitlab.kitware.com/vtk/vtk/-/blob/master/IO/Import/vtkOBJImporterInternals.cxx
- https://gitlab.kitware.com/vtk/vtk/-/blob/master/IO/Export/vtkOBJExporter.cxx
Problem
The interpretation of the d
OR Tr
attribute in a .mtl file for a .obj 3D-Object is not consistent along the Import and Export.
- the vtkOBJImporterInternal only interprets the "d" value
- see line https://gitlab.kitware.com/vtk/vtk/-/blob/master/IO/Import/vtkOBJImporterInternals.cxx#L330
- and https://gitlab.kitware.com/vtk/vtk/-/blob/master/IO/Import/vtkOBJImporterInternals.cxx#L493
- but sets the internal
mtl->trans
value directly without invertring
- the vtkOBJExporter writes the internal ``opacity``` as "Tr" value in the .mtl file
Funny Result of this inconsistency
Not really noticing with full opaque models
- Importing a full Opaque object with .mtl attribute "d 1"
- Export results in a .mtl file with attribute "Tr 1"
- Importing again
- Unable to find "d" value -> opacity is set to default = 1
Funny problem begins
- Importing a semitransparent object with .mtl attribute "d 0.2"
- Export results in a .mtl file with attribute "Tr 0.2"
- Importing again
- Unable to find "d" value -> opacity is set to default = 1
- Transparency is lost
Clarification
- Am I missing something?
- Is this the way to go?
Suggestion
Implement the standard definition of .mtl attribute, for example https://people.sc.fsu.edu/~jburkardt/data/mtl/mtl.html I know that vtk is internally using opacity for the object representation. A double definition for the same expression should be not necessary.
- Extend the import:
- if "d"
- Set Opacity with the d value
- if "Tr"
- Set Opacity with 1 - Tr as value
- if "d"
- Fix the export:
- Write the export with "Tr" as
1 - Internal Opacity
- Write the export with "Tr" as