Capítulo 272 de 859

Chapter 272: SSAARenderPass

Core Idea

Supersample Anti-Aliasing Render Pass.

This manual approach to SSAA re-renders the scene ones for each sample with camera jitter and accumulates the results.

Key Concepts

  • camera : Camera: The camera.
  • clearAlpha : number: The clear alpha of the render pass.
  • clearColor : number | Color | string: The clear color of the render pass.
  • sampleLevel : number: The sample level. Specified as n, where the number of samples is 2^n, so sampleLevel = 4, is 2^4 samples, 16.
  • scene : Scene: The scene to render.
  • stencilBuffer : boolean: Whether to use a stencil buffer or not. This property can't be changed after the first render.
  • unbiased : boolean: Whether the pass should be unbiased or not. This property has the most visible effect when rendering to a RGBA8 buffer because it mitigates…

Code Examples

const ssaaRenderPass = new SSAARenderPass( scene, camera );
ssaaRenderPass.sampleLevel = 3;
composer.addPass( ssaaRenderPass );
  • What it demonstrates: Typical usage of SSAARenderPass.

Reference Tables

Constructor

Signature
`new SSAARenderPass( scene : Scene, camera : Camera, clearColor : number

Properties

PropertyDescription
.camera : CameraThe camera.
.clearAlpha : numberThe clear alpha of the render pass.
`.clearColor : numberColor
.sampleLevel : numberThe sample level. Specified as n, where the number of samples is 2^n, so sampleLevel = 4, is 2^4 samples, 16.
.scene : SceneThe scene to render.
.stencilBuffer : booleanWhether to use a stencil buffer or not. This property can't be changed after the first render.
.unbiased : booleanWhether the pass should be unbiased or not. This property has the most visible effect when rendering to a RGBA8 buffer because it mitigates rounding errors. By default RGBA16F is used.

Methods

MethodDescription
.dispose()Frees the GPU-related resources allocated by this instance. Call this method whenever the pass is no longer used in your app.
.render( renderer : WebGLRenderer, writeBuffer : WebGLRenderTarget, readBuffer : WebGLRenderTarget, deltaTime : number, maskActive : boolean )Performs the SSAA render pass.
.setSize( width : number, height : number )Sets the size of the pass.

Key Takeaways

  1. SSAARenderPass extends: Pass
  2. Most relevant properties: camera, clearAlpha, clearColor, sampleLevel.
  3. Key methods: dispose, render, setSize.

Connects To