Skip to main content

PassNode

Struct PassNode 

Source
pub struct PassNode(/* private fields */);
Expand description

pass( scene, camera ).

A handle: clones share one pass. The pass renders its scene from updateBefore() (NodeUpdateType.FRAME), which the renderer fires the first time in a frame that a draw samples one of the pass’s textures, as three’s does (docs/nodes.md §57). The nested render is its own submit, so the GPU runs it before the pass that samples it.

The scene and camera are shared handles, given by pass or PassNode::set_scene: the node holds them across frames, as three’s this.scene / this.camera do. A pass without them never renders; the explicit render() that used to cover that case was removed in 0.2.0 (docs/api.md decision 10).

Implementations§

Source§

impl PassNode

Source

pub fn new() -> Self

new PassNode( PassNode.COLOR, scene, camera ): a 1×1 RenderTarget with { type: HalfFloatType } plus a DepthTexture named depth, resized to the drawing buffer on the first frame.

Source

pub fn new_with_options(options: PassOptions) -> Self

pass( scene, camera, options ) — the third argument, which three spreads over renderTarget.texture and so over every attachment getTexture( name ) clones from it.

The filter pair is not cosmetic: webgpu_mrt passes NearestFilter on both sides, which makes all four attachments unfilterable, and the composite shader that samples them is generated with textureLoad and no samplers at all (docs/nodes.md §23).

Source

pub fn set_scene(&self, scene: SceneRef, camera: CameraRef)

passNode.scene = scene; passNode.camera = camera — what the pass renders from updateBefore().

Source

pub fn set_resolution_scale(&self, resolution_scale: f64)

passNode.setResolutionScale( resolutionScale ) — the render target becomes Math.floor( drawingBuffer * resolutionScale ) on the next render. RetroPassNode renders at a quarter of the canvas this way.

Source

pub fn resolution_scale(&self) -> f64

passNode.getResolutionScale().

Source

pub fn set_layers(&self, layers: Layers)

passNode.setLayers( layers ) — the camera layer mask this pass renders with. Layers::default() (layer 0 only) is what webgpu_deferred’s opaque and transparent passes set, to keep the resolve quad on layer 2 out of them.

Source

pub fn set_opaque(&mut self, opaque: bool)

passNode.opaque — false skips the opaque half of the render list, and with it the skybox.

Source

pub fn set_transparent(&mut self, transparent: bool)

passNode.transparent.

Source

pub fn set_lighting_enabled(&mut self, enabled: bool)

passNode.lighting = new Lighting(); passNode.lighting.enabled = false — the pass renders every material with an empty light list.

Source

pub fn set_context_shadow(&self, shadow: NodeRef, light: &ObjectRef)

passNode.contextNode = builtinShadowContext( shadow, light ) — every material this pass draws that receives light’s shadow multiplies shadow (a float node, typically another pass’s texture read at screenUV) into that light’s colour, after the shadow map’s own factor: three’s getShadow returns shadowColorNode.mul( shadow ) for that light and every other light’s shadowColorNode untouched.

Like three’s, the hook only runs where AnalyticLightNode.setupShadow() does — light.castShadow, object.receiveShadow and renderer.shadowMap.enabled — so an object that receives no shadow map receives none of shadow either.

webgpu_postprocessing_sss: scenePass.contextNode = builtinShadowContext( sssPass.getTextureNode().sample( screenUV ).r, dirLight ).

The node is part of each receiving material’s program key, so replacing it builds new programs; keep one node for the pass’s lifetime.

Source

pub fn clear_context_shadow(&self)

passNode.contextNode = null after a set_context_shadow: the page’s “Shadow Maps only” output.

Source

pub fn set_context_ao(&self, ao: NodeRef)

passNode.contextNode = builtinAOContext( ao ) — every non-transparent material this pass draws multiplies ao (a float node, typically another pass’s texture read at screenUV) into its AmbientOcclusion, on top of its own aoMap when it has one. The lighting models then occlude their indirect light by it, exactly as they would by an aoMap.

