Skip to content

Latest commit

 

History

History
33 lines (23 loc) · 3.23 KB

00_introduction.md

File metadata and controls

33 lines (23 loc) · 3.23 KB

Introduction to Kage

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.

Table of Contents

Next up: #1.

  1. Introduction
  2. CPU vs GPU: different paradigms
  3. Setting up your first shader
  4. The targetCoords input parameter
  5. Built-in functions
  6. Manual shader invocation
  7. More input: uniforms
  8. Using images
  9. Beyond one-to-one mapping
  10. Loops are tricky
  11. What's next?

Footnotes

  1. Shaders can also be used for general computation, not just graphics, but that's outside the scope of this guide. We have thrown a few links here if you want to learn more later.