# How CustomProceduralTexture use itself last render result

**URL:** <https://forum.babylonjs.com/t/how-customproceduraltexture-use-itself-last-render-result/39939>\
**Category:** Questions\
**Tags:** texture, render-target\
**Created:** [April 17, 2023, 3:12am UTC](https://forum.babylonjs.com/t/how-customproceduraltexture-use-itself-last-render-result/39939 "2023-04-17T03:12:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zzh505968568](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/zzh505968568/32/31483_2.png) [@zzh505968568](https://forum.babylonjs.com/u/zzh505968568)\
**Post date:** [April 17, 2023, 3:12am UTC](https://forum.babylonjs.com/t/how-customproceduraltexture-use-itself-last-render-result/39939/1 "2023-04-17T03:12:08Z")

</div>

How CustomProceduralTexture use itself as next input.  
I want create a CustomProceduralTexture and use itself render result as next input.  
I try

```auto
this.onGeneratedObservable.add((texture)=>{
            this.setTexture("lastRender", texture);
            // console.log(123);
        });

```

It not work how can I do it, Please give me an example demo.

---

<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:** [April 17, 2023, 6:07am UTC](https://forum.babylonjs.com/t/how-customproceduraltexture-use-itself-last-render-result/39939/2 "2023-04-17T06:07:02Z")

</div>

You can use two textures to get the result.

> [@Onion Skin Post Process?](https://forum.babylonjs.com/t/onion-skin-post-process/9362/24):
>
> NOW I get it! That is amazing… Here’s a documented version of the Onion Skin Effect playground, for future explorers: [https://playground.babylonjs.com/#ZLB7Z2#6](https://playground.babylonjs.com/#ZLB7Z2#6)

Though the example used RTT, it should be similar with CustomProceduralTexture.

---

<div class="post-metadata">

**Author:** ![zzh505968568](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/zzh505968568/32/31483_2.png) [@zzh505968568](https://forum.babylonjs.com/u/zzh505968568)\
**Post date:** [April 17, 2023, 12:23pm UTC](https://forum.babylonjs.com/t/how-customproceduraltexture-use-itself-last-render-result/39939/3 "2023-04-17T12:23:53Z")

</div>

It works!  
But I made a mistake. I need to process vertex data, maybe I should use `ShaderMaterial` , Can `ShaderMaterial` use pingpong?  
I tried but didn’t succeed. I want to implement the function of drawing on complex models， use shader to calculate painting position.

---

<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:** [April 18, 2023, 12:47am UTC](https://forum.babylonjs.com/t/how-customproceduraltexture-use-itself-last-render-result/39939/4 "2023-04-18T00:47:11Z")

</div>

I’m not sure if I catch your words, but it seems custom post processes work for your situation?

> **[How To Use Post Processes | Babylon.js Documentation](https://doc.babylonjs.com/features/featuresDeepDive/postProcesses/usePostProcesses#custom-postprocesses)**
>
> Learn how to use post process effect in Babylon.js.

---

<div class="post-metadata">

**Author:** ![zzh505968568](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/zzh505968568/32/31483_2.png) [@zzh505968568](https://forum.babylonjs.com/u/zzh505968568)\
**Post date:** [April 18, 2023, 1:33am UTC](https://forum.babylonjs.com/t/how-customproceduraltexture-use-itself-last-render-result/39939/5 "2023-04-18T01:33:40Z")

</div>

Sorry, maybe I didn’t express clearly.  
I learned that Post Processes is bound to the camera, as follows:

 ![A17T0977-0001 (5)](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/3/0/30c7e62eeb333f0d1d9110006bf7466eee6b8006.jpeg)  
but I want a texture based on model，like UV map, as follows:  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/4/e/4ebd4ab54289d7c6bf70cc2e0315f5e392e80ea9.png)  
How can I get `ShaderMaterial` rendered texture like that?
