mmatl / pyrender

Easy-to-use glTF 2.0-compliant OpenGL renderer for visualization of 3D scenes.
http://pyrender.readthedocs.io/
MIT License
1.31k stars 225 forks source link

Add alpha channel if RenderFlags.RGBA is set #218

Open eyllanesc opened 2 years ago

eyllanesc commented 2 years ago

Fixes #209

alon-ne commented 2 years ago

Hey Edwin, I also ran into the issue that I get RGB instead of RGBA, specifically when I use osmesa on mac (running with the normal graphics adaptor I got RGBA as expected). I validated that running on linux with osmesa, the issue is indeed resolved, thank you!

On mac with osmesa however, I tried using this branch and it indeed produced an RGBA image, but it's cut so I see only the lower-left quarter. Here's a snippet of my code

            scene = pyrender.Scene.from_trimesh_scene(self.glb, bg_color=[0] * 4, ambient_light=[255] * 3)
            scene.add(self._camera(), pose=self.glb.camera_transform)

            renderer = pyrender.OffscreenRenderer(width, height)
            thumbnail, _ = renderer.render(scene, RenderFlags.RGBA)
            thumbnail_filename = self._thumbnail_filename(destination)
            Image.fromarray(thumbnail).save(thumbnail_filename)
alon-ne commented 2 years ago

There's another issue about this, specifically with osmesa https://github.com/mmatl/pyrender/issues/137

alon-ne commented 2 years ago

Attaching an example image produced by this code, when run with PYOPENGL_PLATFORM=osmesa it's cut, but without the environment variable it's not cut. Duck_not_cut Duck_cut

jkulhanek commented 2 years ago

Any progress here?