HDR Effect Overlay

RPG Reactor 0.99.2 (runtime revision 20261025.1) includes HDR effect rendering. There is no plugin to install or enable. An effect opts in through a sidecar next to its .efkefc; ordinary effects retain their existing draw path.

HDR materials emit exposed linear light. The overlay adds the animations sharing a display grade into one floating-point target, adds reduced-resolution bloom, and applies that grade once to the sum. Output is display SDR; this does not enable HDR monitors, change the game's lighting, or grade the entire scene.

On PIXI 8's WebGL2 renderer, HDR animations draw inside PIXI's scene with the other screen animations (runtime 20261027.3, EFFEKSEER-IN-SCENE.md): the same light buffer, bloom and grade, screened into the scene where the animation sits. The overlay this guide describes is the fallback, and what a Graphics.effekseerInScene = false game uses.

Updating Reactor and Existing Projects

The canonical module is runtime/reactor_hdr_overlay.js. reactor_main.js loads it automatically. New projects inherit it through the normal runtime copy. The editor's existing runtime refresh installs it in older Reactor projects when their runtime revision changes. Game and editor distribution preflights require the module, and the bundled Demo carries the same runtime.

The file defines two globals. ReactorHdrRenderer is the light pipeline itself (float targets, bloom, one grade, the composite), one instance per WebGL context (the overlay's WebGL1, or PIXI's WebGL2 for the in-scene path) and free of game state. ReactorHdrOverlay is the game's adapter: sidecar requests, animation selection, the fallback twin and the overlay canvas. The editor loads the same file for its previews and keeps only the renderer (see Editor previews).

Use the complete runtime from the same Reactor build. Mixing a new module with old core/manager/sprite files does not install the native hooks. To update a project by hand, back up its js/ and copy the reactor_*.js files from runtime/ into it, except reactor_plugins.js, which belongs to the project.

A project that still enables the overlay's earlier standalone plugin, under the name ReactorHdrOverlay, keeps working: plugin setup passes that entry's parameters to the built-in overlay and skips its script, so the two never both render. The entry and its file can be removed after upgrading. A renamed copy of that plugin is not recognized and must be disabled by hand. Other plugins load as usual.

Installing an HDR Effect

Install all three files together, along with their referenced resources:

effects/MyEffect/MyEffect-hdr.efkefc
effects/MyEffect/MyEffect-hdr.hdr.json
effects/MyEffect/MyEffect-ldr.efkefc
effects/MyEffect/Materials/...
effects/MyEffect/Texture/...
effects/MyEffect/Model/...

Set the animation's effect name to MyEffect/MyEffect-hdr, without an extension. Keep the normally graded twin installed. Unsupported float rendering or a grade compile failure selects that twin. Playback waits for the metadata request before starting; requests are cached once per effect, including missing sidecars, and abort after 15 seconds. Invalid/unreadable metadata fails closed because a safe twin cannot be established. A conventional -hdr filename without metadata also fails closed. Reload the game after changing a cached sidecar.

Sidecar Contract

{
  "version": 1,
  "gradeInput": "hdr",
  "grade": "vec3 tmOut = hdr / (hdr + vec3(1.0));",
  "bloom": {
    "intensity": 0.675,
    "sizes": [0.3, 1, 2, 10, 30, 64],
    "tints": [0.3465, 0.138, 0.1176, 0.066, 0.066, 0.061],
    "radiusScale": 2.4
  },
  "fallback": "MyEffect-ldr"
}

The grade is trusted effect code in GLSL ES 1.00. It reads a local vec3 hdr containing exposed light plus bloom, and declares a local vec3 tmOut containing display RGB. Do not apply exposure again. One program is compiled per distinct grade string. The example is a simple test grade.

Fallback names without / resolve beside the HDR effect; names containing / resolve from the effects/ root. Do not include .efkefc. The fallback must be an independently usable, normally graded effect, not another HDR asset.

Sizes and tints contain six finite values: sizes must be positive, tints and intensity nonnegative, radiusScale positive. tints are scalar bloom weights. The six sizes follow UE 4.27's width-relative bloom radii; Gaussian sigma is viewWidth * size * 0.04 * 0.5 / sqrt(33.4) * radiusScale.

bloom.threshold (optional, runtime 20261027.1) is UE 4's bloom setup threshold. When it is a number, the light is multiplied by clamp((dot(rgb, (0.3, 0.59, 0.11)) - threshold) * 0.5, 0, 1) before any blur, as PostProcessBloomSetup does. UE runs that setup at half its screen resolution; an effect drawn radiusScale times larger than in the source game covers that pixel with radiusScale overlay pixels, so the setup runs at pyramid level round(log2(radiusScale)) (level 0 is an extra full-resolution pass), and every Gaussian reads that level or a coarser one: light whose exposed luminance is at or below the threshold does not bloom, and bloom reaches full strength 2 units above it. A negative threshold blooms dark light partly (-0.8 passes 40 % at zero). Without it every pixel blooms, as before. Like the other bloom settings, it is taken from the first sidecar of a grade group.

Authoring and Tuning

An HDR asset's materials output exposed linear light, not display-graded colour, and it carries no baked bloom stand-ins or refraction/distortion nodes (see Rendering limits). Reactor does not author HDR assets; they come from whatever tool exported the effect. Build and install the normally graded variant separately as the declared twin.

The defaults above are the sidecar defaults. A game's startup script can override tuning for all HDR effects:

ReactorHdrOverlay.configure({ bufferType: "auto", debug: false });
window.REACTOR_HDR = { bloom: 0.675, bloomScale: 2.4 };

