TextNode issue w/ shader

I think this might be related to the “1.5 texture bug” as discussed here:
discourse.panda3d.org/viewtopic.php?t=4055

However… My what gets screwed up for me are simple TextNodes! That don’t even have textures(or texturestages) applied to them!

So i’m not quite sure how to fix this.

But here is the full rundown:

I’m implementing shadows, from the shadows tutorial. Everything works fine, everything casts a shadow, etc. Nice.
Except… For my characters I have “nameplates” over their heads, made using a TextNode. Here is the code I use:

class NamePlate(NodePath):
	""" Nameplate to display text, such as the name of a character or a pawn """
	
	def __init__(self, id, text, borderColor):
		NodePath.__init__(self, id)
		self.setBillboardPointEye();
		
		namePlate = TextNode(id);		
		namePlate.setAlign(TextNode.ACenter);
		namePlate.setFrameColor(borderColor);
		namePlate.setFrameAsMargin(0.4, 0.4, 0.1, 0.1);
		namePlate.setFrameLineWidth(4);
		namePlate.setFrameCorners(True);
		namePlate.setCardColor(1, 1, 1, 0.7);
		namePlate.setCardAsMargin(0.4, 0.4, 0.1, 0.1);
		namePlate.setCardDecal(True);
		namePlate.setText(text);
		
		self.attachNewNode(namePlate)
		self.setLightOff()
		self.setScale(4)

I then reparent that to the character

However… The background of the textnode is all screwed up! It displays random textures of other things in the scene. And even flips between textures between frames.

I’m not manually loading textures for ANYTHING in the scene.

Everything else except the background of my textnodes looks fine.

Any ideas?

Is it inheriting a shader, or some other state, from the character that you didn’t intend it to inherit?

David

Yes… I’m using the shader the same way it’s used in the sample that comes with panda.

This is how it’s done:

mci = NodePath(PandaNode(“Main Camera Initializer”))
mci.setShader(Shader.load(‘shadow.sha’))
base.cam.node().setInitialState(mci.getState())

render.setShaderInput(‘light’, self.LCam)
render.setShaderInput(‘Ldepthmap’, Ldepthmap)
render.setShaderInput(‘ambient’, self.ambient, 0, 0, 1)
render.setShaderInput(‘texDisable’, 0, 0, 0, 0)
render.setShaderInput(‘scale’, 1, 1, 1, 1)
render.setShaderInput(‘push’, self.pushBias, self.pushBias, self.pushBias, 0)

So I guess essentially everything uses the shader since it’s somehow attached to the camera.

The default TextNode background card is untextured. If your shader is written to assume that everything is textured, it will probably end up applying a random texture when it comes across untextured geometry.

Thus, either turn off the shader from your TextNode (e.g. via node.setShaderOff()), or don’t use its background card.

David

Thanks. .setShaderOff() worked.