Skip to content

MGFXModern GMod FX

Shader-backed immediate UI rendering for Garry's Mod. Use @lux/mgfx from Lux, or ship the generated loader and call MGFX.* from plain GLua.

Use with Plain GLua

Use the generated loader distribution when an addon is still written in GLua. After the client loader runs, MGFX installs the global facade and existing panels can call MGFX.* directly.

lua
function PANEL:Paint(w, h)
  MGFX.StartPanel(self, w, h)
  MGFX.RoundedBoxEx(0, 0, w, h, {
    radius = 10,
    fill = MGFX.LinearGradient(
      0,
      0,
      1,
      1,
      Color(30, 130, 255, 230),
      Color(255, 210, 110, 230)
    ),
  })
  MGFX.EndPanel()
end

Quick Start from Lux

lux
import * as mgfx from "@lux/mgfx"

client fn paintPanel(panel, w, h) {
  mgfx.api.startPanel(panel, w, h)

  mgfx.api.roundedBoxEx(0, 0, w, h, {
    radius = 10,
    fill = mgfx.api.linearGradient(0, 0, 1, 1, {
      {0.00, Color(30, 130, 255, 230)},
      {0.55, Color(60, 200, 255, 230)},
      {1.00, Color(255, 210, 110, 230)},
    }),
    backdrop = { blur = 8, tint = Color(0, 8, 12, 120) },
  })

  mgfx.api.progressBarEx(24, 84, w - 48, 10, 0.72, {
    radius = 5,
    track = Color(10, 18, 24, 190),
    fill = mgfx.api.linearGradient(
      0, 0, 1, 0,
      Color(30, 130, 255, 230),
      Color(60, 200, 255, 230)
    ),
  })

  mgfx.api.endPanel()
}
lua
local mgfx = __lux_import("@lux/mgfx")

local function paintPanel(panel, w, h)
  mgfx.api.startPanel(panel, w, h)
  mgfx.api.roundedBoxEx(0, 0, w, h, {
    radius = 10,
    fill = mgfx.api.linearGradient(0, 0, 1, 1, {
      {0.00, Color(30, 130, 255, 230)},
      {0.55, Color(60, 200, 255, 230)},
      {1.00, Color(255, 210, 110, 230)},
    }),
    backdrop = {
      blur = 8,
      tint = Color(0, 8, 12, 120),
    },
  })
  mgfx.api.progressBarEx(24, 84, w - 48, 10, 0.72, {
    radius = 5,
    track = Color(10, 18, 24, 190),
    fill = mgfx.api.linearGradient(
      0, 0, 1, 0,
      Color(30, 130, 255, 230),
      Color(60, 200, 255, 230)
    ),
  })
  mgfx.api.endPanel()
end

Documentation Entry Points

Boundary

MGFX is a Lux package and a renderer, not a UI framework. It does not own layout, input, focus, component lifecycle, transition state, or hit testing. Callers compute the current visual state each frame and pass explicit draw arguments to mgfx.api.* in Lux or to the installed MGFX.* facade in GLua.

Text follows the same rule. Plain text should stay on native GMod text paths. Only text that needs MGFX shader effects should use the whole-run composer.

License

MGFX is distributed under the Lux MGFX Non-Commercial License. Non-commercial use is allowed under that license. Commercial use requires a separate written license from the copyright holder. See the repository license files and the package license before shipping MGFX in a server, product, paid service, sponsored work, or other commercial context.

Maintenance Rules

Example: Wheel Sector

lux
local fill = mgfx.api.sectorAngularGradient({
  {0.00, Color(35, 212, 232, 170)},
  {0.52, Color(80, 220, 160, 150)},
  {1.00, Color(245, 158, 11, 135)},
})

mgfx.api.sectorEx(cx, cy, innerR, outerR, startDeg, endDeg, {
  fill = fill,
  stroke = Color(255, 255, 255, 34),
  strokeWidth = 1,
  backdrop = { blur = 7, tint = Color(4, 10, 14, 120) },
  innerGlow = { color = Color(255, 96, 78, 90), width = 28 },
  transform = mgfx.api.pointerTilt(mx, my, {
    perspective = 900,
    maxRotateX = 4,
    maxRotateY = 6,
  }),
})
lua
local fill = MGFX.SectorAngularGradient({
    {0.00, Color(35, 212, 232, 170)},
    {0.52, Color(80, 220, 160, 150)},
    {1.00, Color(245, 158, 11, 135)},
})

MGFX.SectorEx(cx, cy, innerR, outerR, startDeg, endDeg, {
    fill = fill,
    stroke = Color(255, 255, 255, 34),
    strokeWidth = 1,
    backdrop = {blur = 7, tint = Color(4, 10, 14, 120)},
    innerGlow = {color = Color(255, 96, 78, 90), width = 28},
    transform = MGFX.PointerTilt(mx, my, {
        perspective = 900,
        maxRotateX = 4,
        maxRotateY = 6,
    }),
})