webgpu_postprocessing_ao: scenePass.contextNode = builtinAOContext( aoPass.getTextureNode() .sample( screenUV ).r ).

The node is part of each material’s program key, so replacing it builds new programs; keep one node for the pass’s lifetime.

Source

pub fn depth_texture(&self) -> DepthTexture

passNode.getTexture( 'depth' ) — the pass’s own depth attachment.

Three seeds _textures[ 'depth' ] in the constructor when the target has a depth buffer and throws from getTexture() for any other pass; here the target always has one, so this is infallible.

Source

pub fn view_z_node(&self, name: &str) -> NodeRef

passNode.getViewZNode( name ) — the depth attachment read back as a view-space z.

perspectiveDepthToViewZ( getTextureNode( name ), cameraNear, cameraFar ). Only 'depth' exists as a name here: a custom depth output would be an extra colour attachment, which no ported page asks for.

Source

pub fn linear_depth_node(&self, name: &str) -> NodeRef

passNode.getLinearDepthNode( name ) — view_z_node as viewZToOrthographicDepth( viewZ, cameraNear, cameraFar ): 0 at the near plane, 1 at the far one, linear in between.

Source

pub fn set_mrt(&self, mrt: MrtNode)

passNode.setMRT( mrt ).

The names the MRT writes are not what creates the attachments — getTextureNode( name ) is, exactly as in three.js, where MRTNode.setup() silently drops an output whose name is not among renderTarget.textures. webgpu_postprocessing_bloom_selective asks for getTextureNode( 'bloomIntensity' ) and so gets the second attachment; a page that set the MRT and never sampled the extra output would render single-attachment, in three.js too.

Source

pub fn mrt(&self) -> Option<MrtNode>

passNode.getMRT().

Source

pub fn texture_node(&self, name: &str) -> NodeRef

passNode.getTextureNode( name ) — the node for one named colour attachment, creating the attachment on first ask (PassNode.getTexture()).

Unlike PassNode::node this is one var, not two: a PassTextureNode is what the graph holds, and the PassNode it builds from its own setup() is then built only that once — hasDependencies is false, so TempNode gives it no var of its own. pass( scene, camera ) used directly is the case with two, because there the graph holds the PassNode as well and its usage count reaches two.

getTextureNode() with no argument is that direct use, PassNode::node; getTextureNode( 'output' ) is this, on the same renderTarget.textures[ 0 ].

Source

pub fn previous_texture_node(&self, name: &str) -> NodeRef

passNode.getPreviousTextureNode( name ) — the node for the frame before this one on that output.

PassNode.updateBefore() calls toggleTexture() for every name that has one before it renders, so on the very first frame the scene is drawn into one of the pair and the node named “previous” points at the other, which nothing has ever rendered into: a zero-initialised texture. webgpu_postprocessing_difference grades exactly that frame, so its |previous − current| is |0 − current| and the whole image is a saturated version of the box. Rendering the previous buffer, or swapping in the other order, is a different picture.

Source

pub fn texture_named(&self, name: &str) -> Texture

passNode.getTexture( name ).

Source

pub fn node(&self) -> NodeRef

The pass used as a value — PassNode.setup(): the colour texture (getTextureNode()), or for a depth_pass the linear depth (getLinearDepthNode()).

Source

pub fn a(&self) -> NodeRef

pass( … ).a — the a of node, so a depth_pass swizzles its linear depth as three’s PassNode in depth scope does.

Source

pub fn texture(&self) -> Texture

renderTarget.texture.

Trait Implementations§

Source§

impl Clone for PassNode

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for PassNode

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Deref for PassNode

The handle reads through to what it shares, so the accessors below read the pass’s fields as they did before it was a handle.

Source§

type Target = PassState

The resulting type after dereferencing.
Source§

fn deref(&self) -> &PassState

Dereferences the value.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.