Horizon docs

You can write two kinds of things for Horizon. Add-ons are Luau scripts that change the HUD and control the effects. An effect is an HLSL shader that changes the picture.

Making an add-on

An add-on is a Luau script, the same language Roblox games use. It can add tabs, windows, hotkeys and themes, or replace Horizon's HUD with one of your own.

  1. In Horizon's Add-ons tab, press Open folder.
  2. Put your script there, either as one file (my_addon.luau) or as a folder with a main.luau in it (my_addon/main.luau).
  3. Horizon loads it within a second, and again each time you save.

Each add-on gets a row in the Add-ons tab with an on/off switch, anything it printed, and its error if it has one. Here's a complete add-on. Save it as hello.luau in that folder to try it:

horizon.tab("Hello", function()
    ui.label("My first tab")
    if ui.button("Add bloom") then
        horizon.add("light/bloom.hlsl")
    end
end)

What an add-on can and cannot do

Add-ons run in a sandbox. They get everything on this page plus the standard Luau libraries (string, table, math, os.clock, os.time, ...). They can't read or write files, go online, start programs or load other code. No io, no require, no os.execute.

If an add-on hits an error, Horizon stops it and shows the error in the Add-ons tab. Save a fixed file and it starts again. One that runs too long in one go gets stopped the same way. The limit is a tenth of a second per call, or one second while loading. A stray while true do end won't freeze the game.

Drawing with ui

Call these inside the function you passed to horizon.tab or horizon.window. It runs every frame while it's on screen, and if ui.button(...) is true on the frame the button was clicked. Widgets that edit a value take the current one and return the new one. Call them with a dot, not a colon.

CallWhat it drawsReturns
ui.label(text)A line of text
ui.heading(text)A section title
ui.hint(text)Small, faint text
ui.separator()A dividing line
ui.space(pixels)An empty gap
ui.button(text)A buttontrue when clicked
ui.checkbox(label, on)A tick boxthe new on
ui.slider(label, value, low, high)A sliderthe new value
ui.input(label, text)A text fieldthe new text
ui.combo(label, current, {options})A dropdown of stringsthe chosen string
ui.color(label, r, g, b)A colour picker (0 to 1)r, g, b
ui.row(fn)Whatever fn draws, side by side
ui.collapsing(title, fn)A section that folds away
ui.scroll(fn)A scrolling area

The horizon library

Your own interface

CallWhat it does
horizon.tab(title, fn)Adds a tab to the HUD. fn draws it.
horizon.window(title, fn)Adds a window of your own, shown while the HUD is open.
horizon.hide_hud(true)Hides Horizon's window and leaves only yours. Does nothing unless your add-on has at least one window.
horizon.theme(css)Restyles the HUD with the same rules as theme.css, on top of the user's theme. horizon.theme(nil) undoes it. Add-ons can't change fonts.
horizon.toast(text)Shows a short message in the HUD's status line.
horizon.close()Closes the HUD.

Keys

CallWhat it does
horizon.on_key(key, fn)Runs fn when the key is pressed while Roblox is the focused window.
horizon.keybind(action)The key bound to one of Horizon's own actions, or "".
horizon.keybind(action, key)Rebinds it. "" removes the key (not allowed for "hud").

Actions: "hud", "bypass", "screenshot", "peek", "split". Keys are names: "A" to "Z", "0" to "9", "F1" to "F24", "Insert", "Delete", "Home", "End", "PageUp", "PageDown", "Space", "Tab", "Enter", "Backspace", "Up", "Down", "Left", "Right", "Num0" to "Num9". A Windows virtual-key number works too.

Effects

Positions in the chain start at 1.

CallWhat it does
horizon.library()All effects, as a list of {id, name, category, desc}.
horizon.chain()The effects in use, in order, as {id, name, enabled, params}. params maps each setting's name to a number, a boolean (tick boxes) or {r, g, b}.
horizon.add(id)Adds an effect to the end. Returns its position, or nil if there is no such effect.
horizon.remove(position)Removes one.
horizon.move(from, to)Moves one to another position.
horizon.enable(position, on)Switches one on or off.
horizon.set(position, name, value)Changes a setting. A colour takes r, g, b or {r, g, b}.
horizon.clear()Removes every effect.

