Book Image

Panda3D 1.7 Game Developer's Cookbook

Book Image

Panda3D 1.7 Game Developer's Cookbook

Overview of this book

Table of Contents (20 chapters)
Panda3D 1.7 Game Developer's Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Adding a custom shader generator


Modern graphics cards and graphics APIs like Direct3D or OpenGL allow developers to program, and therefore customize, the behavior of parts of the graphics pipeline using shader programs, written in a C-like programming language. These shader programs define how vertices are being transformed, which textures are used for retrieving color values, and which final color pixels we have on the screen.

Luckily, Panda3D adds a very nice abstraction layer on top of this shader system, which is called the shader generator. As soon as you call the setShaderAuto() method on a node in the scene graph, the shader generator kicks in and pieces together the right shaders, depending on the render state (textures, colors, lights, and so on.) of your objects.

Sometimes the built-in shader generator and the code it creates may not suit your needs. Therefore, this recipe will explore and show how to add a custom shader generator to Panda3D.

Getting ready

This recipe requires you...