explaingit

zjl88858/forza-painter-geometrize-gpu

18GoAudience · developerComplexity · 4/5ActiveSetup · hard

TLDR

Go and OpenCL helper for forza-painter that rasterises rotated-ellipse shape candidates on the GPU, producing the JSON livery file the Forza editor imports much faster than the CPU original.

Mindmap

mindmap
  root((forza-painter-gpu))
    Inputs
      Source PNG image
      Settings ini
      RNG seed
    Outputs
      Shape JSON
      Preview PNG
      Progress logs
    Use Cases
      Speed up livery generation
      Run on iGPU or dGPU
      Reproduce runs with seed
    Tech Stack
      Go
      OpenCL
      CGO
      PowerShell

Things people build with this

USE CASE 1

Generate a high-shape-count livery JSON for Forza Horizon 5 in a fraction of the CPU time using your machine's GPU.

USE CASE 2

Produce reproducible runs for sharing or benchmarking by passing a fixed RNG seed on the command line.

USE CASE 3

Inspect intermediate quality by writing the preview PNG alongside the JSON output.

USE CASE 4

Plug the generated JSON back into the user's normal forza-painter branch for FH4, FH5, or FH6.

Tech stack

GoOpenCLCGOPowerShell

Getting it running

Difficulty · hard Time to first run · 1day+

Requires Go 1.24 plus OpenCL-SDK 3.0.19 and CGO build flags that the README only spells out for Windows; Linux and macOS users must port the PowerShell script themselves.

In plain English

This is a third-party helper tool for a project called forza-painter, which lets people paint custom liveries (the decals and color schemes on cars) in the Forza racing games. The forza-painter project takes a target image and converts it into a list of geometric shapes that the game can reproduce in its livery editor. This repository, written by zjl88858, rebuilds part of that conversion step so the JSON file describing those shapes is generated more quickly, letting users get a higher-quality livery in the same amount of time. The main difference from the original project is that this version uses the GPU instead of the CPU for the heavy math. It calls OpenCL through the OpenCL-SDK library to do error calculations and to rasterize shapes on the graphics card. To keep things simple it only renders rotated ellipses, which is the one shape that forza-painter actually needs. It also keeps the transparent pixels of a PNG image intact, evaluates many candidate shapes in parallel, and avoids recomputing the error for the whole image each time a shape is added. The code is written in Go with CGO, so once it is compiled it can ship as a single binary on different platforms without needing a runtime. The README lists Go 1.24 or newer and OpenCL-SDK 3.0.19 or newer as requirements, and includes a PowerShell script for building on Windows. Linux and macOS users are pointed at the script as a reference for setting their compiler flags. Usage is through a command line tool. The user passes an input image plus optional flags for the output path, a preview PNG, a settings ini file, a profile name, and an RNG seed for reproducible runs. The program prints progress as it works and writes JSON files at the shape counts listed in the settings. The generated JSON is then imported back into the user's normal forza-painter branch (links are given for FH4, FH5, and FH6) to load the livery into the game. The README includes a short performance table comparing CPU and OpenCL times per ellipse on a laptop iGPU and on a Ryzen AI MAX 395 machine, showing large speedups on the GPU path. The author also notes that generative AI was used to help plan the work, write some of the code, and translate the non-Chinese version of the document.

Copy-paste prompts

Prompt 1
Build forza-painter-geometrize-gpu on Windows 11 with Go 1.24 and OpenCL-SDK 3.0.19 using the included PowerShell script. Show the exact commands.
Prompt 2
Run the binary on logo.png with seed 42 and a settings ini that targets 500, 1000, and 2000 ellipses. Where do the JSON files land?
Prompt 3
Port the build to Linux with Go and pocl. Write the CGO_CFLAGS and CGO_LDFLAGS that map to the existing PowerShell flags.
Prompt 4
Read the OpenCL kernel and explain in plain English how it scores a candidate ellipse without recomputing the whole image error each time.
Prompt 5
Compare CPU-only forza-painter against this GPU build on a Ryzen AI MAX 395 and produce an updated speedup table.
Open on GitHub → Explain another repo

Generated 2026-05-22 · Model: sonnet-4-6 · Verify against the repo before relying on details.