Shaders are one of the most powerful concepts in today's graphics programming, allowing programmers to program the graphics hardware and thus provide great flexibility for creating amazing effects.
This recipe will show you how to use shaders written in the Cg shading language with the Panda3D engine.
Setup your project as described in Setting up the game structure found in Chapter 1. Add an additional folder called shaders
in the top-level source directory and add it to Panda3D's resource search paths.
Let's create a shader and apply it to a model:
Add the following code snippet to
Application.py
:from direct.showbase.ShowBase import ShowBase from panda3d.core import * class Application(ShowBase): def __init__(self): ShowBase.__init__(self) self.world = loader.loadModel("environment") self.world.reparentTo(render) self.world.setScale(0.5) self.world.setPos(-8, 80, 0) shader = loader...