A shader effect
Status: Implemented (API 1.13). Post-processing passes from mod GLSL ship. The full walkthrough, including a keybind that toggles a pass, is Post Processing and Camera; this page is a short pointer.
A greyscale effect on a key
- Write the pass in
assets/<mod>/shaders/post/grey.glsl:
vec4 cl_post(vec2 uv) {
vec4 c = cl_scene(uv);
float g = dot(c.rgb, vec3(0.299, 0.587, 0.114));
return vec4(vec3(g), 1.0);
}
- Register it once at client setup, switched off, and toggle it with a keybind:
local grey, key
cl.on("lifecycle.client_setup", function()
grey = cl.render.post_pass{ id = "grey", shader = "my_mod:shaders/post/grey.glsl" }
grey:set_enabled(false)
key = cl.keybind.register{ id = "my_mod:grey", default_key = "key.keyboard.g", label = "Greyscale" }
end)
local on = false
cl.on("tick.client_post", function()
if not key then return end
while key:consume_click() do
on = not on
grey:set_enabled(on)
end
end)
While the pass is off it costs nothing; the frame is exactly vanilla.
Next
- Uniforms, textures, the rules a pass must follow, fog, sky and camera effects: Post Processing and Camera.
- Keybind details: Keybind.
- The API: Render Hooks and Shaders.