Skip to main content

Class: OrderIndependentTransparency

Weighted blended order-independent transparency for one scene, as a frame of passes (render):

  1. The scene, without its blended band: three's lists draw as always, but each blended draw (and each draw that must come after them) is kept instead of drawn.
  2. The kept blended draws, into an accumulation target that shares the scene's depth (tested, not written), each material's own colour turned into the weighted sums by a render-target output (mrt) the renderer lays over every material. With a separating surface in view the band draws twice: first what lies behind the surface, composited, then the surface and what lies in front of it.
  3. The composite over the scene.
  4. The draws that come after the blended layers (additive light, overlays, labels).

The kept draws replay through one marker object's draw, so no pass walks the scene again. Adopted materials draw their ordinary colour in every other render (a shadow cascade, an inventory scene): only the accumulation passes carry the encoder.

Constructors​

constructor​

• new OrderIndependentTransparency(scene, options, hooks?): OrderIndependentTransparency

Parameters​

NameTypeDescription
sceneObject3D<Object3DEventMap>The scene whose renders accumulate.
optionsOrderIndependentTransparencyOptions-
hooksObject-
hooks.beforeAfter?(renderer: Renderer, camera: Camera) => voidBetween renders, with the scene's target bound, before the draws kept for after the blended layers (their composite is done, or there were none): a draw among them that needs a pass of its own first, into another target, makes it here.
hooks.beforeComposite?(renderer: Renderer, camera: Camera, layers: Texture<unknown, TextureEventMap>) => voidRight before the closing composite, with the scene's target bound: whatever lies behind the blended layers and could not draw before them (a deck of cloud marched after the scene) draws here, under them. layers is the weight target: per pixel, the layers' weighted alpha (r) and that times their view depth (g).
hooks.onOpen?(renderer: Renderer, target: RenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>) => voidThe scene's colour as blended layers are about to draw over it: once as the accumulation opens, and again after a split, when it also holds what lies behind the separating surface.
hooks.separator?OrderIndependentSeparator-

Returns​

OrderIndependentTransparency

Properties​

stats​

• Readonly stats: OrderIndependentStats


uniforms​

• Readonly uniforms: Object

Type declaration​

NameTypeDescription
phaseValueUniform<0>OIT_PHASE_*: which side of the separating surface a pass keeps. It changes between the passes of one render, so it lives in the render's shared group and moves it on (setPhase): one small write a pass. In an object's own group every blended draw rewrote its buffer twice a frame, ~350 writes over a lake.
separatorBiasValueUniform<0>-
separatorDepthTextureNode<"vec4">-
weightValueUniform<Vector4>(scale, near distance, far distance, unused) of the depth weight.
weightRangeValueUniform<Vector2>The depth weight's clamp.

Accessors​

isOpen​

• get isOpen(): boolean

Whether this frame's blended layers are accumulating right now.

Returns​

boolean

Methods​

accumulationPass​

▸ accumulationPass(target): Object

Where the accumulation draws for a scene drawn into target: its targets and the outputs it lays over every material. For a warmup that builds the blended pipelines before their first frame.

Parameters​

NameType
targetRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>

Returns​

Object

NameType
mrtMRTNode
targetRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>

adopt​

▸ adopt(material): boolean

Whether material draws in the blended band. The answer is kept per material; nothing about the material changes.

Parameters​

NameType
materialMaterial<MaterialEventMap>

Returns​

boolean


adoptBeforeCompile​

▸ adoptBeforeCompile(material): boolean

adopt, for a warmup.

Parameters​

NameType
materialMaterial<MaterialEventMap>

Returns​

boolean


bandOf​

▸ bandOf(object, material): number

The band of a transparent item of this scene (see OIT_BLENDED_RENDER_ORDER), or undefined to place it by its own render order: an item of another scene, the sky, an overlay.

Parameters​

NameType
objectObject3D<Object3DEventMap>
materialMaterial<MaterialEventMap>

Returns​

number


dispose​

▸ dispose(): void

Returns​

void


render​

▸ render(renderer, scene, camera, target): void

Draws scene from camera into target (which must hold a depth texture), its blended layers order-independent. A target that cannot share its depth draws them in list order, and says why once.

Parameters​

NameType
rendererRenderer
sceneScene<Object3DEventMap>
cameraCamera
targetRenderTarget<Texture<unknown, TextureEventMap>, RenderTargetEventMap>

Returns​

void


setWeights​

▸ setWeights(weights): void

Parameters​

NameType
weightsOrderIndependentWeights

Returns​

void