TextNode.setTextColor issues

Every time I try to set the text color of a TextNode, the text remains black. I’ve tried using TextNode.setTextColor(r,g,b,a), calling clearTextColor() first, and calling setColor(r,g,b,a) to the enclosing TextNode first (among other things). I’ve scoured the forums, TextNode manual page, and TextNode API for possible answers, but in all cases it led me to setTextColor().

OnscreenText has no problem displaying itself in various colors. Here’s basically what my code does:

self.text = TextNode('NodeName')
self.text.setTextColor(1, 1, 1, 1)
self.textNode = self.parent.attachNewNode(self.text)

Positioning, hpr, scale, etc. are fine - it’s just the text color I’m concerned with. Even though I use the setTextColor() line, and self.parent is just a dummy node with no coloring/texturing info (I’ve tried parenting to render instead with the same effect), the text appears black. Does anyone have any insight into this problem?

Note: In this case there’s no card… in other places there are cards, frames, etc. - the text is still always black regardless.

Perhaps you have lighting enabled, and none of your lights are close to the text? Try disabling lighting on your TextNode:



It didn’t help. Render doesn’t have any lights attached anyway, and I tried parenting it to that. Also, the parent does have lighting close to and pointing towards the text so that shouldn’t have been the issue anyway. That was a good thought, though.

Well, I don’t think text has normals, by default; so even if your lights were directly aimed at the text it probably wouldn’t illuminate it, and it would look black.

There must be something else in the state that’s making the text black. It could be the font itself (do you have a custom font?) or it could be anything in the global state (are you setting fog or shaders or anything)?

What does the state look like when you print the net state with:

print textNode.getNetState()

? Does the text appear white when you attach it to render2d instead? How about if you use a different font?


Thank you for your help, David.

I am using a custom font, but I also tried letting it use the default - both showed black. Here’s the dump of the net state:

In render2d it appears white (with either the default or custom font).

That ShaderAttrib is suspicious. Are you applying a custom shader to render, or have you enabled render.setShaderAuto()? Or are you doing any other tricks with shaders?


Yeah, I use render.setShaderAuto() for use with a bloom filter and glow maps… That was the problem. Apparently shaders don’t play nice with TextNodes. I turned shaders off for textNode and it worked like a charm. Thank you so much for your help, David! My text is white now!