O'Reilly logo

Libgdx Cross-platform Game Development Cookbook by Alberto Cejas Sánchez, David Saltares Márquez

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Passing parameters into shader programs

The shaders we have seen so far simply apply a non-configurable filter to a texture, and nothing more. You will most likely want to have richer effects in your applications, some that change over time and others that take into account external factors such as user input. This recipe is all about uniforms, which let us send parameters from the Java code into the vertex and fragment shader scripts.

We will add a vignette effect to our classic jungle background. The shader will create a circle in the center of the screen and darken everything that falls out of it. From the code, we will increase and decrease the circle's radius so that it looks like a scene transition. Refer to the following diagram for further ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required