Arshes
English

arshes.slang

arshes.slang is the Slang module that defines the attributes and resolution macros available to Arshes shaders. The app loads it whenever it compiles a shader.

Usage

Save the source below as arshes.slang in the same folder as your shader, and import it. (Download)

import arshes;

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

The app compiles the code with or without the import arshes; line. The resolution values in the file are placeholders; the app replaces them with the actual resolution.

Source

// 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;
};