Cg Shader Tutorial

Cg Shader Tutorials

Panda has the ability to process shaders written in the Cg shader language. In this tutorial series, you will learn how to write shaders for Panda3D in Cg. While there are panda specific things in this tutorial you should be able to learn how to write Cg shaders that can be used in other engines.


You should be able to write a simple math program in C. Do not underestimate this. If you start writing your own shaders without any prior knowledge about a C-like language it is as hard as starting to write a Panda3D application without knowing anything about Python. Some resources you might want to look at:

You should have a solid grasp of Panda basics. Read the hello world tutorial and understand the “Solar System” sample that comes with the Panda3D distribution. You should also have a good understanding of how the scene graph works. If you’re interested in writing a shadow mapping shader, it helps to have a solid understanding of how the depth buffer works.

Read the first chapter from NVIDIA’s Cg Tutorial. You do not have to understand it fully, but at least you know who invented Cg and what it is for. The NVIDIA and ATI developer sites also have plenty of useful information about shaders.

You should also have the List of Possible Shader Inputs page handy.


  1. Baseline Panda application

  2. The Simplest Possible Shader. So simple that it’s useless.

  3. The simplest possible useful shader.


The use of Cg will be deprecated in a future version of Panda3D.