Making a Speech Bubble Texture Issue

I’m trying to make a speech bubble with this code:

        self.frame = OnscreenImage(image="data/models/etc/speechbubble.png",scale=3)
        self.frame.reparentTo(speaker)
        self.frame.setBillboardAxis()
        #self.frame.setPos(speaker.getPos())
        self.frame.setZ(3.5)
        

But it will get the “speaker” texture!

I tried reseting the image with

self.frame.setImage(image="data/models/etc/speechbubble.png")

, but it disappears :imp:

Hmm, that’s because a texture that’s applied to a parent node will also propagate to a child node. You can disable this if you use an override value with setTexture, ie. setTexture(texture, 1).

I finally got the image to work, but now I’m in trouble with the text!

        self.frame = OnscreenImage(image="data/models/etc/speechbubble.png",scale=2)
        self.frame.reparentTo(np)
        self.frame.setBillboardAxis()
        p = speaker.getPos(np)
        p.setZ(p.getZ()+3.2)
        self.frame.setPos(p)
        self.frame.setSz(1.5)
        self.frame.setSx(2)
        self.frame.setTexture(loader.loadTexture("data/models/etc/speechbubble.png"),1)
        
        self.text = OnscreenText(text=speech,scale=.25,fg=Vec4(0, 0, 0, 1),align=TextNode.ALeft,pos=Vec3(-.9,.7,7),decal=True,parent=self.frame,wordwrap=4*1.75)
        self.text.setTextureOff()

But the text seems to “fight” the image!! Look the effect:

Very similar to what happened here: Nametag wierd effect

But this time I AM passing decal=True to the constructor.

I think decal=True will only work if the text and the frame of the same OnscreenText object are fighting. In this case, you could try self.text.setDepthOffset(1).

Didn’t work (actually helped just a little, it got like 10% more readable) :frowning:

Worked when I set offset to 999 :smiley:

In that case, the better way to eliminate z-fighting is probably to just give it a very slight positional offset so that it’s just a tiny bit in front of the other card. Depth offsets are known not to show reliable behaviour between graphics cards.