mikedh / trimesh

Python library for loading and using triangular meshes.
https://trimesh.org
MIT License
3k stars 579 forks source link

GLB is not rendered correctly #2097

Open dmikushin opened 10 months ago

dmikushin commented 10 months ago

Hi @mikedh ,

I apologize for first posting this question to pyrender, however it more likely belongs to trimesh.

I've been desperately trying to render the GBL model of an eye correctly. I've tried everything, including your notes in #135. Unfortunately, the texture is still on the opposite side, and the iris is placed incorrectly. Needless to say, that on the other hand the rendering is perfectly correct with other JS-based renderers. What am I missing?

green-eye.zip

mikedh commented 10 months ago

Neat model! It looks like a lot of that is bad support for alpha in trimesh, I did notice when you scale the sclera down it does line up with the iris texture.

import numpy as np
import trimesh

if __name__ == "__main__":

    fn = 'models/featuretype.STL'

    trimesh.util.attach_to_log()

    m = trimesh.load('~/Downloads/g1.glb')

    m.geometry['Sclera'].apply_scale(9/10)

    # looks a lot better than showing the whole scene                                               
    e.show()

    m.show()
image
dmikushin commented 10 months ago

@mikedh , thanks! I think you identified the issue. Indeed, by scaling down the sclera a bit, we can see that it is not as transparent as it is supposed to be. I'm attaching the render from another engine for comparison:

Screenshot from 2023-12-19 09-02-32

dmikushin commented 10 months ago

Your example also points out that there is another issue in pyrender, because in pyrender I could not get even what you can get in trimesh:

Screenshot from 2023-12-19 09-08-20

In pyrender Sclera is much larger than the inner geometry, by some reason.

dmikushin commented 10 months ago

As it turns out, the trimesh rendering issue is likely due to the absence of KHR_materials_specular, KHR_materials_ior and KHR_materials_transmission support in the backend (pyglet?).