@pixi/3d
    Preparing search index...

    Class RenderGraphAdvanced

    The ordered passes a View3D renders, and the textures they read and write

    Each pass declares in setup what it reads and writes. From that the graph lends the passes pooled textures for as long as they're used, binds each pass's target, and each frame skips any pass whose output nothing uses. A view builds one with createDefaultGraph3D, or with its graph option, then compiles and runs it.

    Index
    defaultColor: ColorHandle

    The colour of the target the view draws into, such as the canvas: where the final picture goes

    defaultDepth: DepthHandle

    Depth paired with RenderGraph#defaultColor

    globalTextureBindings: GlobalTextureBindings

    The view's global texture bindings; passes reach them through PassBuilder#globalTextureBindings

    resolution: number = 1

    Texels per logical pixel of the scene, which every texture with resolution: 'inherit' follows

    The view sets it before each frame: its target's resolution when the scene draws straight to the target, otherwise View3D#resolution.

    sceneColor: ColorHandle

    The colour the scene draws into: the texture made from RenderGraphOptions#sceneColor, or RenderGraph#defaultColor without one

    sceneDepth: DepthHandle

    Depth paired with RenderGraph#sceneColor

    sceneOutputs: readonly SceneOutput[]

    The scene outputs this graph attaches, as given in RenderGraphOptions#sceneOutputs

    • Adds a pass after those already added, and runs its setup now

      Passes run in the order they're added. Keep the handles setup declares for render.

      Type Parameters

      Parameters

      • pass: T

        The pass to register.

      Returns T

      The same pass, for inline capture.

    • Works out what each pass depends on and which target it binds; the view calls it once the graph is built

      It can run again, and starts afresh each time. It throws when a pass both writes and reads one texture, or samples, through a global binding, a texture PassBuilder#sample says needs the pass's own bind group.

      Returns void

    • Destroys the graph and its passes; imported textures are left alone, and pixi's TexturePool keeps the textures the graph used

      Returns void

    • The texture of a scene output this graph attaches, for a pass to read or draw into

      Declare the access in the pass's setup, as for any graph texture. A 'beforeOpaque' pass runs before the scene writes it, and an 'afterOpaque' pass runs before transparent and glass surfaces do.

      Parameters

      Returns ColorHandle

      The output's texture handle.

      const normals = graph.getSceneOutput(normalOutput);
      

      If the graph doesn't attach an output with this name.

    • The texture behind a handle, for a pass that binds it itself, such as raw WebGPU compute

      Call it in the pass's render, for a handle the pass declared in setup; PassBuilder#sample binds a texture for you instead. A texture the graph allocated lives from the first pass that uses it to the last, and then the pool can hand it to another pass, so don't keep it past render. Outside that span this throws.

      On WebGPU, record on renderer.encoder.commandEncoder: work on an encoder of your own runs before this frame's earlier passes, and reads what the texture held before this frame. A render pass can still be open, so call renderer.renderTarget.finishRenderPass() first, and set RenderSession#activeTarget to null so the next pass binds its target again. renderer.texture.getGpuSource(texture.source) gives the GPUTexture, and renderer.texture.getTextureView gives a view it caches on the source, so a bind group made from that view can be kept while the view stays the same.

      A pooled texture can be larger than its content: texture.frame times texture.source.resolution is the content rect in texels. A depth-stencil texture binds to a WebGPU shader through a depth-only view, as in the example.

      Parameters

      Returns Texture

      The texture, valid until the pass's render returns.

      const depth = graph.getTexture(depthHandle, session);
      const depthView = renderer.texture.getTextureView(depth, { aspect: 'depth-only' });

      renderer.renderTarget.finishRenderPass();
      session.activeTarget = null;
      const compute = renderer.encoder.commandEncoder.beginComputePass();
      // bind depthView, dispatch
      compute.end();
    • Whether this graph attaches output, for a pass that uses it when the view has it and works without it otherwise

      It matches by name and content, so a different output that shares the name doesn't count.

      Parameters

      Returns boolean

      Whether the graph attaches this output, by name and content.

      const normals = graph.hasSceneOutput(normalOutput) ? graph.getSceneOutput(normalOutput) : null;
      
    • Adds a colour texture you own, such as a render texture, for passes to draw into

      getter runs each frame, so the graph follows a resized or swapped texture. A pass that writes it runs even when no pass reads it, and the graph never clears it.

      Parameters

      Returns ColorHandle

      The handle for the imported colour resource.

    • The scene's content rect in its own texels, available before any target is bound

      When the scene draws straight into the view's target, it's the view's place there. Otherwise it starts at the origin of the scene texture and is sized at RenderGraph#resolution.

      Parameters

      Returns Rectangle

      out, for inline use.

    • Writes the scale from view UVs, 0 to 1, to the content of a scene-sized graph texture, which the pool can make larger than its content

      Parameters

      Returns void

    • Frees the GPU memory each pass can rebuild, such as the shadow map, through its GraphRenderPass#unload; the graph keeps rendering

      Textures the graph allocates are back in pixi's TexturePool between frames, and stay there.

      Returns void