render method

  1. @override
dynamic render(
  1. dynamic renderer,
  2. dynamic writeBuffer,
  3. dynamic readBuffer, {
  4. num? deltaTime,
  5. bool? maskActive,
})
override

Implementation

@override
render(renderer, writeBuffer, readBuffer, {num? deltaTime, bool? maskActive}) {
  renderer.getClearColor(oldClearColor);
  oldClearAlpha = renderer.getClearAlpha();
  oldAutoClear = renderer.autoClear;
  renderer.autoClear = false;

  renderer.setClearColor(clearColor, alpha: 0.0);

  if (maskActive == true) renderer.state.buffers.stencil.setTest(false);

  if (uniforms[textureID] != null) {
    uniforms[textureID]["value"] = readBuffer.texture;
  }

  if (passes != null) {
    int i = 0;
    int lastPass = passes!.length - 1;
    WebGLRenderTarget? lastRenderTarget;
    for (final _ in passes!) {
      material.uniforms["acPass"] = {"value": i};
      if (lastRenderTarget != null) {
        material.uniforms["acPassTexture"] = {"value": lastRenderTarget.texture};
      }

      material.needsUpdate = true;

      if (renderTargetsPass[i] == null) {
        var pars =
            WebGLRenderTargetOptions({"minFilter": LinearFilter, "magFilter": LinearFilter, "format": RGBAFormat});
        var renderTargetPass = WebGLRenderTarget(readBuffer.width, readBuffer.height, pars);
        renderTargetPass.texture.name = 'renderTargetPass$i';
        renderTargetPass.texture.generateMipmaps = false;
        renderTargetsPass[i] = renderTargetPass;
      }

      if (i >= lastPass) {
        if (renderToScreen) {
          renderPass(renderer, material, null, null, null, clear);
        } else {
          renderPass(renderer, material, writeBuffer, null, null, clear);
        }
      } else {
        renderPass(renderer, material, renderTargetsPass[i], null, null, clear);
      }

      lastRenderTarget = renderTargetsPass[i];

      i = i + 1;
    }
  } else {
    if (renderToScreen) {
      renderPass(renderer, material, null, null, null, clear);
    } else {
      renderPass(renderer, material, writeBuffer, null, null, clear);
    }
  }
}