Yotsuba ShaderLearn
Get Started

Get Started

3 min read

Learn from scratch how to create shaders with Yotsuba Shader.

Welcome to Yotsuba Shader. An SDK for writing shaders in C# for multiple graphics APIs and game engines.

What you will learn#

In this tutorial you will learn how to write shaders in C# with Yotsuba Shader, and how to compile them so you can hand them to the GPU, whether from an existing game engine, from your own engine, or straight from a graphics API.

You will go from the basics of a shader to using the compiler. You do not need to know what a shader is or how it works. We teach you here. All you need is to know how to program in C#.

How this tutorial is built#

You are not going to read a list of attributes and functions. You are going to write code and see it work, step by step. In every chapter there is something to type, a command to run and an image that you should see appear in your window. If something does not look the same, the chapter tells you what to check.

The path has three stretches:

1. The fundamentals#

Nothing is taken for granted here. It is designed for someone who has never seen a shader.

ChapterWhat you learn
What is a shader?What it is for, and why it runs on the GPU.
How a shader is builtVertices, pixels and the three doors the data travels through.
Set up your projectYou get everything installed, in a library that depends on no engine.
Shader 1: a sunsetYour first complete shader, and how to compile it with the add command.

2. The workshop#

One chapter per tool, each with short exercises. Here you build the base that every shader uses.

ChapterWhat you learn
Your window for seeing shadersA viewer to see each change instantly.
The colorsWhat a color means to the GPU, and what happens when you go over.
The coordinatesHow a pixel knows where it is, and how to stop your circles coming out oval.
Deciding with ifRectangles, circles and boards.
Functions and structsHow to keep order in a growing shader.
Mixing and smoothingmix, clamp and smoothstep, written by you.
Repeating with loopsfor, break, continue and arrays.
TimeHow something moves when it has no memory.

3. The shaders#

Now that you have the tools, you use them to make four more ambitious shaders.

ShaderThe new thing you learn
The Mandelbrot fractal in blue on black2. A fractalPutting if, loops and functions together into something complex.
A ring of pink and cyan light3. A neon ringThe math functions the GPU already has.
Blobs of color blending together4. A moving plasmaHow to send data to the shader from your program, such as the time.
A clownfish seen with a blue tint5. A photo underwaterHow to read an image from the shader and change it.

When something does not work out, you have When something goes wrong: a method for finding errors and the questions almost everyone asks.

This tutorial does not depend on any game engine. When you finish, in What now?, you pick yours and see how the shaders you made are used there.

Start with What is a shader?.