Skip to content

Directives

Directives are prefixed with @ and recognized by the tokenizer as decorator tokens.

@version

Sets the GLSL version. Must be the first declaration in the file.

axsl
@version 450;

Emitted as:

glsl
#version 450 core

TIP

AXSLC always emits the core profile. The version number you specify must be compatible with OpenGL 4.5 or later.

@include

Textually merges another .axsl file's globals into the current program.

axsl
@include "common/materials.axsl";
@include "common/lighting.axsl";

Rules

  1. Must follow @version - includes must appear after the version directive.
  2. Must precede all other declarations - includes come before global structs, functions, etc.
  3. Only merges globals - stage blocks from included files are ignored.
  4. Path resolution - relative to the base path (usually the input file's directory).

Example

common/materials.axsl:

axsl
@version 450;

struct Material {
    vec3 albedo;
    float roughness;
    float metallic;
};

const float PI = 3.14159;

main.axsl:

axsl
@version 450;
@include "common/materials.axsl";

@stage fragment {
    uniform Material u_material;

    void main() {
        float rough = u_material.roughness;
        // PI is available here
    }
}

The linker will:

  1. Parse common/materials.axsl
  2. Extract its global declarations (Material struct, PI constant)
  3. Merge them into the main program's globals
  4. Both stages can now use Material and PI

Include Path Override

The CLI tool accepts an -I flag to override the base path for includes:

bash
axslc -I ./shaders/includes main.axsl

@define

Reserved token, not yet implemented. Intended for preprocessor-style macro definitions.

axsl
@define MAX_LIGHTS 16  // Not implemented

@stage

Marks a shader stage block. See Stages for details.

axsl
@stage vertex {
    // vertex shader code
}

@stage fragment {
    // fragment shader code
}