RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

server/commands - Camera & Input Commandsge_utils - Game Engine Utility Functionsmain.lua - GE Lua Entry Point & Game Loopmap.lua - Navigation Graph (AI Road Map)screenshot.lua - Screenshot Systemserver/server - Level Loading & Game ServerserverConnection - Client-Server Connection Manager`setSpawnpoint` - Default Spawn Point Persistence`simTimeAuthority` - Simulation Time & Bullet Time Control`spawn` - Vehicle Spawning & Safe Placement`suspensionFrequencyTester` - Suspension Natural Frequency Analysis
Auto AnnotationBoosterCalibrate ESCCompile ImpostersCompile MeshesConfig List GeneratorDecal Roads EditorDependency TreeDoc CreatorExport (glTF)Follow The White RabbitForest GeneratorGround Model DebugInput System UtilsInstanced Line Render DemoJBeam StatsLog StreamsMap TilesNode Beam ExportNode StreamPhotomodePrecompile ShadersPrecompile VehiclesProcedural Track (Gymkhana Generator)Rectangle GeneratorRender Components APIResave MaterialsRich PresenceSave Dynamic DataScreenshot Creator (Vehicle Thumbnails)ShowroomSort LinesStep HandlerTerrain GeneratorTest Extension ProxiesTest JSON Files Syntaxutil/vehicleRopeDebug - Rope Physics Debug UIutil/worker - Batch Job Workerutil/wsTest - WebSocket Test Server

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API ReferenceGE Extensionsutil

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)

FunctionSignatureDescription
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

  1. onInit - filters available levels against levelsToLoad, calls Engine.Render.setAsyncShaderCompilation(false), loads the first level.
  2. onClientStartMission - sets loaded = true when a level finishes loading.
  3. onPreRender - when loaded is true, advances levelToLoad index. If all levels done, calls quit().

State Variables

  • levels - filtered array of level data tables
  • levelToLoad - current index (1-based)
  • loaded - boolean, set true by onClientStartMission
  • finished - boolean, stops processing in onPreRender

How It Works

  1. Extension is loaded (typically via CLI argument).
  2. onInit builds a filtered list of levels and starts loading the first.
  3. Each level triggers onClientStartMission → next frame onPreRender advances to the next.
  4. 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)

Photomode

Provides overlay file listing for the photo mode UI.

Precompile Vehicles

M.dependencies = {'freeroam_freeroam', 'core_vehicles'}

On this page

DependenciesOverviewExports (M)InternalsLevel ListFlowState VariablesHow It WorksLua ExamplesAdditional Exports