pmndrs / postprocessing

A post processing library for three.js.
zlib License
2.36k stars 213 forks source link

Implement AfterImageEffect #665

Open TamagawaJousui opened 2 weeks ago

TamagawaJousui commented 2 weeks ago

Is your feature request related to a problem?

I'm try to use afterimagepass in this library, so I adopted it from three.js and glued it anyway since I'm in very hurry. I planed to formally rewrite it in a suitable style and make PR later.

you can check my dirty work here.

https://github.com/III-Exhibition/visual-demo/blob/df1e0c8174a3a4d077ec66070aa76ad74e8921af/AfterimagePass.js

Describe the solution you'd like

Is it nice to have? Is anyone else doing same work?

Describe alternatives you've considered

Additional context

Any advice would be kindly appreciated.

vanruesc commented 2 weeks ago

There haven't been any plans to add AfterImageEffect yet, but I think it's fine to add it.

Feel free to prepare a PR if you'd like to work on it, but please note that this should be implemented as an Effect instead of a Pass. It should also be implemented for v7 because v6 is in maintenance mode at this point.

I'd recommend implementing it as a simple Effect that uses an internal pass to generate the after-image texture. The effect can just use the existing texture.frag shader as its main fragmentShader to auto blend the map with the input image. You can check TextureEffect for reference (only need to set the map uniform).

The internal pass should probably be called FeedbackPass because it might be useful for other effects in the future. Likewise, the feedback copy shader used by that pass should be called FeedbackMaterial.

For the demo, you can copy tone-mapping and add a simple rotating mesh.