From b21f52123002657934fe8eab3478ce7ca83d140e Mon Sep 17 00:00:00 2001 From: "J. Benjamin Kacerovsky" Date: Fri, 26 Jul 2024 23:35:39 -0400 Subject: [PATCH 1/2] Update material.py convert PIL mode "L" or "LA" to "RGBA" for basecolorTexture --- pyrender/material.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyrender/material.py b/pyrender/material.py index 3ce9c2d..72ce53b 100644 --- a/pyrender/material.py +++ b/pyrender/material.py @@ -429,6 +429,8 @@ def baseColorTexture(self): @baseColorTexture.setter def baseColorTexture(self, value): + if value and (value.mode == 'LA' or value.mode == "L"): + value = value.convert('RGBA') self._baseColorTexture = self._format_texture(value, 'RGBA') self._tex_flags = None From 6c5102bdbe2d49b2dcc2a25f1d0afaf15e51fa5d Mon Sep 17 00:00:00 2001 From: "J. Benjamin Kacerovsky" Date: Fri, 26 Jul 2024 23:43:08 -0400 Subject: [PATCH 2/2] Update utils.py added condition to handle bool array textures in format_texture_source --- pyrender/utils.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyrender/utils.py b/pyrender/utils.py index 48a11fa..af8fe26 100644 --- a/pyrender/utils.py +++ b/pyrender/utils.py @@ -67,6 +67,8 @@ def format_texture_source(texture, target_channels='RGB'): texture = np.array(texture * 255.0, dtype=np.uint8) elif np.issubdtype(texture.dtype, np.integer): texture = texture.astype(np.uint8) + elif np.issubdtype(texture.dtype, np.bool_): + texture = texture.astype(np.uint8) * 255 else: raise TypeError('Invalid type {} for texture'.format( type(texture)