pub struct RenderTarget(/* private fields */);Expand description
Cloning is a handle copy, matching JS object identity.
Implementations§
Source§impl RenderTarget
impl RenderTarget
Sourcepub fn dispose(self)
pub fn dispose(self)
renderTarget.dispose() — drops this handle, and nothing more: the
attachments live on the target, so they go with its last handle, and
the renderer lets go of the views it cached for them at the top of the
next render (docs/scene-graph.md, “Identity and eviction”). Dropping
the handle does the same; this exists so three.js code ports line for
line.
Sourcepub fn new(width: u32, height: u32) -> Self
pub fn new(width: u32, height: u32) -> Self
new RenderTarget( width, height ) — the default options’ texture type
is UnsignedByteType, so this one cannot fail.
Sourcepub fn new_with_options(
width: u32,
height: u32,
options: RenderTargetOptions,
) -> Result<Self, Error>
pub fn new_with_options( width: u32, height: u32, options: RenderTargetOptions, ) -> Result<Self, Error>
Errors when options.texture_type has no colour format — three.js
would have produced a target that fails at the first pass instead.
Sourcepub fn clone_target(&self) -> Self
pub fn clone_target(&self) -> Self
renderTarget.clone() — a second target with the same descriptor and
its own textures, which is what SSAAPassNode.setup() builds its
_sampleRenderTarget from.
Not Clone::clone: that is the handle copy, and it has to stay one,
because a RenderTarget is a JS object identity everywhere else in the
port. RenderTarget.copy() copies the depth texture reference; this
gives the copy a fresh DepthTexture instead, because RenderTarget‘s
constructor is what attached the original’s and three.js’ own
_sampleRenderTarget ends up with a depth texture of its own (the
dump’s textures 5 and 28, one per target).
Sourcepub fn set_count(&self, count: usize)
pub fn set_count(&self, count: usize)
new RenderTarget( width, height, { count } ): count - 1 clones of
renderTarget.texture pushed onto renderTarget.textures, each with
the target’s size, type and filters and an empty name — the page
names them afterwards (Self::set_texture_name), and MRTNode
writes only the ones whose name its outputs carry.
A setter rather than a RenderTargetOptions field, for the same
reason as Self::set_rg_format. It only ever grows the list, and it
has to run before the target is first drawn into, as three’s
constructor option does by construction.
Sourcepub fn set_texture_name(&self, index: usize, name: &str)
pub fn set_texture_name(&self, index: usize, name: &str)
renderTarget.textures[ index ].name = name — what the attachment
answers to in mrt( { name: … } ) and in Self::add_texture.
Attachment 0 answers to OUTPUT_ATTACHMENT until it is named
otherwise — three leaves textures[ 0 ].name empty and PassNode
treats it as output, while OITPassNode names its accumulation
target’s first attachment accum. The name lives on the target, not
the texture.
Sourcepub fn set_depth_texture(&self, depth_texture: DepthTexture)
pub fn set_depth_texture(&self, depth_texture: DepthTexture)
renderTarget.depthTexture = texture.
Sourcepub fn depth_texture(&self) -> Option<DepthTexture>
pub fn depth_texture(&self) -> Option<DepthTexture>
renderTarget.depthTexture.
Sourcepub fn set_rg_format(&self)
pub fn set_rg_format(&self)
options.format = RGFormat — a two-channel colour attachment, which
is what ShadowNode asks for its VSM blur targets
({ format: RGFormat, type: HalfFloatType }). The fragment programs
drawn into it then write a vec2 (NodeBuilder.getOutputType()).
A setter rather than a RenderTargetOptions field, so that adding
the one format the ladder needs does not break every literal
construction of the options.
Sourcepub fn set_mip_level_count(&self, count: u32)
pub fn set_mip_level_count(&self, count: u32)
renderTarget.texture.mipmaps.push( {}, … ) — count levels in the
colour texture instead of one, each to be drawn into on its own with
Renderer::set_render_target_level.
Textures.getMipLevels() takes texture.mipmaps.length as the level
count whenever it is non-zero, which is how SSRNode gives its blur
target five levels without generating any: nothing fills them but the
node’s own passes. Drops the GPU texture so it is recreated.
Sourcepub fn mip_level_count(&self) -> u32
pub fn mip_level_count(&self) -> u32
The colour texture’s mip level count, 1 unless
set_mip_level_count said otherwise.
Sourcepub fn set_red_format(&self)
pub fn set_red_format(&self)
options.format = RedFormat — a one-channel colour attachment:
DepthOfFieldNode’s CoC targets ({ format: RedFormat, type: HalfFloatType }). The fragment programs drawn into it write an f32
(NodeBuilder.getOutputType()), and a texture node sampling it is a
float node, so every tap reads .x.
Call it before set_count: the extra attachments
take the first one’s format when they are made.
The match is spelled out rather than defaulting to R8Unorm, so a
type with no red format here can never be quantised to eight bits:
FloatType / UnsignedIntType colour targets are refused by
RenderTarget::new_with_options, as they are for RGBAFormat, so
they cannot reach this setter.
Sourcepub fn set_size(&self, width: u32, height: u32)
pub fn set_size(&self, width: u32, height: u32)
RenderTarget.setSize() — drops the GPU textures so they are recreated.
Sourcepub fn depth_buffer(&self) -> bool
pub fn depth_buffer(&self) -> bool
renderTarget.depthBuffer.
Sourcepub fn set_samples(&self, samples: u32)
pub fn set_samples(&self, samples: u32)
renderTarget.samples = renderer.samples, which is what
PassNode.setup() does before the first nested render.
Sourcepub fn set_viewport(&self, x: f64, y: f64, width: f64, height: f64)
pub fn set_viewport(&self, x: f64, y: f64, width: f64, height: f64)
renderTarget.viewport.set( x, y, width, height ) — the rectangle of
this target a render into it is confined to, and what
PMREMGenerator._setViewport() sets before each tile of the cubeUV
atlas is rendered, so that 21 passes share two textures. Origin
top-left, in the target’s own pixels; see
Renderer::set_viewport.
( 0, 0, width, height ) — the default, and what Self::set_size
restores — is the whole target, which is the rectangle wgpu would use
anyway.
Sourcepub fn set_scissor(&self, x: f64, y: f64, width: f64, height: f64)
pub fn set_scissor(&self, x: f64, y: f64, width: f64, height: f64)
renderTarget.scissor.set( x, y, width, height ).
Sourcepub fn scissor_test(&self) -> bool
pub fn scissor_test(&self) -> bool
renderTarget.scissorTest.
Sourcepub fn set_scissor_test(&self, scissor_test: bool)
pub fn set_scissor_test(&self, scissor_test: bool)
renderTarget.scissorTest = value.