Capítulo 266 de 859

Chapter 266: RenderTarget

Core Idea

A render target is a buffer where the video card draws pixels for a scene that is being rendered in the background. It is used in different effects, such as applying postprocessing to a rendered image before displaying it on the screen.

Key Concepts

  • depth : number: The depth of the render target.
  • depthBuffer : boolean: Whether to allocate a depth buffer or not.
  • depthTexture : DepthTexture: Instead of saving the depth in a renderbuffer, a texture can be used instead which is useful for further processing e.g. in context of post…
  • height : number: The height of the render target.
  • isRenderTarget : boolean (readonly): This flag can be used for type testing.
  • multiview : boolean: Whether to this target is used in multiview rendering.
  • resolveDepthBuffer : boolean: Whether to resolve the depth buffer or not.
  • resolveStencilBuffer : boolean: Whether to resolve the stencil buffer or not.
  • samples : number: The number of MSAA samples.
  • scissor : Vector4: A rectangular area inside the render target's viewport. Fragments that are outside the area will be discarded.

Reference Tables

Constructor

Signature
new RenderTarget( width : number, height : number, options : RenderTarget~Options )

Properties

PropertyDescription
.depth : numberThe depth of the render target.
.depthBuffer : booleanWhether to allocate a depth buffer or not.
.depthTexture : DepthTextureInstead of saving the depth in a renderbuffer, a texture can be used instead which is useful for further processing e.g. in context of post-processing.
.height : numberThe height of the render target.
.isRenderTarget : boolean (readonly)This flag can be used for type testing.
.multiview : booleanWhether to this target is used in multiview rendering.
.resolveDepthBuffer : booleanWhether to resolve the depth buffer or not.
.resolveStencilBuffer : booleanWhether to resolve the stencil buffer or not.
.samples : numberThe number of MSAA samples.
.scissor : Vector4A rectangular area inside the render target's viewport. Fragments that are outside the area will be discarded.
.scissorTest : booleanIndicates whether the scissor test should be enabled when rendering into this render target or not.
.stencilBuffer : booleanWhether to allocate a stencil buffer or not.
.texture : TextureThe texture representing the default color attachment.
.textures : Array.<Texture>An array of textures. Each color attachment is represented as a separate texture. Has at least a single entry for the default color attachment.
.useArrayDepthTexture : booleanWhether to create the depth texture as an array texture for per-layer depth testing. This is separate from multiview so layered render targets can use array depth without the multiview extension.
.viewport : Vector4A rectangular area representing the render target's viewport.
.width : numberThe width of the render target.

Methods

MethodDescription
.clone() : RenderTargetReturns a new render target with copied values from this instance.
.copy( source : RenderTarget ) : RenderTargetCopies the settings of the given render target. This is a structural copy so no resources are shared between render targets after the copy. That includes all MRT textures and the depth texture.
.dispose()Frees the GPU-related resources allocated by this instance. Call this method whenever this instance is no longer used in your app.
.setSize( width : number, height : number, depth : number )Sets the size of this render target.

Key Takeaways

  1. RenderTarget extends: EventDispatcher
  2. Most relevant properties: depth, depthBuffer, depthTexture, height.
  3. Key methods: clone, copy, dispose, setSize.

Connects To