ryuko
(流光, meaning "flowing light") is a transpiler from a custom shader language to GLSL.
-
Shader Parsing
Parses GLSL code to extract functions and varyings.
-
Transformation
Modifies main shader functions' return values, ensuring compatibility with Vulkan requirements:
- Vertex shader:
vert()
's return expression is converted into assignment togl_Position
. - Fragment shader:
frag()
's return expression is assigned to a customout
variable.
- Vertex shader:
-
GLSL Code Emission
Transpiles and emits modified vertex and fragment shader code to separate GLSL files.
-
Error Handling
Provides detailed error messages with formatted outputs for easier debugging.
- C++ Compiler: Requires a compiler that supports C++20.
- Libraries:
- fmt: For formatted text output.
- CMake: Building the project.
- mei: Building the project.
fmt
xrepo package to be installed. It can be installed with:
xrepo install -y fmt
git clone https://github.com/straightcurve/ryuko.git
cd ryuko
npx @sweetacid/mei
mkdir build && cd build
cmake ..
make
Extracts functions, varyings and shader version.
Modifies shader code to align with Vulkan requirements:
- Rewrites
return
statements into appropriate assignments. - Adds varying variable declarations when necessary.
Responsible for emitting the final GLSL code:
- Ensures functions are emitted in dependency order.
- Handles GLSL version declarations and varying declarations.
Orchestrates the parsing, transpiling and emission of shaders.
#version 450
varying vec4 Position;
varying vec4 Color;
vec4 vert() {
Color = vec4(Position.zyx, 1.0);
return vec4(Position.xyz, 1.0);
}
vec4 frag() {
return Color;
}
#version 450
layout (location = 0) in vec4 Position;
layout (location = 0) out vec4 Color;
void main() {
Color = vec4(Position.zyx, 1.0);
gl_Position = vec4(Position.xyz, 1.0);
}
#version 450
layout (location = 0) in vec4 Color;
layout (location = 0) out vec4 ryuko_outColor;
void main() {
ryuko_outColor = Color;
}
Reports errors such as:
- Missing vertex or fragment main functions.
- Invalid GLSL syntax (partial).
- Parsing failures due to unsupported constructs.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions are welcome! Feel free to submit issues or pull requests for bug fixes, enhancements, or additional features.