Arshes
日本語

arshes.slang

arshes.slang は、Arshes のシェーダーで使える属性と解像度のマクロを定義している Slang のモジュールです。アプリはシェーダーをコンパイルするときに、このモジュールを読み込みます。

使い方

下のソースを arshes.slang という名前でシェーダーと同じフォルダに保存し、import してください。(ダウンロード)

import arshes;

[range(0.0, 1.0, 0.5)]
uniform float brightness;

import arshes; の行は、あってもなくてもアプリでコンパイルできます。ファイルの中の解像度は仮の値で、アプリでは実際の解像度に置き換わります。

ソース

// The Arshes app passes these as preprocessor macros when it compiles an effect.
// The values below are placeholders so that editors can resolve the names outside the app.
#ifndef RESOLUTION_X
static const int RESOLUTION_X = 1080;
static const int RESOLUTION_Y = 1920;
static const int DEPTH_RESOLUTION_X = 256;
static const int DEPTH_RESOLUTION_Y = 192;
#endif

[__AttributeUsage(_AttributeTargets.Var)]
struct rangeAttribute {
    float min;
    float max;
    float value;
};

[__AttributeUsage(_AttributeTargets.Var)]
struct rgbAttribute {
    float r;
    float g;
    float b;
};

[__AttributeUsage(_AttributeTargets.Var)]
struct rgbaAttribute {
    float r;
    float g;
    float b;
    float a;
};

[__AttributeUsage(_AttributeTargets.Var)]
struct toggleAttribute {
    int value;
};

[__AttributeUsage(_AttributeTargets.Function)]
struct dispatchAttribute {
    int x;
    int y;
    int z;
};


[__AttributeUsage(_AttributeTargets.Var)]
struct sizeAttribute {
    int count;
};

[__AttributeUsage(_AttributeTargets.Var)]
struct size2dAttribute {
    int width;
    int height;
};

[__AttributeUsage(_AttributeTargets.Function)]
struct primitiveAttribute {
    int type;
    int count;
};

[__AttributeUsage(_AttributeTargets.Function)]
struct passAttribute {
    int index;
};

enum BlendMode {
    None = 0,
    Additive = 1,
    Alpha = 2,
};

[__AttributeUsage(_AttributeTargets.Function)]
struct blendAttribute {
    BlendMode mode;
};