How to add a renderpass with transparency?

Hello! I have several effects composer layers, and as the last layer I’d like to add a render pass but with some transparency to blend the previous pass with the render pass. How would one approach this?

1 Like

By default, RenderPass always overwrites the buffer, so you can’t directly blend it with previous passes. Instead, you need a custom pass that samples both the existing scene buffer and your final render, then blends them with an alpha factor. A common approach is:

  1. Render your main passes as usual (e.g. pass1, pass2, etc.).
  2. Add a final custom ShaderPass that has two texture inputs:
  • tDiffuse from the previous composer pass (the accumulated scene).
  • A second texture of what you want to blend in (for instance, a separate RenderTarget or the output of a hidden camera).
  1. In the fragment shader, do something like:
gl_FragColor = mix(texture2D(tDiffuse, vUv), texture2D(tBlend, vUv), alpha);
  1. Use that ShaderPass as the last pass in your composer chain.

This way, you can control opacity (alpha) to merge your final render with the existing buffer.

2 Likes