# RenderTexture update with custom pipeline

**URL:** <https://phaser.discourse.group/t/rendertexture-update-with-custom-pipeline/1123>\
**Category:** Phaser 3\
**Created:** [February 7, 2019, 7:54pm UTC](https://phaser.discourse.group/t/rendertexture-update-with-custom-pipeline/1123 "2019-02-07T19:54:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![hardylr](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/hardylr/32/677_2.png) [@hardylr](https://phaser.discourse.group/u/hardylr)\
**Post date:** [February 7, 2019, 7:54pm UTC](https://phaser.discourse.group/t/rendertexture-update-with-custom-pipeline/1123/1 "2019-02-07T19:54:36Z")

</div>

Im creating a renderTexture from complex game objects and then applying a custom render pipeline to that texture to apply a blur effect. This all works fine. The problem comes when I clear and redraw my renderTexture in the update loop as the state of my game objects change - it causes the displayed renderTexture to be upside down, mirrored and smaller in size.

I have created a codepen to show the behavior. Have a look [here](https://codepen.io/hardylr/pen/mvpmYY?editors=0010)

Is this a possible bug? Or maybe Im doing something wrong? Any ideas?

PS- Really digging Phaser 3!!  
Thanks!!

---

<div class="post-metadata">

**Author:** ![jjcapellan](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jjcapellan/32/542_2.png) [@jjcapellan](https://phaser.discourse.group/u/jjcapellan)\
**Post date:** [February 7, 2019, 10:05pm UTC](https://phaser.discourse.group/t/rendertexture-update-with-custom-pipeline/1123/2 "2019-02-07T22:05:07Z")

</div>

Hi @hardylr,  
In your create function this “solution” seems to work:

```javascript
    bubble.setPipeline('Custom');
    dude.setPipeline('Custom');
    rt.setPipeline('Custom'); 

```

It works but I really don’t know why. 🤔  
Regards.

---

<div class="post-metadata">

**Author:** ![hardylr](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/hardylr/32/677_2.png) [@hardylr](https://phaser.discourse.group/u/hardylr)\
**Post date:** [February 7, 2019, 10:41pm UTC](https://phaser.discourse.group/t/rendertexture-update-with-custom-pipeline/1123/3 "2019-02-07T22:41:00Z")

</div>

Hi @jjcapellan,

well, it sort of works. The shader has a weird effect on the renderTexture when you set the pipeline of the dude and bubble image also to ‘Custom’. The images in the example are a bit small for you to see the weird effect properly. Its like the shader gets applied twice.

Im also not sure how this is working. 🧐

Thanks for your reply

---

<div class="post-metadata">

**Author:** ![hardylr](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/hardylr/32/677_2.png) [@hardylr](https://phaser.discourse.group/u/hardylr)\
**Post date:** [February 8, 2019, 7:37am UTC](https://phaser.discourse.group/t/rendertexture-update-with-custom-pipeline/1123/4 "2019-02-08T07:37:50Z")

</div>

I have updated my [codepen](https://codepen.io/hardylr/pen/mvpmYY?editors=0010) example to better illustrate the problem.

- The first is just normal images added to the scene.

- The second is a renderTexture of the images added to the scene without any custom pipeline.

- The third is another renderTexture of the images added to the scene with a custom pipeline that gets redrawn on update. The renderTexture is upside down and much smaller in size.

- The forth is another renderTexture of the images added to the scene with a custom pipeline that does not get redrawn on update.

![image](https://global.discourse-cdn.com/free1/uploads/phaser1/original/1X/a32ae3d928f06c2538108be623921eb8743a39e9.png)

---

<div class="post-metadata">

**Author:** ![jjcapellan](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jjcapellan/32/542_2.png) [@jjcapellan](https://phaser.discourse.group/u/jjcapellan)\
**Post date:** [February 8, 2019, 10:58am UTC](https://phaser.discourse.group/t/rendertexture-update-with-custom-pipeline/1123/5 "2019-02-08T10:58:32Z")

</div>

Hi again @hardylr,  
A possible workaround is apply the custom pipeline over a camera with the method [setRenderToTexture](https://photonstorm.github.io/phaser3-docs/Phaser.Cameras.Scene2D.Camera.html#setRenderToTexture__anchor):

```javascript
    // In create function
    var cam = this.cameras.add(0,0,800,600);
    cam.setRenderToTexture('Custom');
  
    bubble = this.add.image(20, 230, 'bubble').setScale(2,2).setOrigin(0,0);
    dude = this.add.image(55, 250, 'dude').setScale(2,2).setOrigin(0,0);
    cam.ignore([bubble,dude]);
  
    rt = this.add.renderTexture(200, 200, 200, 200); 
    rt.draw(bubble, 32, 32);
    rt.draw(dude, 68, 48);
    this.cameras.main.ignore(rt);

```

Surely not the best solution, but it works … 😀  
Regards.

---

<div class="post-metadata">

**Author:** ![hardylr](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/hardylr/32/677_2.png) [@hardylr](https://phaser.discourse.group/u/hardylr)\
**Post date:** [February 9, 2019, 4:29am UTC](https://phaser.discourse.group/t/rendertexture-update-with-custom-pipeline/1123/6 "2019-02-09T04:29:14Z")

</div>

Thank you @jjcapellan, I ended up using your solution. 😄

---

<div class="post-metadata">

**Author:** ![hardylr](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/hardylr/32/677_2.png) [@hardylr](https://phaser.discourse.group/u/hardylr)\
**Post date:** [February 9, 2019, 4:35am UTC](https://phaser.discourse.group/t/rendertexture-update-with-custom-pipeline/1123/7 "2019-02-09T04:35:04Z")

</div>

I managed to find a solution to updating and redrawing a renderTexture that is rendered through a custom pipeline. I dont know if this is optimal or not, but it seems to be working.

```
function update (){
  rt.resetPipeline()
  rt.clear();
  rt.draw(bubble, 32, 32);
  rt.draw(dude, 68, 48);
  rt.setPipeline('Custom');
}
```
