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 coreTIP
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
- Must follow
@version- includes must appear after the version directive. - Must precede all other declarations - includes come before global structs, functions, etc.
- Only merges globals - stage blocks from included files are ignored.
- 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:
- Parse
common/materials.axsl - Extract its global declarations (
Materialstruct,PIconstant) - Merge them into the main program's globals
- Both stages can now use
MaterialandPI
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
}