Skip to main content

RenderTarget

Struct RenderTarget 

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

Cloning is a handle copy, matching JS object identity.

Implementations§

Source§

impl RenderTarget

Source

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.

Source

pub fn new(width: u32, height: u32) -> Self

new RenderTarget( width, height ) — the default options’ texture type is UnsignedByteType, so this one cannot fail.

Source

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.

Source

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).

Source

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.

Source

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.

Source

pub fn textures(&self) -> Vec<Texture>

renderTarget.textures — attachment 0 first.

Source

pub fn set_depth_texture(&self, depth_texture: DepthTexture)

renderTarget.depthTexture = texture.

Source

pub fn depth_texture(&self) -> Option<DepthTexture>

renderTarget.depthTexture.

Source

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.

Source

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.

Source

pub fn mip_level_count(&self) -> u32

The colour texture’s mip level count, 1 unless set_mip_level_count said otherwise.

Source

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.

Source

pub fn size(&self) -> (u32, u32)

(renderTarget.width, renderTarget.height).

Source

pub fn set_size(&self, width: u32, height: u32)

RenderTarget.setSize() — drops the GPU textures so they are recreated.

Source

pub fn depth_buffer(&self) -> bool

renderTarget.depthBuffer.

Source

pub fn texture(&self) -> Texture

renderTarget.texture.

Source

pub fn samples(&self) -> u32

renderTarget.samples.

Source

pub fn set_samples(&self, samples: u32)

renderTarget.samples = renderer.samples, which is what PassNode.setup() does before the first nested render.

Source

pub fn viewport(&self) -> Vector4

renderTarget.viewport.

Source

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.

Source

pub fn scissor(&self) -> Vector4

renderTarget.scissor.

Source

pub fn set_scissor(&self, x: f64, y: f64, width: f64, height: f64)

renderTarget.scissor.set( x, y, width, height ).

Source

pub fn scissor_test(&self) -> bool

renderTarget.scissorTest.

Source

pub fn set_scissor_test(&self, scissor_test: bool)

renderTarget.scissorTest = value.

Trait Implementations§

Source§

impl Clone for RenderTarget

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 Debug for RenderTarget

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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<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.