Clustered Shading Android* Sample

This Android sample implements and compares several techniques for shading a scene with many lights. The full sample source code is available on GitHub. It can also be downloaded using this direct link. The most efficient method implemented in the sample is clustered shading, which is described in this paper. This sample is Android port of the more advanced windows-only version which is available here.

The sample implements the following methods:

  • Forward rendering. In this mode, the scene is rendered as usual and the fragment shader goes through the list of all lights, applying appropriate ones to every fragment being shaded.
  • Deferred shading. In this method, the scene is first rendered to G-buffer, and lighting is computed as post-processing effect. The fragment shader goes though the entire list of lights, for every fragment.
  • Quad. This is also deferred shading technique, but in contrast to previous mode, in this method every light is rendered on the screen as quad, and lighting contribution is accumulated in the back buffer.
  • Clustered. In this mode, all the lights are first clustered into the 3-dimensional grid. The scene is then rasterized. The fragment shader first finds which cell of the grid the current fragment falls into, and then goes through the list of lights assigned to that tile, accumulating contributions from every light.
  • CS tile. This technique combines deferred shading and light clustering. Lighting is computed by a compute shader, which applies contribution from every light. Note that this technique only works if OpenGLES 3.1 is available.

The following picture shows the image generated by the sample: 

The sample folder contains two visual studio solutions:

  • ClusteredShadingWindows.sln is Windows solution, which can be built as normal windows application
  • ClusteredShadingAndroid.sln is Android solution. To build it, you will need Visual GDB Visual Studio plugin. It can be downloaded from

If you do not want to install visual GDB, you can follow the instructions in readme.txt file located in the sample folder to build it manually.

For more complete information about compiler optimizations, see our Optimization Notice.