Rendering Images

In order to render an image, it is necessary to first create a flat piece of geometry consisting of two triangles (usually called a quad or a card) and then apply the desired image as a texture. Panda3D provides convenience methods for creating such a card automatically.

Generating a card

CardMaker is a convenience class that can be used to generate a card with arbitrary dimensions. It can be used for rendering an image in the 3D or 2D scene. The image should be loaded as a texture and then applied to the generated card:

CardMaker cm("card");
NodePath card = render2d.attach_new_node(cm.generate());

PT(Texture) tex = TexturePool::load_texture("maps/noise.rgb");

This will generate a card that causes the image to be stretched to cover the entire screen. To preserve the aspect ratio of the image, it is necessary to instead parent it to “aspect2d”, as well as use either set_scale() or CardMaker.set_frame() to adjust the card dimensions to match the aspect ratio of the image.

See the CardMaker class in the API reference for a full list of methods to configure the generated card.


To enable transparency in images, you must tell Panda3D to enable a transparency mode on the object, otherwise the transparent parts of the image will show up as black. This can be done using the following code:


See the section on Transparency and Blending for some caveats about rendering objects with transparency.