# Mask a renderTexture

**URL:** <https://phaser.discourse.group/t/mask-a-rendertexture/12240>\
**Category:** Phaser 3\
**Created:** [August 30, 2022, 4:23pm UTC](https://phaser.discourse.group/t/mask-a-rendertexture/12240 "2022-08-30T16:23:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![PhaserNoob](https://avatars.discourse-cdn.com/v4/letter/p/ed8c4c/32.png) [@PhaserNoob](https://phaser.discourse.group/u/PhaserNoob)\
**Post date:** [August 30, 2022, 4:23pm UTC](https://phaser.discourse.group/t/mask-a-rendertexture/12240/1 "2022-08-30T16:23:20Z")

</div>

I created a gradient background and i want to remove (mask) some parts of the texture.

But mask= / setMask() did not do anything.

```javascript
const width = 100
const heigth = 200

const rt = this.add.renderTexture(0, 0, width, height).setIsSpriteTexture(true).setVisible(false)
const boxRt = this.add.renderTexture(0, 0, width, height).setIsSpriteTexture(true).setVisible(false)
const gradientRt = this.add.renderTexture(0, 0, width, height).setIsSpriteTexture(true).setVisible(false)

// gradient
const gradient = this.add.graphics().setVisible(false)

gradient.fillGradientStyle(0xff0000, 0xff0000, 0x0000ff, 0x0000ff, 1, 1, 1, 1)
gradient.fillRect(0, 0, this.width + 200, height + 80)
gradient.setAngle(-30)

gradientRt.draw(gradient, -200, 80)

// box
const box = this.add.graphics().setVisible(false)

box.fillStyle(0xffff00, 1)

box.beginPath()
box.moveTo(20, 20)
box.lineTo(40, 20)
box.lineTo(40, 40)
box.lineTo(20, 40)
box.closePath()
box.fillPath()
box.strokePath()

boxRt.draw(box, 0, 0)

// mask
// const boxMask = boxRt.createBitmapMask() // not work
const boxMask = new Phaser.Display.Masks.GeometryMask(this, box) // not work
gradientRt.setMask(boxMask)

// draw
rt.draw(gradientRt)

```

Is it not possible to mask textures?

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [August 30, 2022, 6:37pm UTC](https://phaser.discourse.group/t/mask-a-rendertexture/12240/2 "2022-08-30T18:37:18Z")

</div>

You can’t mask a texture itself, only a game object.

---

<div class="post-metadata">

**Author:** ![PhaserNoob](https://avatars.discourse-cdn.com/v4/letter/p/ed8c4c/32.png) [@PhaserNoob](https://phaser.discourse.group/u/PhaserNoob)\
**Post date:** [August 31, 2022, 8:37am UTC](https://phaser.discourse.group/t/mask-a-rendertexture/12240/3 "2022-08-31T08:37:04Z")

</div>

Ok, thank you.
