Preview Ebitengine Shaders with Luluka

zer0tonin1 pts0 comments

Preview Ebitengine shaders with Luluka

Lately, I’ve been experimenting with building games in Ebitengine.<br>It’s a 2D engine that lets you create games using the Go programming language.<br>To be able to iterate faster on visual effects, I have created a tool that lets me preview shaders: Luluka.

Kage Shaders

For those who feel like they missed an episode, shaders are small programs running on the GPU which can be used to modify the pixels of an image.<br>In games, they are used everywhere to control how a game looks.<br>They can be used create special effects like blurring an image or making your screen look like a CRT from the 90s.

Ebitengine has its own shader language called Kage.<br>It is very convenient because it has a syntax extremely close to Go.<br>Close enough that you can even run go fmt to format your Kage files.<br>Under the hood, Ebitengine will automatically convert Kage shaders into a format understandable by the GPU.

Quasilyte’s article about Ebitengine shaders is generally the most comprehensive introduction to the subject.<br>You can also learn more about them in the Kage’s desk.

Moria Luluka from Star Detective Precure! by Toei Animation

Luluka

One of the main difference between Ebitengine and other game engines like Godot, is that it doesn’t have a visual editor.<br>This is generally fine, since I’ve spent most of my career avoiding What-You-See-Is-What-You-Get tools in favor of staying inside NeoVim.

But for shaders, you can end up spending a lot of time tweaking a few variables until you get them to look right.<br>That’s why I decided to build my own tool that would let me work on a shader in isolation, and quickly change the variables we give it.

You can install Luluka using the following command:

go install github.com/Tsukumogami-Software/[email protected]

Run a shader by pointing it straight to the file, passing textures with -i and uniform values with -u:

luluka sample/transition.kage -i image2.png -i image.png -u Steepness:80 -u Seed.0:15 -u Seed.1:100 -u Seed.2:5000 -u Seed.3:5000 -u Speed:0.08

For more convenience, you can use a YAML file to pass your uniform values.<br>This is especially practical when working with arrays or matrices, since commands can get very long:

Steepness: 80<br>Seed: [15.0, 100.0, 5000.0]<br>Speed: 0.08

luluka sample/transition.kage -i image2.png -i image.png -v values.yaml

Previous entry<br>Protecting Godot games against reverse engineering

shaders luluka ebitengine kage seed games

Related Articles