Yotsuba Shader
English

COMPILATION PROCESS

One shader.
From C# to your graphics API.

Write your shader logic in C#. Yotsuba Shader produces SPIR-V, then Yotsuba ShaderCross translates it into the shader language your application needs.

Explore the C# authoring syntaxes →

The compilation journey

Lighting, procedural patterns, texture sampling, and reusable functions start in the same C# project. The compiler works with the supported shader subset of C#.

  1. C# shader code

    Your types, functions, and shader logic.

  2. Yotsuba Shader

    Roslyn analysis → Yotsuba IR → SPIR-V generation.

  3. SPIR-V

    A binary shader module shared by the output paths.

  4. Yotsuba ShaderCross

    Translate the SPIR-V module into the target shader language.

Choose the output language

GLSL ES

Android · OpenGL ES · WebGL

Portable shader source for OpenGL ES applications on Android and for WebGL.

GLSL

OpenGL

Shader source for an OpenGL rendering pipeline.

MSL

Metal

Metal Shading Language source for Apple platforms.

HLSL

Direct3D 11 / 12

Shader source to compile with a Direct3D shader compiler such as DXC.

WGSL

Planned

WebGPU

Planned for 2027. WGSL output is not available yet.

Illustrative imagery by independent photographers and 3D artists.

In development. This diagram describes the intended compilation pipeline. The complete C# → IR → SPIR-V path is still being assembled. WGSL output is planned for 2027.

YOTSUBA SHADER

Start with the shader you want to write.

The vertex stage receives a position and color, converts the position to homogeneous clip-space coordinates, and passes the color to the fragment stage. The fragment stage returns the interpolated color.

This example contains the shader code for both stages. The application configures the graphics pipeline, supplies vertex data, and issues draw calls.

BasicColorShader.cs
using Microsoft.Xna.Framework;
using YotsubaShader.Language;
using YotsubaShader.HlslSyntax;

public class BasicColorShader
{
    public struct VS_Input
    {
        [POSITION]
        public Vector2 Position;

        [COLOR]
        public Vector4 Color;
    }

    public struct VS_Output
    {
        [SV_Position]
        public Vector4 Position;

        [COLOR]
        public Vector4 Color;
    }

    [ShaderStage(Stage.Vertex)]
    public VS_Output VS(VS_Input input)
    {
        VS_Output output = new VS_Output();

        output.Position = new Vector4(
            input.Position.X,
            input.Position.Y,
            0.0f,
            1.0f
        );

        output.Color = input.Color;

        return output;
    }

    [ShaderStage(Stage.Fragment)]
    [return: SV_Target(0)]
    public Vector4 FS(VS_Output input)
    {
        return input.Color;
    }
}

SPIR-V

One intermediate module.

SPIR-V stores shader instructions, types, entry points, and resource bindings in a binary module. A Vulkan application can use a compatible module directly; other output paths pass it to Yotsuba ShaderCross.

YOTSUBA SHADERCROSS

Generate the source for your target.

ShaderCross reads SPIR-V and emits GLSL ES, GLSL, MSL, or HLSL source. WGSL is a planned output. Your engine or graphics API then compiles the generated source as required by the target platform.

Android is a platform, not a shader format: use GLSL ES for an OpenGL ES renderer, or SPIR-V for a Vulkan renderer. WebGL uses GLSL ES; WebGPU uses WGSL.