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

**URL:** <https://forum.babylonjs.com/t/postprocess-weird-behavior-with-samples-1-and-getting-last-frame-sampler/42422>\
**Category:** Questions\
**Created:** [July 14, 2023, 7:07am UTC](https://forum.babylonjs.com/t/postprocess-weird-behavior-with-samples-1-and-getting-last-frame-sampler/42422 "2023-07-14T07:07:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tanpopo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tanpopo/32/32025_2.png) [@tanpopo](https://forum.babylonjs.com/u/tanpopo)\
**Post date:** [July 14, 2023, 7:07am UTC](https://forum.babylonjs.com/t/postprocess-weird-behavior-with-samples-1-and-getting-last-frame-sampler/42422/1 "2023-07-14T07:07:15Z")

</div>

Playground with problem: [https://playground.babylonjs.com/#JAVY4F#12](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.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [July 14, 2023, 1:12pm UTC](https://forum.babylonjs.com/t/postprocess-weird-behavior-with-samples-1-and-getting-last-frame-sampler/42422/2 "2023-07-14T13:12:08Z")

</div>

cc @Evgeni_Popov

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [July 15, 2023, 8:20am UTC](https://forum.babylonjs.com/t/postprocess-weird-behavior-with-samples-1-and-getting-last-frame-sampler/42422/3 "2023-07-15T08:20:40Z")

</div>

You have this error in the console log:

```auto
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.

---

<div class="post-metadata">

**Author:** ![tanpopo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/tanpopo/32/32025_2.png) [@tanpopo](https://forum.babylonjs.com/u/tanpopo)\
**Post date:** [July 17, 2023, 12:52am UTC](https://forum.babylonjs.com/t/postprocess-weird-behavior-with-samples-1-and-getting-last-frame-sampler/42422/4 "2023-07-17T00:52:40Z")

</div>

> **[Babylon.js Playground](https://playground.babylonjs.com/#JAVY4F%2315)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

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.
