pyrender icon indicating copy to clipboard operation
pyrender copied to clipboard

trimesh 3.9.33 test regression

Open traversaro opened this issue 4 years ago • 5 comments

Since trimesh 3.9.33 (I tested with pip, and trimesh 3.9.32 works fine) the test_meshes.py test fails with error:

        bm = trimesh.load('tests/data/WaterBottle.glb').dump()[0]
        x = Mesh.from_trimesh(bm)
        assert x.primitives[0].material.baseColorTexture is not None
>       assert x.primitives[0].material.emissiveTexture is not None
E       assert None is not None
E        +  where None = <pyrender.material.MetallicRoughnessMaterial object at 0x7fa1a0e760a0>.emissiveTexture
E        +    where <pyrender.material.MetallicRoughnessMaterial object at 0x7fa1a0e760a0> = <pyrender.primitive.Primitive object at 0x7fa1a0e76130>.material

tests/unit/test_meshes.py:121: AssertionError

traversaro avatar Nov 29 '21 20:11 traversaro

Hey, is this still happening? Checking on my local machine it looks OK:

n [4]: m = trimesh.load('/home/mikedh/Downloads/WaterBottle.glb')
primitive has no mode! trying GL_TRIANGLES?

In [5]: m
Out[5]: <trimesh.Scene(len(geometry)=1)>

In [9]: m.geometry
Out[9]: 
OrderedDict([('WaterBottle',
              <trimesh.Trimesh(vertices.shape=(2549, 3), faces.shape=(4510, 3))>)])

In [10]: m.geometry['WaterBottle'].visual.material
Out[10]: <trimesh.visual.material.PBRMaterial at 0x7f66ab235520>

In [11]: mat = m.geometry['WaterBottle'].visual.material

In [12]: mat._data
Out[12]: 
{'emissiveFactor': array([1., 1., 1.]),
 'baseColorTexture': <PIL.PngImagePlugin.PngImageFile image mode=RGB size=2048x2048 at 0x7F66AB240A30>,
 'doubleSided': False}

In [13]: mat.emissiveFactor
Out[13]: array([1., 1., 1.])

In [14]: mat.emissiveTexture
Out[14]: <PIL.PngImagePlugin.PngImageFile image mode=RGB size=2048x2048 at 0x7F66A31BA130>

Is it possible the runner is missing pillow, which would be required to load the texture?

mikedh avatar Dec 16 '21 17:12 mikedh

I missed the reply @mikedh ! I will trigger a new build in https://github.com/conda-forge/pyrender-feedstock/pull/2 to check.

traversaro avatar Feb 10 '22 12:02 traversaro

@traversaro I reproduce the same thing on my local machine and also on GitHub Workflow (See #216)

eyllanesc avatar Mar 17 '22 04:03 eyllanesc

I was debugging code and found the following behavior change:

import trimesh

print(trimesh.__version__)

bm = trimesh.load("tests/data/WaterBottle.glb").dump()[0]
print(bm.visual.material.emissiveTexture)
  • trimesh 3.9.32

    3.9.32
    primitive has no mode! trying GL_TRIANGLES?
    <PIL.Image.Image image mode=RGB size=2048x2048 at 0x7F385EAFACD0>
    
  • trimesh 3.9.33

    3.9.33
    primitive has no mode! trying GL_TRIANGLES?
    None
    

eyllanesc avatar Mar 18 '22 21:03 eyllanesc

@mikedh Your analysis helped me a lot. It seems that the dump method has changed in trimesh 3.9.33 so it does not take into account some materials. So I have changed the test based on your code which is in my PR #216.

Also note that prior to 3.9.33 emissive Texture was of type PIL.Image.Image but is now PIL.PngImagePlugin.PngImageFile. It can be a starting point to know the effects of the changes introduced in 3.9.33

eyllanesc avatar Mar 18 '22 21:03 eyllanesc