# How Can I Clamp Render Target Values

**URL:** <https://forums.unrealengine.com/t/how-can-i-clamp-render-target-values/414724>\
**Category:** Rendering\
**Tags:** rendertarget, unreal-engine, clamp, render-target, question\
**Created:** [January 16, 2018, 7:09pm UTC](https://forums.unrealengine.com/t/how-can-i-clamp-render-target-values/414724 "2018-01-16T19:09:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Justin.Dooley](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/justin.dooley/32/1194553_2.png) [@Justin.Dooley](https://forums.unrealengine.com/u/Justin.Dooley)\
**Post date:** [January 16, 2018, 7:09pm UTC](https://forums.unrealengine.com/t/how-can-i-clamp-render-target-values/414724/1 "2018-01-16T19:09:47Z")

</div>

I’m trying to make a painting tool in a similar way that the Render Target examples has a height map tool. Everything is working fine until I try to erase. I pass a negative value into the power and clamp the output before adding it to my material. This allows me to have 0-1 values and the paint is essentially masked. The problem is that the texture still has larger and smaller values so you can erase a spot multiple times and essentially prevents painting until you get it above that 0 value again. Likewise, painting the same place causes values greater than 1 (making erasing have no effect until reduced bellow 1).

To solve this, I need to take my additive material and add it to the render target then clamp those values after that. I was hoping someone could point me in the direction of where I could do this. If it requires some C++ that’s fine as well.

---

<div class="post-metadata">

**Author:** ![Deathrey](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Deathrey](https://forums.unrealengine.com/u/Deathrey)\
**Post date:** [January 16, 2018, 10:21pm UTC](https://forums.unrealengine.com/t/how-can-i-clamp-render-target-values/414724/2 "2018-01-16T22:21:16Z")

</div>

Correct way would be using appropriate render target format, designed to store values in 0-1 range.

---

<div class="post-metadata">

**Author:** ![Justin.Dooley](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/justin.dooley/32/1194553_2.png) [@Justin.Dooley](https://forums.unrealengine.com/u/Justin.Dooley)\
**Post date:** [January 16, 2018, 10:25pm UTC](https://forums.unrealengine.com/t/how-can-i-clamp-render-target-values/414724/3 "2018-01-16T22:25:08Z")

</div>

I came to the same conclusion (with your helpt actually) but even setting it to RTF\_R8 didn’t work.
