Editing shaders
Kivy, of course, permits us to work with shaders. The shaders calculate rendering effects with the help of the GPU. In this recipe, we will use a predefined shader that we will load from a glsl
file, which is the common extension of the OpenGL Shading Language (GLSL).
Getting ready
We are going to need a glsl
file to work with in this recipe; there exist thousands free on the Web.
Note
A nice place to look is the site http://www.iquilezles.org/apps/shadertoy/index2.html where you could find your favorite.
Also, you should be familiar with some concepts about shaders, so you can start reading the Wikipedia article at http://en.wikipedia.org/wiki/OpenGL_Shading_Language.
How to do it…
In this recipe, we will use the KV, Python, and glsl
files of our choice. In the KV file, we will provide the size and position of the shader in the app, and in the Python file, we will set the behavior of the shader. Let's follow the next steps:
Open the
glsl
file and add the next header after the#endif...