# Changing Custom Stencil Value At Runtime Doesn't Work?

**URL:** <https://forums.unrealengine.com/t/changing-custom-stencil-value-at-runtime-doesnt-work/370044>\
**Category:** Rendering\
**Tags:** Post-Processing, bug, stencil, unreal-engine, Rendering, question\
**Created:** [September 10, 2016, 9:53pm UTC](https://forums.unrealengine.com/t/changing-custom-stencil-value-at-runtime-doesnt-work/370044 "2016-09-10T21:53:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rujuro](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rujuro](https://forums.unrealengine.com/u/rujuro)\
**Post date:** [September 10, 2016, 9:53pm UTC](https://forums.unrealengine.com/t/changing-custom-stencil-value-at-runtime-doesnt-work/370044/1 "2016-09-10T21:53:37Z")

</div>

Is changing the stencil value of a static mesh component at runtime not supported? I am finding that if I change the value (say from 0 to 200) while viewing a post process effect that uses it, the object in question does not show up in the stencil mask. However if I START with that same value, then it is visible.

In addition, it seems that if I recompile the material while the game is running in PIE, the mask starts showing up as well. Is there something that needs to be done to force the object to update its render parameters if they change at runtime? Thanks!

---

<div class="post-metadata">

**Author:** ![rujuro](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rujuro](https://forums.unrealengine.com/u/rujuro)\
**Post date:** [September 10, 2016, 11:23pm UTC](https://forums.unrealengine.com/t/changing-custom-stencil-value-at-runtime-doesnt-work/370044/2 "2016-09-10T23:23:36Z")

</div>

I got this to work by adding MarkRenderStateDirty(). I am not sure if this is the proper way to handle it though, and would still like any feedback anyone can offer.

Thanks

---

<div class="post-metadata">

**Author:** ![andoalon](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@andoalon](https://forums.unrealengine.com/u/andoalon)\
**Post date:** [March 22, 2019, 11:00am UTC](https://forums.unrealengine.com/t/changing-custom-stencil-value-at-runtime-doesnt-work/370044/3 "2019-03-22T11:00:09Z")

</div>

It worked for me too. I still don’t know whether that’s the proper way to do it but it works ¯\_(ツ)\_/¯

---

<div class="post-metadata">

**Author:** ![MoonHoodYogurt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MoonHoodYogurt](https://forums.unrealengine.com/u/MoonHoodYogurt)\
**Post date:** [November 26, 2025, 3:04pm UTC](https://forums.unrealengine.com/t/changing-custom-stencil-value-at-runtime-doesnt-work/370044/4 "2025-11-26T15:04:34Z")

</div>

yep, this was still a problem in 5.61 and the workaround or intended solution was to markrenderstatedirty
