fury-gl / fury

FURY - Free Unified Rendering in pYthon.
https://fury.gl
Other
227 stars 165 forks source link

[Bug] Textured gltf objects not displayed correctly #785

Open chisarie opened 1 year ago

chisarie commented 1 year ago

Dear all,

I just started playing around with Fury, it looks like a very interesting library!

I've just discovered one issue when running the example script https://github.com/fury-gl/fury/blob/master/docs/examples/viz_gltf_export.py (after setting interactive=True). It seems that the texture indeces are not mapped correctly, see attached gif. Do you also see the same behavior?

I am using Python 3.9.16 on Ubuntu 20.04, on a laptop without Nvidia GPU (only integrated Intel card). I have just cloned the fury repo a few minutes ago and installed from source.

fury_texture

skoudoro commented 1 year ago

Hi @chisarie,

Thank you for the feedback!

Indeed, I can reproduce the issue on my laptop.

Personally, I am quite busy so I can look into it only at the beginning on May.

Maybe @xtanion or other member of the team have time to look deeper at it.

feel free to go for a fix, If you also want to give a try !

xantric commented 4 months ago

@skoudoro I dont think this issue is caused due to the incorrect mapping of texture indices, when the original actors that were added are removed and the gltf file that was created using the scene before is loaded separately this bug does not occur.

1st time I ran this code:

cube = actor.cube(np.add(centers, np.array([2, 0, 0])), colors=colors / 2)
scene.add(cube)

sphere = actor.sphere(np.add(centers, np.array([0, 2, 0])), colors=colors)
scene.add(sphere)

fetch_gltf('BoxTextured', 'glTF')
filename = read_viz_gltf('BoxTextured')
gltf_obj = gltf.glTF(filename)
box_actor = gltf_obj.actors()
scene.add(box_actor[0])
##############################################################################
# Setting camera to the scene.

scene.set_camera(
    position=(4.45, -21, 12), focal_point=(4.45, 0.0, 0.0), view_up=(0.0, 0.0, 1.0)
)
gltf.export_scene(scene, filename='viz_gltf_export.gltf')

2nd time I just loaded the actors from the gltf file viz_gltf_export.gltf:

# cube = actor.cube(np.add(centers, np.array([2, 0, 0])), colors=colors / 2)
# scene.add(cube)

# sphere = actor.sphere(np.add(centers, np.array([0, 2, 0])), colors=colors)
# scene.add(sphere)

# fetch_gltf('BoxTextured', 'glTF')
# filename = read_viz_gltf('BoxTextured')
# gltf_obj = gltf.glTF(filename)
# box_actor = gltf_obj.actors()
# scene.add(box_actor[0])

##############################################################################
# Setting camera to the scene.

scene.set_camera(
    position=(4.45, -21, 12), focal_point=(4.45, 0.0, 0.0), view_up=(0.0, 0.0, 1.0)
)

# gltf.export_scene(scene, filename='viz_gltf_export.gltf')

gltf_obj = gltf.glTF('viz_gltf_export.gltf')
actors = gltf_obj.actors()

scene.add(*actors)

Doing it this way does not produce any error. I think this issue occurs due to the overlapping of two actors with each other.

Thank you

skoudoro commented 4 months ago

Thank you for the feeback @IshanKamboj.

which actors are overlapping ? Can you provide more details ? if it is the case, we still need to update the tutorial and/or the code

xantric commented 4 months ago

Thank you for the feeback @IshanKamboj.

which actors are overlapping ? Can you provide more details ? if it is the case, we still need to update the tutorial and/or the code

The box actor which is added to the scene first and the new box actor that is again added on top of it when the actors are added using the 'viz_gltf_export.gltf' these 2 overlap with each other which causes this weird behaviour.

xantric commented 4 months ago

@skoudoro So I think we would need to update the tutorial, So as to avoid confusion.