Kage is a programming language to implement shaders in Ebitengine.
If you are new to shaders, the short version is that they are programs that run on the GPU instead of the CPU. For our purposes, shaders are programs that allow us to create or modify images1, like recoloring them, adding noise or grain, distorting them and many others:
(Shader recolor based on raw luminance)
In games, you will see shaders being used for all kinds of things: rounded rectangles on UI frameworks, hit and death animations on sprites, power-up or alter state effects, full screen effects like blurs, warpings, chromatic aberrations and CRT effects, lighting, water generation, screen transitions... and many, many more.
Shaders, in conclusion, are programs that allow the GPU to perform sophisticated computations for the individual pixels of an image in a highly parallel manner. When this process is repeated frame after frame —as you might have inferred from the previous examples—, we can even create cool animations and effects.
There are a few different languages in which shaders can be written: you may have heard of GLSL, HLSL and others. Ebitengine has its own intermediate language, Kage, which allows us to write shaders with a Golang-like syntax without having to worry about other internal details. At runtime, Ebitengine will translate our Kage program to HLSL, MSL or whatever language is needed to make it work on the platform where the game's being played.
Next up: #1.
- Introduction
- CPU vs GPU: different paradigms
- Setting up your first shader
- The
targetCoords
input parameter - Built-in functions
- Manual shader invocation
- More input: uniforms
- Using images
- Beyond one-to-one mapping
- Loops are tricky
- What's next?