trimesh icon indicating copy to clipboard operation
trimesh copied to clipboard

GLB is not rendered correctly

Open dmikushin opened this issue 1 year ago • 4 comments

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

dmikushin avatar Dec 19 '23 01:12 dmikushin

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

mikedh avatar Dec 19 '23 02:12 mikedh

@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 avatar Dec 19 '23 08:12 dmikushin

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 avatar Dec 19 '23 08:12 dmikushin

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?).

dmikushin avatar Dec 19 '23 10:12 dmikushin