Postprocess weird behavior with samples = 1 and getting last frame sampler

Playground with problem: https://playground.babylonjs.com/#JAVY4F#12.

I have two postprocess: the first one will get a texture sampler from the last frame and do something(It will display amiga.jpg if nothing wrong), the second one is just a copy postprocess.
When I set samples to 1(line 89), it shows an empty scene, but if I comment last frame texture reading(line 44), it works fine again.

cc @Evgeni_Popov

You have this error in the console log:

GL_INVALID_OPERATION: Feedback loop formed between Framebuffer and active Texture.

That’s because effect.setTextureFromPostProcess("lastFrameSampler", myPostProcess2) sets for lastFrameSampler the myPostProcess2 texture, which is the one myPostProcess1 is writing to: you are not allowed to read and write to the same texture at the same time.

I think it works with MSAA (samples > 1) because in this case, lastFrameSampler will be set to a resolved texture, that is a texture that is transformed from a MSAA texture to a regular texture, and so it is a different texture.

2 Likes

In case anyone in need, I fixed the playground by adding a new copy postprocess between the two postprocesses so they will not use the same texture any more.
However, I’m not aware of why this will work, they are not using the same texture anymore, though I don’t think this is a gentle solution, it do solve the problem.