Shaders

Shaders are very useful as they allow a lot of the complex work required to apply textures and lighting to an object by offloading the task to the more powerful GPU in Raspberry Pi. The Shader class is defined as follows:

class pi3d.Shader.Shader(shfile=None, vshader_source=None, 
                                      fshader_source=None) 

This allows you to specify a shader file (shfile) and specific vertex and fragment shaders (if required) within the file.

There are several shaders included in the pi3d library, some of which allow multiple textures to be used for reflections, close-up details, and transparency effects. The implementation of the shader will determine how the lights and textures are applied to the object (and in some cases, such as uv_flat, the shader ...

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.