Presets

CallWhat it does
horizon.presets()The names of all presets.
horizon.load_preset(name)Loads one. Returns false if there is none by that name.
horizon.save_preset(name)Saves the chain under that name (letters, digits, spaces, -, _, brackets).
horizon.export()The chain as preset text.
horizon.import(text)Replaces the chain with preset text.

Settings and state

CallWhat it does
horizon.setting(name)Reads a setting.
horizon.setting(name, value)Changes it.
horizon.info(){version, fps, gpu_ms, attached, time}: capture rate, GPU time of the chain, whether Roblox is found, seconds since Horizon started.
horizon.camera()The game's camera, {x, y, z, look = {x, y, z}, fov} (degrees), or nil when it can't be read.
horizon.screenshot()Takes a screenshot.

Settings: "mix" (master strength, 0 to 1), "bypass", "compare" (split view), "split" (0 to 1), "streamproof", "opacity" (0.5 to 1.5), "scale" (0.75 to 1.75).

Events

horizon.on(event, fn) runs fn when something happens:

EventWhenfn gets
"frame"Every frame Horizon drawsseconds since the last one
"attach"Roblox was found
"detach"Roblox closed
"open"The HUD opened
"close"The HUD closed

Remembering things

CallWhat it does
horizon.save(key, text)Stores text for this add-on. It's still there after a restart.
horizon.load(key)Gets it back, or nil.

Store numbers with tostring and read them back with tonumber. print(...) goes to the add-on's log in the Add-ons tab.

A whole new HUD

horizon.hide_hud(true)
horizon.window("My HUD", function()
    for i, fx in horizon.chain() do
        local on = ui.checkbox(fx.name, fx.enabled)
        if on ~= fx.enabled then horizon.enable(i, on) end
    end
    horizon.setting("mix", ui.slider("Strength", horizon.setting("mix"), 0, 1))
end)

If it breaks, delete or rename the script to get Horizon's window back.

Making an effect

An effect is one .hlsl file, a pixel shader that takes the picture and returns a new one. Horizon's built-in effects are written the same way and you can read any of them. They're in the Folders menu at the top of the HUD, under Shaders.

  1. In the Folders menu, open Your effects.
  2. Make a folder there (say mine) and put a file in it: mine/warm.hlsl. The folder name becomes the effect's category.
  3. Restart Horizon and the effect shows up in the library. Once it's in your chain, it reloads every time you save.

If the file has an error, it shows under the effect's settings in the HUD and the effect is skipped until it's fixed. A complete effect:

// @name  Warm Tint
// @desc  Pushes the picture toward a colour.
// @param Amount 0.3 0 1
// @color Tint 1 0.6 0.3

float4 main(PS_IN) : SV_Target
{
    float3 c = tex(Input, uv).rgb;
    return float4(lerp(c, c * Tint, Amount), 1.0);
}

Horizon ignores a file at the same path as one of its own effects. Give your folder a name nothing else uses. If you share a preset that uses your effect, the effect is packed into the .horizon file with it.

The header

Header lines start with // @ and can go anywhere in the file. Each setting becomes a variable in the shader. Pick names like Amount that don't clash with the built-in names below or with your own variables.

LineWhat it does
// @name Warm TintThe name in the library. Without it, the file name.
// @category ColorWhere it's listed. Without it, the folder name.
// @desc textOne line about it, shown above its settings.
// @param Name default min maxA slider. Name is a float.
// @toggle Name 0A tick box, off (0) or on (1) to start. Name is a float. Test it with Name > 0.5.
// @color Name r g bA colour picker, 0 to 1. Name is a float3.
// @pass Entry scaleOne pass. See Passes.
// @needs cameraOnly runs while Horizon can read the game's camera. Use it for anything that lives in the world, like rain or particles. Until then the HUD says it's waiting for the camera.
// @look Group/Name Amount=1 Tint=1,0.8,0.7A ready-made set of values, listed under Looks when you right-click the effect.
// @nocam Name NameHides these settings while the camera can be read. For settings that only stand in for the camera, like a horizon line placed by hand.
// @nosun NameSame, but for the sun.

Passes

