Yotsuba Shader
Documentation

Tutorial

Textures and samplers

Declare textures and samplers, describe exactly what kind of image each one is, and bind them in the syntax you write in.

Texture type metadata#

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

public enum TextureDimension
{
   D1 = 1,
    D2 = 2,
    D3 = 3,
    Cube = 4
}
C#
namespace YotsubaShader.Language.Native.Types.Texture;

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
public class TextureAttribute(TextureDimension dimension, TextureComponentTypes componentTypes) : YotsubaShaderAttribute
{
    public TextureDimension Dimension = dimension;

    public TextureComponentTypes ComponentTypes = componentTypes;
    
    public TextureUsage Usage = TextureUsage.Sampled;

    public TextureDepth Depth = TextureDepth.No;

    public TextureFormat Format = TextureFormat.Unknown;

    public bool Arrayed = false;

    public bool Multisampled = false;
}

Mark a type with [Texture(dimension, componentTypes)]. The named fields are Usage, Depth, Format, Arrayed, and Multisampled. The sampler marker is YotsubaShader.Language.Native.Types.Sampler.

HLSL resource types#

C#
using YotsubaShader.HlslSyntax.Resources;
using YotsubaShader.HlslSyntax.Resources.Types;

public class Surface
{
    [register(RegisterPrefix.t, 0)]
    public Texture2D Albedo;

    [register(RegisterPrefix.s, 0)]
    public SamplerState Sampler;
}

The current HLSL Texture2D and SamplerState are metadata structs. They do not provide a Sample method or a CPU texture implementation. Texture sampling, CPU emulation, and runtime resource binding require additional implementation.

Copyright © 2026 Yotsuba Shader contributors · Licensing · GitHub