renderTransmissionPass method

void renderTransmissionPass(
  1. List<RenderItem> opaqueObjects,
  2. Object3D scene,
  3. Camera camera
)

Implementation

void renderTransmissionPass(List<RenderItem> opaqueObjects, Object3D scene, Camera camera) {
  bool isWebGL2 = capabilities.isWebGL2;

  if (_transmissionRenderTarget == null) {
    final opts = WebGLRenderTargetOptions({
      "generateMipmaps": true,
      "type": utils.convert(HalfFloatType) != null ? HalfFloatType : UnsignedByteType,
      "minFilter": LinearMipmapLinearFilter,
      "samples": (isWebGL2 && _antialias == true) ? 4 : 0
    });

    _transmissionRenderTarget = WebGLRenderTarget(1, 1, opts);
  }

  // set size of transmission render target to half size of drawing buffer

  getDrawingBufferSize(_vector2);

  if (isWebGL2) {
    _transmissionRenderTarget!.setSize(
      _vector2.x.toInt(),
      _vector2.y.toInt(),
    );
  } else {
    _transmissionRenderTarget!.setSize(MathUtils.floorPowerOfTwo(_vector2.x).toInt(), MathUtils.floorPowerOfTwo(_vector2.y).toInt());
  }

  final currentRenderTarget = getRenderTarget();
  setRenderTarget(_transmissionRenderTarget);
  clear(true, true, true);

  // Turn off the features which can affect the frag color for opaque objects pass.
  // Otherwise they are applied twice in opaque objects pass and transmission objects pass.
  final currentToneMapping = toneMapping;
  toneMapping = NoToneMapping;

  renderObjects(opaqueObjects, scene, camera);

  toneMapping = currentToneMapping;

  textures.updateMultisampleRenderTarget(_transmissionRenderTarget!);
  textures.updateRenderTargetMipmap(_transmissionRenderTarget!);

  setRenderTarget(currentRenderTarget);
}