API ReferenceGE Extensionsrender
Render Views
Provides a utility to create offscreen render views and save them to disk. Used for programmatic screenshots from arbitrary camera positions.
Provides a utility to create offscreen render views and save them to disk. Used for programmatic screenshots from arbitrary camera positions.
Public API
| Function | Signature | Description |
|---|---|---|
M.takeScreenshot | (options, callback) | Creates a render view at a given position/rotation and saves to file |
options Table
| Field | Type | Default | Description |
|---|---|---|---|
pos | vec3 | required | Camera position in world space |
rot | quat | required | Camera rotation (x, y, z, w) |
resolution | vec3 | 512 × 256 | Output resolution |
fov | number | 75 | Field of view in degrees |
nearPlane | number | 0.1 | Near clip distance |
filename | string | required | Output file path |
renderViewName | string | "defaultRenderView" | Unique render view identifier |
screenshotDelay | number | 0.1 | Delay before capture (seconds) |
Internals
- Creates a
RenderViewManagerInstanceview withluaOwned = truefor GC cleanup - Builds a camera matrix from quaternion rotation + position
- Sets up a
Frustumwith the given FOV, aspect ratio, near/far planes - Temporarily disables FXAA (if active) to avoid artifacts, re-enables after save
- Hides UI and gameplay markers during capture via
ui_visibilityandgameplay_markerInteraction - Uses
core_jobsystemto run the save asynchronously
How It Works
takeScreenshotcreates or reuses a render view by name- Sets camera matrix, resolution, viewport, frustum, and named texture target
- If FXAA is enabled, temporarily disables it
- Spawns a job that:
- Hides UI and markers
- Sleeps for
screenshotDelay - Calls
renderView:saveToDisk(filename) - Destroys the render view
- Restores UI, markers, and AA settings
- Fires optional callback
Usage Examples
-- Take a screenshot from a specific camera position
render_renderViews.takeScreenshot({
pos = vec3(100, 200, 50),
rot = quat(0, 0, 0, 1),
resolution = vec3(1920, 1080, 0),
fov = 60,
filename = "screenshots/myshot.png",
screenshotDelay = 0.2,
}, function()
log('I', '', 'Screenshot saved!')
end)Key Notes
- Render view is destroyed after each screenshot (not reused)
- Far clip is hardcoded to 2000 units
- Editor icons are disabled in the render view (
renderEditorIcons = false) - The named texture target must match the render view name for correct output
See Also
- Render HDR - Post-Effect Pipeline Initialization - Related reference
- Render OpenXR - VR/XR Runtime Management - Related reference
- Render View Demo - Render View Usage Example - Related reference
- Game Engine Overview - Guide
OpenXR VR
Manages the OpenXR VR session lifecycle: toggling on/off, welcome dialog, debug ImGui panel, headset centering, state tracking, and error handling.
Offscreen View Demo
A minimal example extension demonstrating how to create and display an offscreen render view in an ImGui window. The camera orbits the origin.