With no @pass line, an effect is a single pass: the function main. Otherwise each @pass line runs its function, in order. Scale is the pass's size relative to the screen. 0.5 is half size. That's four times cheaper and fine for blurs. The last pass always draws at full size.

Every pass function looks like float4 Name(PS_IN) : SV_Target. Inside it, uv runs from 0 to 1 across the screen, with 0, 0 at the top left, and vpos is the pixel position.

Pictures it can read

NameWhat it holds
InputThe picture this effect works on: the game with every effect before this one.
SrcWhat the previous pass drew. In the first pass, the same as Input.
Pass0 to Pass5What each earlier pass drew, at its own size.
OrigThe game before any effect.
LastWhat Horizon showed last frame, for trails and ghosts. Horizon only keeps it when an effect mentions Last.

Read them with tex(picture, uv), which blends between pixels, or texp(picture, uv), which takes the nearest one. Both stop at the edges.

Screen, time and the game

NameWhat it is
Res, PxThe size this pass draws at, in pixels, and 1 divided by it (one pixel in uv).
FullRes, FullPxThe same for the whole screen. A pixel of a pass at scale s is FullPx / s.
SrcPxOne pixel of Src.
ASPECTWidth divided by height.
TimeSeconds since Horizon started.
DtSeconds since the last frame.
FrameCounts up by one each frame.
AudioWhat the computer is playing: x bass, y mid, z treble, w overall, each 0 to 1. Quiet and loud music both use the whole range. All 0 in silence. Horizon only listens while an effect that mentions Audio is on.

These come from the Roblox game, and any of them can be missing. Check cam_known() before using the camera and sun_known() before using the sun.

NameWhat it is
CamPos.xyzWhere the camera is, in studs. All 0 when only its direction is known.
CamPos.wThe camera's height with jumps smoothed out. See ground_drop.
CamLook.xyz, CamRight.xyz, CamUp.xyzWhere the camera faces, and its right and up. World directions, with Y up.
CamInfo.xtan(vertical field of view / 2).
PrevPos, PrevLook, PrevRight, PrevUpThe camera one frame earlier, for motion. Known when PrevLook.w > 0.5.
SunDir.xyzThe direction toward the sun.
SunColor.rgbThe game's light colour times its brightness.
FogInfo.rgb, FogInfo.wThe fog colour, and where the fog ends, in studs.
Atmo.rgb, Atmo.wThe game's Atmosphere colour and density. All 0 without one.
Atmo2x Atmosphere haze, y glare, z 1 when the game has an Atmosphere.

An effect gets no depth, no surface directions and no way to tell which object a pixel belongs to. Horizon only sees the finished picture, like a screenshot. The reflection helpers, for example, find floors by looking at the picture itself.

Helpers

CallWhat it does
view_dir(uv)The world direction seen through a pixel. Needs the camera.
sun_screen()Where the sun is on screen (xy, can be off screen) and how much it faces the camera (z, 0 to 1).
prev_screen(dir)Where a world direction was on screen one frame ago.
ground_drop(height)How far below the camera the ground is, if it's height studs under the player's eyes. It stays down when the player jumps.
keep60(k)How much of Last to keep so a trail fades at the same speed at 30, 144 or 240 frames a second. Tune k at 60.
luma(c), saturation(c, s)Brightness, and more or less colour.
to_linear(c), to_gamma(c)Into linear light and back.
rgb2hsv, hsv2rgb, rgb2yiq, yiq2rgbOther colour spaces.
hash12(p), hash22(p)Random numbers from a position.
vnoise(p), fbm(p)Smooth noise, and five layers of it. Both about 0 to 1.
bayer4(vpos.xy)A dither threshold, 0 to 1.
blur9(picture, uv, step)A blur along one direction. step is one pixel times the direction times the radius.
blend_screen, blend_overlay, blend_softlightBlend modes, like in an image editor.
tonemap_aces(c)Brings bright colours back into range.
PI, TAUπ and 2π.

Floor reflections have their own helpers (refl_prep, refl_trace, refl_blur, refl_apply, refl_streaks). The comments above them in horizon.hlsli (in the Shaders folder) explain them, and the effects in reflection and glossy use them.

Limits