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 an alpha mask to a texture


A very common technique in computer graphics called alpha blending is used to make whole objects, or only parts of them, appear translucent. In this recipe you will learn how to add an additional texture layer, an alpha mask, which controls the opacity of an object.

Getting ready

This recipe uses Setting up the game structure found in Chapter 1 as a starting point on which the rest of the sample will be built. Please revisit this recipe to set things up before proceeding.

Analogous to the models and sounds directories, you need to add a directory called textures and add it to Panda3D's asset search path.

You will need two texture images—one that contains the color information and an additional grayscale texture that controls opacity. The color texture will simply be mapped onto our model, while the grayscale image will be used to determine the translucency of each color texture pixel. The whiter the pixel in the grayscale opacity map, the more opaque it will...