# How to set some render target as a pixel shader's input?

**URL:** <https://forums.unrealengine.com/t/how-to-set-some-render-target-as-a-pixel-shaders-input/1783949>\
**Category:** International\
**Tags:** unreal-engine, pixel, Rendering, Shaders, question\
**Created:** [April 2, 2024, 4:50pm UTC](https://forums.unrealengine.com/t/how-to-set-some-render-target-as-a-pixel-shaders-input/1783949 "2024-04-02T16:50:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anonymous\_f5ae1799aeee410c63cc8bb85b52e0f0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_f5ae1799aeee410c63cc8bb85b52e0f0](https://forums.unrealengine.com/u/Anonymous_f5ae1799aeee410c63cc8bb85b52e0f0)\
**Post date:** [April 2, 2024, 4:50pm UTC](https://forums.unrealengine.com/t/how-to-set-some-render-target-as-a-pixel-shaders-input/1783949/1 "2024-04-02T16:50:51Z")

</div>

Here’s the thing: I wrote a fisheye camera and created 5 scenecapturecomponent2d of the same size. For each frame in the rendering thread, I will read the render targets of these 5 cameras into FColor arrays into the memory, and then construct a new FColor array of the same size based on my mathematical model, and finally send it out or save it to local.  
I did this and found that it took a bit long. So I have the following questions

1. Can I put those pixels calculate in the pixel shader?
2. If I place those pixels calculate in the pixel shader, is that mean I save the time of copying 5 camera data from the GPU to the memory?
3. Will the GPU do the calculation work of these pixels faster?
4. If I want to write these tasks as a pixel shader, how should I do it? I have never written a shader. How can I take the render targets of 5 cameras as input and get a new render target based on special calculations? Because I briefly looked at the shader course titles, they all seem to be related to post-processing. I didn’t find the function for render target as input to pixel shader.
5. All I want to do is to put pixel calculate work on GPU, and see will get a higher frame rate than before.  
HELP ME PLEASE AND THANKS A LOT!!!

---

<div class="post-metadata">

**Author:** ![Speido](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Speido](https://forums.unrealengine.com/u/Speido)\
**Post date:** [April 2, 2024, 9:21pm UTC](https://forums.unrealengine.com/t/how-to-set-some-render-target-as-a-pixel-shaders-input/1783949/2 "2024-04-02T21:21:01Z")

</div>

CPU transfer is extremely expensive. Not sure about your mathematical model, but if you can do your calculations in pixel shader, it could run in realtime. You can simply create a material with your model and use DrawMaterialToRenderTarget to draw to a (new) render target. Set the material to “Post Process”, the output is “Emissive Color” and maybe “Opacity” if you want 4 channels. Bind your 5 render targets as regular inputs like any texture (see SetTextureParameterValue). Maybe use the gui material graphs to get started.

---

<div class="post-metadata">

**Author:** ![thadweldon5](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@thadweldon5](https://forums.unrealengine.com/u/thadweldon5)\
**Post date:** [June 17, 2024, 4:24pm UTC](https://forums.unrealengine.com/t/how-to-set-some-render-target-as-a-pixel-shaders-input/1783949/3 "2024-06-17T16:24:43Z")

</div>

any luck with this? I have a similar problem

---

<div class="post-metadata">

**Author:** ![Anonymous\_f5ae1799aeee410c63cc8bb85b52e0f0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_f5ae1799aeee410c63cc8bb85b52e0f0](https://forums.unrealengine.com/u/Anonymous_f5ae1799aeee410c63cc8bb85b52e0f0)\
**Post date:** [November 13, 2024, 11:13am UTC](https://forums.unrealengine.com/t/how-to-set-some-render-target-as-a-pixel-shaders-input/1783949/4 "2024-11-13T11:13:32Z")

</div>

thanks, I use compute shader to solve this , and frame rate is 4 times higher than before

---

<div class="post-metadata">

**Author:** ![Anonymous\_f5ae1799aeee410c63cc8bb85b52e0f0](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Anonymous\_f5ae1799aeee410c63cc8bb85b52e0f0](https://forums.unrealengine.com/u/Anonymous_f5ae1799aeee410c63cc8bb85b52e0f0)\
**Post date:** [November 13, 2024, 11:15am UTC](https://forums.unrealengine.com/t/how-to-set-some-render-target-as-a-pixel-shaders-input/1783949/5 "2024-11-13T11:15:01Z")

</div>

I use compute shader solve all problem ， you can try it
