API

Shader packs

A shader pack changes how the whole image looks: colors, light and effects. It is data, not a mod: players install it by copying its folder.

Installing a pack

Copy the pack's folder into shaderpacks/ in the game folder. The same pack keeps working when Minecraft updates, because Crafting adapts it to the game.

Text
shaderpacks/sepia/
├── shaderpack.json
├── tone.glsl
└── vignette.glsl

The pack file

shaderpack.json names the pack and lists its passes. They run in order, each one on the image the previous one produced.

shaderpacks/sepia/shaderpack.jsonJSON
{ "name": "Sepia", "passes": ["tone.glsl", "vignette.glsl"] }

A pass

A pass is a GLSL file with one function:

shaderpacks/sepia/tone.glslGLSL
vec4 effect(vec4 color, vec2 uv) {
    float grey = dot(color.rgb, vec3(0.299, 0.587, 0.114));
    return vec4(grey * 1.07, grey * 0.74, grey * 0.43, 1.0);
}

color is the pixel's color and uv its position on the screen, from (0, 0) to (1, 1). The function returns the new color. Three more things are available in every pass:

Name What it gives you
crafting_scene(uv) reads the image at any position: blur, edges, distortion
crafting_screen the screen size in pixels (vec2)
crafting_time the time in seconds: animations, pulses

More examples

A vignette, darkening the corners:

shaderpacks/sepia/vignette.glslGLSL
vec4 effect(vec4 color, vec2 uv) {
    vec2 d = uv - 0.5;
    d.x *= crafting_screen.x / crafting_screen.y;
    float v = smoothstep(0.85, 0.25, length(d));
    return vec4(color.rgb * v, 1.0);
}

A gentle wave, using crafting_time and crafting_scene:

shaderpacks/sepia/wave.glslGLSL
vec4 effect(vec4 color, vec2 uv) {
    vec2 shift = vec2(sin(uv.y * 30.0 + crafting_time * 2.0) * 0.002, 0.0);
    return crafting_scene(uv + shift);
}

Choosing the pack

In the game folder, open config/crafting/client.toml and set shader_pack to the pack's folder name. Empty means none. Then start the game.

config/crafting/client.tomlTOML
shader_pack = "sepia"

The pack applies inside worlds; menus look normal.

When a pass has an error

The game shows a resource warning and the image stays normal. The game's log says what is wrong, in which file and line.