bufferType is auto, half, or float: auto tries half first, then float. It requires renderable, linearly filtered targets in the overlay's WebGL1 context, or in the scene in PIXI's WebGL2 context (RGBA16F with EXT_color_buffer_float, the light buffer multisampled 4x where the format allows). Legacy plugin parameters bloomIntensity, bloomRadiusScale, bufferType, and debug are accepted by configure; global REACTOR_HDR overrides their tuning. Without overrides, each grade group's first sidecar supplies bloom settings. Use consistent bloom settings for effects sharing a grade.

For diagnostics, REACTOR_HDR.debugScale shows buffer light divided by a positive value. probeScale records a quantized lower bound in ReactorHdrOverlay.stats.probe; probeFrame limits sampling to that effect frame. measureGpu: true uses synchronous gl.finish() around postprocessing and records postSamples; it changes timing and is for measurement only. Statistics include draw/group counts, target allocations, size, type and accumulated post time. Testing markers [HDR] and REACTOR_HDR_IDS still require a valid sidecar or a complete ReactorHdrOverlay.overrides[effectName] entry, including fallback.

Rendering Limits

  • In the scene, each animation draws at its own place in the scene graph; HDR animations of one grade in one container share a light pass at the first one's place. When PIXI's context is lost, in-scene animations end and new ones play on the overlay until it is restored.
  • On the overlay, all ordinary animations draw in their original order, then HDR groups composite in first-appearance order. Animations sharing a grade add before grading even when ordinary animations occur between them. Interleaved scene/HDR occlusion and light accumulation between different grades are not supported.
  • The default is screen compositing over the scene and ordinary effects. As measured on Effekseer's WebGL runtime, additive alpha uses (SRC_ALPHA, ONE, ONE, ONE); ordinary blend uses (SRC_ALPHA, ONE_MINUS_SRC_ALPHA, ONE, ONE). Both add alpha, so alpha is not reliable coverage. Translucent HDR layers cannot darken the scene. Experimental REACTOR_HDR.coverage = true uses the accumulated alpha; it is unsuitable for mixed additive/translucent effects without corrected coverage data.
  • The target covers the overlay, with seven downsample and twelve blur passes plus one composite per grade group. Bloom intensity zero skips all 19 bloom passes. Allocations are lazy and reused; resize recreates them. Context loss invalidates them, restoration creates them on the next HDR animation. The native module ends active HDR effects at context loss; it does not preserve their clock. New animations wait until the context is restored.
  • This supports the WebGL1 effect overlay and the in-scene path on PIXI 8's WebGL2 context. Effects the 3D scene draws on its own context (Reactor3D.GpuEffects) do not use it. Refraction/distortion nodes must be excluded from HDR assets. A future authoring approach can start a separate ordinary refraction twin alongside the HDR effect; Effekseer cannot filter individual nodes during a draw. That synchronized twin is not implemented here.

Editor Previews

The editor's animation previews draw an HDR effect through the same renderer the game uses: Database › Animations and its effect file picker, the Skills/Items animation picker, Show Animation's picker, and the effect layers of Action Sequences, the 3D database and the map's 3D view. Each preview's WebGL context gets a renderer of its own; the sidecar's bloom and grade apply as they do in battle. Database › Animations says under the preview which of the following happened.

  • In HDR. The two pickers and Database › Animations clear their canvas to the backdrop (or copy it in) before drawing, so the graded light is screened over it as the game screens it over the scene. The effect layers draw on a transparent, premultiplied canvas the page lays over the 3D view; there the composite writes alpha from the graded colour, so the page's own blend comes close to the game's screen. A cropped view keeps a light buffer the size of the full view, so bloom is not cut at the box's edge. An overlay layer's buffer is its own square: light a grade spreads past it (a wide wash that covers the whole screen in battle) stops at the square's edge. Bloom radii are fractions of the game screen's width as each preview draws it (System's screen size against the preview's scale), so a glow is the same size against an effect as in battle. The same scale places bloom.threshold's setup level: a preview drawing a game pixel as k of its own runs the setup at round(log2(radiusScale * k)), the game's own level when k is 1.
  • As its twin. When the context has no float targets, the grade does not compile, or the runtime file cannot be loaded, the preview plays the sidecar's normally graded twin, as the game does. So does an effect drawn by the 3D scene itself (a GPU effect on a model), which no HDR path covers in the game either. The reason goes to the console.
  • Not at all. What the game refuses to play - a -hdr effect with no sidecar, or a sidecar that cannot be read or is invalid - the preview refuses.

Database › Animations has an HDR checkbox beside Repeat for an effect it can draw in HDR. Clearing it plays the twin instead, as a computer without float targets would see the effect; a playing preview reloads and carries on. The choice is remembered for the next HDR effect.

The preview shows the sidecar's own settings; REACTOR_HDR overrides and the legacy plugin parameters are the game's, and do not apply in the editor. The sidecar is read again each time an effect loads.

Verification

Run node --test editor/tests/hdr-overlay.test.cjs for metadata, safe fallback, in-scene selection and the composite's framebuffer, shared grading, resize/restoration, ordinary draw order, and plugin migration; hdr-preview-render.test.cjs and hdr-preview-twin.test.cjs for the editor previews' choices, loading, draw order and cleanup; effekseer-in-scene.test.cjs for the in-scene light pass and its grouping. Manifest and template tests cover loading and distribution. Unit tests do not establish GPU rendering or appearance; check those on screen.