# Extending pre-pass renderer to support custom render targets

**URL:** <https://forum.babylonjs.com/t/extending-pre-pass-renderer-to-support-custom-render-targets/58862>\
**Category:** Feature requests\
**Tags:** prepassrenderer, render-target\
**Created:** [June 6, 2025, 10:45am UTC](https://forum.babylonjs.com/t/extending-pre-pass-renderer-to-support-custom-render-targets/58862 "2025-06-06T10:45:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shakdwipeea](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/shakdwipeea/32/39634_2.png) [@shakdwipeea](https://forum.babylonjs.com/u/shakdwipeea)\
**Post date:** [June 6, 2025, 10:45am UTC](https://forum.babylonjs.com/t/extending-pre-pass-renderer-to-support-custom-render-targets/58862/1 "2025-06-06T10:45:39Z")

</div>

I want to extend babylon’s pre-renderer to support some custom render-target(s).  
An example could be a id map rtt inspired by the one used in gpu-picking.  
Sample: [https://playground.babylonjs.com/#3W87R0#2](https://playground.babylonjs.com/#3W87R0#2)

I found a way of integrating this by modifying the `default.fragment.fx` in `packages/dev/core/src/Shaders/default.fragment.fx` and including a block which writes to a separate rtt

```auto
	#ifdef PREPASS_IDMAP
		gl_FragData[PREPASS_IDMAP_INDEX] = vec4(1.0, 0.0, 0.0, writeGeometryInfo);
	#endif

```

I had to also add the textureFormat I wanted in the prepassRenderer, along with some other minor updates to fix all references.

```auto
  {
            purpose: Constants.PREPASS_IDMAP_TEXTURE_TYPE,
            type: Constants.TEXTURETYPE_UNSIGNED_BYTE,
            format: Constants.TEXTUREFORMAT_RGBA,
            name: "prePass_IdMap",
 }

```

I wanted to know if there is a simpler way of adding such a render target to the existing prePassRenderer ?

---

<div class="post-metadata">

**Author:** ![ryantrem](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/ryantrem/32/34010_2.png) [@ryantrem](https://forum.babylonjs.com/u/ryantrem)\
**Post date:** [June 20, 2025, 7:24pm UTC](https://forum.babylonjs.com/t/extending-pre-pass-renderer-to-support-custom-render-targets/58862/2 "2025-06-20T19:24:11Z")

</div>

This might be the kind of thing that is addressed by the new [Frame Graph](https://doc.babylonjs.com/features/featuresDeepDive/frameGraph/) system, but maybe @Evgeni_Popov can comment when he is back.

---

<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:** [June 24, 2025, 9:07am UTC](https://forum.babylonjs.com/t/extending-pre-pass-renderer-to-support-custom-render-targets/58862/3 "2025-06-24T09:07:42Z")

</div>

Yes, that’s something we will want to support with frame graphs and not with the prepass renderer, as the latter is more limited. At the time, it’s not possible to do it in a simple way, though. I’ve added it to the frame graph todo list.

---

<div class="post-metadata">

**Author:** ![shakdwipeea](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/shakdwipeea/32/39634_2.png) [@shakdwipeea](https://forum.babylonjs.com/u/shakdwipeea)\
**Post date:** [June 28, 2025, 8:50am UTC](https://forum.babylonjs.com/t/extending-pre-pass-renderer-to-support-custom-render-targets/58862/4 "2025-06-28T08:50:01Z")

</div>

awesome! looking forward to it!
