My EffectComposer setup stopped working after r158

Hi,

I’m using EffectComposer with AfterimagePass to add trails to some particles. It’s not the conventional setup, but it was working perfectly before I upgraded to r159 (so, up until r158).
I’m already at r163, unfortunately I have only noticed this now, but I traced it back to the point when I upgraded to r159…

I have these settings for the renderer:

this.renderer.autoClear = false; // needed with this EffectsComposer setup
this.renderer.sortObjects = false;
this.renderer.setClearColor(0x000000);

and these for the composer:

// an independent Scene, not part of anything, specifically for the composer
// the main scene is App.scene
this.scene.add(points); // <-- Points() with particles

this.composer = new EffectComposer(App.renderer);
this.composer.renderToScreen = true;
this.composer.addPass(new RenderPass(this.scene, App.camera));
this.composer.addPass(new AfterimagePass(0.9));

App.registerBeforeRenderCallback('cosmosParticle', () => {
  App.renderer.clear();
  this.composer.render();
});

and here is the animate function:

public animate(): void {
  this.animationRequestId = window.requestAnimationFrame(() => this.animate());

  this.controls.update();

  // registered through App.registerBeforeRenderCallback
  this.beforeRender(); // <-- this is where the composer is being called

  this.renderer.clearDepth();
  this.renderer.render(this.scene, this.camera);
}

And this is how it looked when it was working (when moving the camera):

But now it’s not just that there’s no trail, but these particles don’t show up at all :neutral_face:
I checked the changelog again, but I don’t see anything related to this.

Anyone has ideas? :slight_smile:

Does it work if you add an instance of OutputPass to your scene:

this.composer.addPass(new RenderPass(this.scene, App.camera));
this.composer.addPass(new AfterimagePass(0.9));
this.composer.addPass(new OutputPass()); // new

You should do this in any event to make sure color space conversion and tone mapping are done correctly.

No, unfortunately this does not solve the issue :confused:

What I also noticed now – although I’m not sure what’s causing it or if it’s an issue at all – is that the imports are complaining and they were fine before:

Cannot find module 'three/examples/jsm/postprocessing/XYZ' or its corresponding type declarations.

Tried adding .js and also import { AfterimagePass, EffectComposer, OutputPass, RenderPass } from 'three/examples/jsm/Addons.js';, the error goes away, but the issue remains, no particles, no trails.

The build is fine though (even with the errors)…

Can you please try it with these imports?

import { EffectComposer } from 'three/addons/postprocessing/EffectComposer.js';
import { RenderPass } from 'three/addons/postprocessing/RenderPass.js';
import { AfterimagePass } from 'three/addons/postprocessing/AfterimagePass.js';

It’s still the same… :confused:
I will try to strip it down and put a working/non-working example somewhere.

1 Like

Well, I figured it out… There’s nothing wrong with the versions, it’s simply that I also added a cube texture as the background to the main scene when I upgraded to r159 and I completely ignored this change :man_facepalming:
And since I render the main scene after the points scene, it draws over it.
I will try to make the cube texture transparent, see if it solves the issue → unfortunately the answer is no :confused: