# RenderTarget autoClear

**URL:** <https://forum.babylonjs.com/t/rendertarget-autoclear/6117>\
**Category:** Questions\
**Tags:** material\
**Created:** [October 4, 2019, 9:36pm UTC](https://forum.babylonjs.com/t/rendertarget-autoclear/6117 "2019-10-04T21:36:21Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![syntheticmagus](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/syntheticmagus/32/395_2.png) [@syntheticmagus](https://forum.babylonjs.com/u/syntheticmagus)\
**Post date:** [October 4, 2019, 11:11pm UTC](https://forum.babylonjs.com/t/rendertarget-autoclear/6117/2 "2019-10-04T23:11:28Z")

</div>

Hi Corentin,

First of all, welcome to Babylon!

It doesn’t look like there’s a feature built in specifically for doing exactly that. However, judging by [this `if` statement](https://github.com/BabylonJS/Babylon.js/blob/master/src/Materials/Textures/renderTargetTexture.ts#L802-L806), it looks like adding an observer to the render target texture’s `onClear` observable will cause the texture to not be cleared.

I tested this by going to the “Custom Render Targets” [example Playground](https://www.babylonjs-playground.com/#CJWDJR#1) and adding the following code on a new line at 62:

```auto
renderTarget.onClearObservable.add(()=>{});

```

I think this might work for your purpose. One caveat, though: this prevents the clearing of the depth buffer, too, so you’ll have to be mindful of that if the depth buffer will affect your future drawing.

---

_[View the full topic](https://forum.babylonjs.com/t/rendertarget-autoclear/6117)._
