@pixi/3d
    Preparing search index...

    Class VelocityViewerAdvanced

    Debug effect that shows the scene's velocity in place of the image

    Each pixel's hue is the direction its surface moved on screen since the camera's previous render: red is right, yellow-green up, cyan left and violet down. Brightness is the speed; raise scale to see small motions. The velocity comes from the camera's motion alone, so with a still camera every pixel is black, moving objects included. The background is black, and blended and transmissive surfaces show the motion of what's behind them; velocityOutput lists what else writes no velocity.

    The view writes velocity only while an enabled pass needs it, so the viewer costs nothing while disabled or left out of View3D#passes.

    It runs after tone mapping by default, so the tone curve leaves its colours alone. It replaces the image, so effects before it drop out of the frame and effects after it treat the velocity colours as their input; put it last in passes.

    const viewer = new VelocityViewer({ scale: 0.5 });
    view3d.passes = [viewer];

    window.addEventListener('keydown', (e) => {
    if (e.key === 'v') viewer.enabled = !viewer.enabled;
    });

    Hierarchy (View Summary)

    Index
    enabled: boolean

    Whether this pass runs

    Flipping it rebuilds the view's render graph on the next render, which suits a settings toggle but not a change every frame; animate an effect's own properties instead. It can also recompile the view's materials; View3D#passes says when.

    const wireframe = new MeshPass({ name: 'wireframe' });
    view.passes = [wireframe];
    wireframe.enabled = false;
    inputMips: boolean = false

    Whether the effect's input has mips, for an effect that reads coarse levels with sampleColorLod, such as a blur

    Costs a mip generation every frame and about a third more memory for the input, so leave it false unless the effect samples levels above 0.

    requiredOutputs: SceneOutput[] = ...

    Makes the view write velocityOutput while the viewer is enabled

    The stage the effect runs at, set by the stage option

    defaultOptions: VelocityViewerOptions = ...

    Defaults for every new VelocityViewer; an option passed as undefined keeps its default

    VelocityViewer.defaultOptions.scale = 1;
    
    • get scale(): number

      Brightness each pixel of motion adds

      A surface that moves 1 / scale pixels of the rendered image between two renders shows at full brightness, and faster ones clamp there, so the default of 0.25 saturates at 4 pixels.

      Returns number

      const viewer = new VelocityViewer();
      viewer.scale = 2;
    • set scale(value: number): void

      Sets the brightness each pixel of motion adds

      Parameters

      • value: number

        Brightness per pixel; 1 saturates at one pixel

      Returns void

    • Advanced

      Adds the pass that draws the velocity in place of the chain's image

      Parameters

      • graph: RenderGraph

        Render graph being built

      • io: EffectIO

        This effect's place in the chain; io.input goes unread

      Returns void

    • Releases GPU resources the pass made outside the graph; the base class has none

      The view never calls it, not on replacing view.passes nor on its own destroy, since a pass can be shared. Call it yourself once the pass is retired. Override it only for resources of your own: the render passes added in build go with the view's graph, and a plain UniformGroup needs no release.

      Returns void

      view.passes = [];
      wireframe.destroy();