Tiling the bokeh shader

Astronaut sprite with tiled orange bokeh effect applied

Learn how to make the bokeh effect tile in a GLSL shader. This tutorial follows on from the last tutorial.

Tile uniform

Add a tile uniform to the shader. This will control the number of times which the effect tiles.

Position

Replace the position line of code below:

With this new line of code:

The fract function is used to make the value loop in the 0 to 1 range. So multiplying the texture coordinates by the tile uniform, will make the effect repeat.

Conclusion

Thank you for reading this tutorial. Let me know in the comments section if you enjoyed it, or have any questions!

Leave a comment