Engine API Reference - v2.24.0-beta.16
    Preparing search index...

    Class BloomEffect

    The HDR bloom effect, a postprocessing technique that simulates the natural glow of bright light sources by spreading their intensity beyond their boundaries, creating a soft and realistic blooming effect.

    The bloom is generated from the scene by passes the effect owns, from a half resolution copy of it or, with BloomEffect#highQuality, from the full resolution scene, and added to the scene in linear HDR space, before tone mapping. It requires an HDR scene format, and is disabled when the camera frame renders to PIXELFORMAT_RGBA8.

    Every CameraFrame constructs and registers one, available as CameraFrame#bloom.

    Hierarchy (View Summary)

    Index
    blurLevel: number = 16

    The number of iterations for blurring the bloom effect, with each level doubling the blur size. Once the blur size matches the dimensions of the render target, further blur passes are skipped. Defaults to 16.

    cameraFrame: CameraFrame | null = null

    The camera frame the effect is registered with, or null.

    The graphics device.

    enabled: boolean = true

    Whether the effect is enabled. An effect can additionally disable itself from its own parameters, see CameraFrameEffect#active.

    highQuality: boolean = false

    Whether the bloom is generated from the full resolution scene instead of a half resolution copy of it. This gives a sharper and more stable glow around small bright features, with a slightly stronger core, at a higher performance cost. Defaults to false.

    intensity: number = 0

    The intensity of the bloom effect, 0-0.1 range. Defaults to 0, making it disabled.

    threshold: number = 0

    The brightness below which the scene does not contribute to bloom. Zero, the default, blooms the whole scene, which is the physically based behaviour; raising it restricts the glow to the brightest parts, with a soft transition below the threshold. The value is in the scene-referred units the scene is rendered in, before the exposure and tone mapping applied when the bloom is composited, so a scene lit for an exposure far from 1 needs the threshold scaled to match.

    • get active(): boolean

      Gets whether the effect contributes to the frame. A zero intensity disables it, the intensity being the effect's on/off control, and so does a scene format without HDR range.

      Returns boolean

    • get cameraExposureScale(): number

      Gets the scale the effect applies to the exposure of the camera this frame, multiplying the exposure of the scene, or of the physical camera with physical units - for effects adapting the exposure to what the camera sees. Read every frame while the effect takes part, after CameraFrameEffect#frameUpdate; the camera frame applies the product of the scales of the effects taking part, and the camera renders with its own exposure again once none does. Defaults to 1.

      // an effect brightening the image by one stop
      get cameraExposureScale() {
      return 2;
      }

      Returns number

    • get chunkName(): string

      Gets the name the compose chunk can be overridden under in ShaderChunks, the same way as the built-in chunks. Derived from the id as compose<Id>PS unless given.

      Returns string

    • get defineName(): string

      Gets the define set on the compose shader while the effect is active: the id in upper snake case, colorEnhance giving COLOR_ENHANCE.

      Returns string

    • get entryPoint(): string

      Gets the name of the function the composition calls at the effect's slot. Derived from the id as apply<Id> unless given. The signature depends on the slot: colour slots take (vec3 color, vec2 uv) and return the colour, COMPOSESLOT_SCENE takes and returns a vec4.

      Returns string

    • get slot(): string | null

      Gets the compose slot the entry function is called at, or null for an effect that does not take part in the composition.

      Returns string | null

    • Destroys the effect, removing it from its camera frame if it is still registered and releasing everything it owns, the passes it created included. Subclasses which create resources in their constructor release them in an override, calling super.destroy(). The removal takes effect for the frames rendered after the next CameraFrame#update, which is due before the next frame renders.

      Returns void

    • Sets a define on the compose shader. The define persists until changed, so fixed defines can be set once in the constructor and those depending on the parameters from CameraFrameEffect#update. A value of false, null or undefined removes it. Changing a define rebuilds the compose shader.

      Parameters

      • name: string

        The define name.

      • value: any

        The value.

      Returns void