Precompile Shaders
M.dependencies = {'core_levels'}
Dependencies
M.dependencies = {'core_levels'}Iterates through a predefined list of levels, loading each one with synchronous shader compilation to force all shaders to be precompiled and cached.
Overview
util_precompileShaders is a build-time utility that loads a fixed set of levels sequentially. By disabling async shader compilation, every shader encountered is compiled immediately. Once all levels are processed, the application quits. This is used in CI/build pipelines to warm the shader cache.
Extension path: lua/ge/extensions/util/precompileShaders.lua
Dependencies: core_levels
Exports (M)
| Function | Signature | Description |
|---|---|---|
onInit | () | Gathers levels from core_levels, disables async shaders, starts loading. |
onClientStartMission | () | Marks the current level as loaded. |
onPreRender | (dt) | Advances to the next level or quits when all are done. |
Internals
Level List
A hardcoded lookup table levelsToLoad contains ~21 level names (e.g. east_coast_usa, italy, utah, west_coast_usa). Only levels present in both core_levels.getList() and this table are processed.
Flow
onInit- filters available levels againstlevelsToLoad, callsEngine.Render.setAsyncShaderCompilation(false), loads the first level.onClientStartMission- setsloaded = truewhen a level finishes loading.onPreRender- whenloadedis true, advanceslevelToLoadindex. If all levels done, callsquit().
State Variables
levels- filtered array of level data tableslevelToLoad- current index (1-based)loaded- boolean, set true byonClientStartMissionfinished- boolean, stops processing inonPreRender
How It Works
- Extension is loaded (typically via CLI argument).
onInitbuilds a filtered list of levels and starts loading the first.- Each level triggers
onClientStartMission→ next frameonPreRenderadvances to the next. - After the last level, the game exits via
quit().
Lua Examples
-- Typically invoked via command-line, not runtime:
-- beamng.exe -onLevelLoad_ext "util/precompileShaders"
-- The extension auto-starts on load via onInit
extensions.load("util/precompileShaders")Additional Exports
M.onClientStartMission- (undocumented)M.onInit- (undocumented)M.onPreRender- (undocumented)