Set texture and object become black

Hi,

I imported the glb file, it looks very nice. What I want to do is to place one more texture on the object, but the object always black. Did I missing any setting?

Left side is the original one and right side is after setTexture():

class MyApp(ShowBase):

    def __init__(self):
        ShowBase.__init__(self)
        simplepbr.init()
        dlight = DirectionalLight('my dlight')
        dlnp = self.render.attachNewNode(dlight)

        self.frame = self.loader.loadModel("scene/frame.glb")
        self.frame.setPos(0,1,1)
        self.frame.setScale(0.5, 0.5, 0.5)
        self.frame.setHpr(0,0,0)
        self.frame.reparentTo(self.render)
        self.frame.setLight(dlnp)

        self.frame2 = self.loader.loadModel("scene/frame.glb")
        self.frame2.setPos(1.5,1,1)
        self.frame2.setScale(0.5, 0.5, 0.5)
        self.frame2.setHpr(0,0,0)
        self.frame2.reparentTo(self.render)
        self.frame2.setLight(dlnp)

        art = self.loader.loadTexture('scene/art/star.png')
        ts = TextureStage('ts')
        self.frame.setTexture(ts, art)

app = MyApp()
app.run()

Maybe this will help.

In short, you need to customize the material.

Hi, and welcome! :slight_smile:

It seems that loaded models don’t use the default UV (texture coordinate) set, but rather one that is specifically named "0".

So perhaps it will work better when you set up your custom TextureStage to use that particular UV set:

        ts.set_texcoord_name("0")