Photo by Richard Horvath on Unsplash

Shaders with Flutter and Flame

Christian Muehle
Flutter Community
Published in
10 min readMay 22, 2022

--

Shaders are defined as a computer program that calculates the appropriated level of light, darkness, and color for a given scene. Shaders can be applied to theoretically any type of application but are most commonly used in video games.

Did you ever wonder how stunning effects, shadows, and other neat graphical tricks are made? The answer could be shaders, or the combination of even more shaders. With this article, I will introduce what shaders are, what you need to use them in Flutter and discuss the current limitations. All of this will be done by implementing the below shader in Flutter:

Shader in details

As mentioned in the introduction, shaders are used to calculate light, darkness, and colors for a given scene. That sounds very limited but if you think about it, you will notice that it is all you need to draw something on a screen. Now you might say: “But I can do all of this with the canvas object or sprites already!” and you are correct, the big difference is that shaders are coded and run on your GPU.
Your GPU can process a shader very fast as it was…

--

--

Christian Muehle
Flutter Community

From software engineering to managing director - In the maritime industry since 2011. Open Sourc & Flutter fan - Always intrested in the next big thing :)