Yotsuba Shader
Documentation

Tutorial

Types for engines and frameworks

Current vector, matrix, texture, and sampler declarations for engine authors.

Current type annotations#

The following declarations use the current vector and matrix authoring attributes. Vector metadata is processed today. Matrix attributes exist, but their presence does not imply that matrix operations and backend lowering are implemented.

Types.cs
using YotsubaShader.Language.Native.Types.Matrix;
using YotsubaShader.Language.Native.Types.Vector;

// Your project's own types, mapped to native GPU types with attributes.
// The same structs can be used by your CPU code and by your shaders.

[Vector]
public struct Vector2
{
    [VectorComponent(0)] public float X;
    [VectorComponent(1)] public float Y;

    public Vector2(float x, float y) { X = x; Y = y; }
}

[Vector]
public struct Vector3
{
    [VectorComponent(0)] public float X;
    [VectorComponent(1)] public float Y;
    [VectorComponent(2)] public float Z;

    public Vector3(float x, float y, float z) { X = x; Y = y; Z = z; }
}

[Vector]
public struct Vector4
{
    [VectorComponent(0)] public float X;
    [VectorComponent(1)] public float Y;
    [VectorComponent(2)] public float Z;
    [VectorComponent(3)] public float W;

    public Vector4(float x, float y, float z, float w) { X = x; Y = y; Z = z; W = w; }
}

[Vector]
public struct UInt3
{
    [VectorComponent(0)] public uint X;
    [VectorComponent(1)] public uint Y;
    [VectorComponent(2)] public uint Z;
}

[Matrix]
public struct Matrix4
{
    [MatrixColumn(0)] public Vector4 Column0;
    [MatrixColumn(1)] public Vector4 Column1;
    [MatrixColumn(2)] public Vector4 Column2;
    [MatrixColumn(3)] public Vector4 Column3;
}

Textures and samplers#

Texture attributes live in YotsubaShader.Language.Native.Types.Texture; sampler attributes live in YotsubaShader.Language.Native.Types. These declarations describe types, not sampling methods or GPU resource creation.

C#
using YotsubaShader.Language.Native.Types;
using YotsubaShader.Language.Native.Types.Texture;

[Texture(TextureDimension.D2, TextureComponentTypes.Float)]
public struct Texture2D { }

[Sampler]
public struct SamplerState { }

Engine integration still needs explicit CPU/GPU layout rules, binding reflection, shader compilation, and runtime loading. There is no official MonoGame, Godot, or Unity adapter in this checkout.

Copyright © 2026 Yotsuba Shader contributors · Licensing · GitHub