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
impl PassNode
Sourcepub fn new() -> Self
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.
Sourcepub fn new_with_options(options: PassOptions) -> Self
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).
Sourcepub fn set_scene(&self, scene: SceneRef, camera: CameraRef)
pub fn set_scene(&self, scene: SceneRef, camera: CameraRef)
passNode.scene = scene; passNode.camera = camera — what the pass
renders from updateBefore().
Sourcepub fn set_resolution_scale(&self, resolution_scale: f64)
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.
Sourcepub fn resolution_scale(&self) -> f64
pub fn resolution_scale(&self) -> f64
passNode.getResolutionScale().
Sourcepub fn set_layers(&self, layers: Layers)
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.
Sourcepub fn set_opaque(&mut self, opaque: bool)
pub fn set_opaque(&mut self, opaque: bool)
passNode.opaque — false skips the opaque half of the render list,
and with it the skybox.
Sourcepub fn set_transparent(&mut self, transparent: bool)
pub fn set_transparent(&mut self, transparent: bool)
passNode.transparent.
Sourcepub fn set_lighting_enabled(&mut self, enabled: bool)
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.
Sourcepub fn set_context_shadow(&self, shadow: NodeRef, light: &ObjectRef)
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.
Sourcepub fn clear_context_shadow(&self)
pub fn clear_context_shadow(&self)
passNode.contextNode = null after a
set_context_shadow: the page’s
“Shadow Maps only” output.
Sourcepub fn set_context_ao(&self, ao: NodeRef)
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.
Sourcepub fn depth_texture(&self) -> DepthTexture
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.
Sourcepub fn view_z_node(&self, name: &str) -> NodeRef
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.
Sourcepub fn linear_depth_node(&self, name: &str) -> NodeRef
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.
Sourcepub fn set_mrt(&self, mrt: MrtNode)
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.
Sourcepub fn texture_node(&self, name: &str) -> NodeRef
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 ].
Sourcepub fn previous_texture_node(&self, name: &str) -> NodeRef
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.
Sourcepub fn texture_named(&self, name: &str) -> Texture
pub fn texture_named(&self, name: &str) -> Texture
passNode.getTexture( name ).
Sourcepub fn node(&self) -> NodeRef
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()).
Sourcepub fn a(&self) -> NodeRef
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.