text texture shader question

I am using mostly the shaderInputs to set textures. This worked much better then texture stages which tend to leak to its siblings. But one problem i run into is text. The internal implementation sets the text texture using the default texture stage. Which gets overridden by the shaders. My plan is to get to the texture that is inside the font and grab it and set it into the shader input like i do for all texture but there seem to be no way to get to it. Please any help is welcome.

I thought i might do some thing like this:

        textTexture = text.getCardTexture()
        print textTexture
        textNode.setShaderInput('rgba',textTexture)
        textNode.setShaderInput('bstg',textTexture)  

but text.getCardTexture return none because i guess the texture has not been created yet. When is it created or is there a different way to get to it?

this works :

# if mayChange=0, textNode would be removed
OT=OnscreenText(text='trial',mayChange = 1)
print NodePath(OT.textNode.getInternalGeom().getChild(0)).findTexture('*')

Wow improvement! But it looks like i am selecting the wrong font. Font that is a bit bigger and does not match the layout. I wonder where is the font i need to select.

Note i found about some stars that appear fine.

EDIT: I set it to use default font and that works just fine. So i think its some thing thing between the font and me setting shader this way. Font works fine if not done through shader though and i would like to get the custom font functionality back.

I guess you’re out of luck. Panda’s high level texture assignment (setTexture) and shader both are node-based operation, but the atomic part for different textures is a geom. A single TextNode may hold multiple text geoms, each geom may use different texture.

Make a static texture font using egg-mkfont. This will make an egg file that you can load as a font, and then you have complete control over your font.

David

I should play around with that. Do you suggest using egg fonts over loading ttf? I fixed the problem using a different shader for text but maybe egg fonts adds some other advantages i am missing.

Generally, loading ttf files is superior to loading egg fonts, because you have a greater selection of characters available to you (international characters, etc.), and more runtime control over the appearance of the font. But all this flexibility comes at a (small) cost: Panda might have to allocate multiple textures, for instance, making shader tricks difficult; and it might end up a bit more wasteful of texture memory than if you had preallocated all of your texture usage for fonts up front.

So, I’d recommend using egg fonts only when there is a good reason to.

David