# Custom Depth Stencil Write Mask not work on Mobile

**URL:** <https://forums.unrealengine.com/t/custom-depth-stencil-write-mask-not-work-on-mobile/487755>\
**Category:** Rendering\
**Tags:** Mobile, stencil, unreal-engine, Rendering, question\
**Created:** [August 20, 2021, 10:14pm UTC](https://forums.unrealengine.com/t/custom-depth-stencil-write-mask-not-work-on-mobile/487755 "2021-08-20T22:14:31Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xiangming\_Lu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Xiangming\_Lu](https://forums.unrealengine.com/u/Xiangming_Lu)\
**Post date:** [August 20, 2021, 10:14pm UTC](https://forums.unrealengine.com/t/custom-depth-stencil-write-mask-not-work-on-mobile/487755/1 "2021-08-20T22:14:31Z")

</div>

On Mobile, Custom Depth Stencil Write Mask is not respected at all. For example, stencil value = 3. write mask = first bit. it should write out 1. but it write out 3. When can this be fixed?

---

<div class="post-metadata">

**Author:** ![Xiangming\_Lu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Xiangming\_Lu](https://forums.unrealengine.com/u/Xiangming_Lu)\
**Post date:** [August 20, 2021, 11:08pm UTC](https://forums.unrealengine.com/t/custom-depth-stencil-write-mask-not-work-on-mobile/487755/2 "2021-08-20T23:08:10Z")

</div>

![346841-stencil-write-mask.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/b/9/ab9af20edf6c1f07e3f6cbfbf2f232e64970be78.jpeg)

---

<div class="post-metadata">

**Author:** ![Xiangming\_Lu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Xiangming\_Lu](https://forums.unrealengine.com/u/Xiangming_Lu)\
**Post date:** [September 8, 2021, 9:14pm UTC](https://forums.unrealengine.com/t/custom-depth-stencil-write-mask-not-work-on-mobile/487755/3 "2021-09-08T21:14:46Z")

</div>

my further investigation shows that Scenetexture::CustomStencil is not reading from the depthstencil buffer. instead it is reading from a custom unorm buffer which is not stored the correct value. the stencil value looks correct in the depthstencil buffer though(via renderDoc)

---

<div class="post-metadata">

**Author:** ![Xiangming\_Lu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Xiangming\_Lu](https://forums.unrealengine.com/u/Xiangming_Lu)\
**Post date:** [September 8, 2021, 9:19pm UTC](https://forums.unrealengine.com/t/custom-depth-stencil-write-mask-not-work-on-mobile/487755/4 "2021-09-08T21:19:08Z")

</div>

![348249-read-stecil.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/4/0/640e8fba8613f7773e30915ff9efaa8f2400e34a.jpeg)

---

<div class="post-metadata">

**Author:** ![Xiangming\_Lu](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Xiangming\_Lu](https://forums.unrealengine.com/u/Xiangming_Lu)\
**Post date:** [September 8, 2021, 9:21pm UTC](https://forums.unrealengine.com/t/custom-depth-stencil-write-mask-not-work-on-mobile/487755/5 "2021-09-08T21:21:51Z")

</div>

Any ETA for a fix?

---

<div class="post-metadata">

**Author:** ![ArtemisLin](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/artemislin/32/88715_2.png) [@ArtemisLin](https://forums.unrealengine.com/u/ArtemisLin)\
**Post date:** [April 28, 2022, 6:05pm UTC](https://forums.unrealengine.com/t/custom-depth-stencil-write-mask-not-work-on-mobile/487755/6 "2022-04-28T18:05:31Z")

</div>

Hi, my problem is Custom Depth Stencil Write Mask doesn’t work any more on Mobile~How did you make it effect on Mobile?  
 ![Snipaste_2022-04-29_02-00-43](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/d/8/cd88e9d638cac5ca96a4826bbcc52fa59f08e834.png)

---

<div class="post-metadata">

**Author:** ![Starkium](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/starkium/32/1194588_2.png) [@Starkium](https://forums.unrealengine.com/u/Starkium)\
**Post date:** [April 6, 2024, 7:26pm UTC](https://forums.unrealengine.com/t/custom-depth-stencil-write-mask-not-work-on-mobile/487755/7 "2024-04-06T19:26:33Z")

</div>

I’m reading the engine source code and it seems that mobile doesn’t even use custom stencil even with hdr enabled.

in the non mobile post processing pass you have this

Engine\Source\Runtime\Renderer\Private\PostProcess\PostProcessing.cpp

```auto
		if (PassSequence.IsEnabled(EPass::Tonemap))
		{
			const FPostProcessMaterialChain MaterialChain = GetPostProcessMaterialChain(View, BL_ReplacingTonemapper);

			if (MaterialChain.Num())
			{
				const UMaterialInterface* HighestPriorityMaterial = MaterialChain[0];

				FPostProcessMaterialInputs PassInputs;
				PassSequence.AcceptOverrideIfLastPass(EPass::Tonemap, PassInputs.OverrideOutput);
				PassInputs.SetInput(EPostProcessMaterialInput::SceneColor, FScreenPassTexture::CopyFromSlice(GraphBuilder, SceneColorSlice));
				//PassInputs.SetInput(EPostProcessMaterialInput::SeparateTranslucency, SeparateTranslucency);
				PassInputs.SetInput(EPostProcessMaterialInput::CombinedBloom, Bloom);
				PassInputs.SceneTextures = GetSceneTextureShaderParameters(Inputs.SceneTextures);
				PassInputs.CustomDepthTexture = CustomDepth.Texture;
				PassInputs.bManualStencilTest = Inputs.bSeparateCustomStencil;

```

main thing being this line → PassInputs.bManualStencilTest = Inputs.bSeparateCustomStencil;

but in the mobile version there is no mention of stencil at all, just the custom depth texture. so it may be that objects get marked as custom depth, but there is no index associated to any of the objects. I’m still digging. The input seems like you could just insert the bool into the mobile pass, but I don’t know if any of the custom stencil stuff is built at that point.

---

<div class="post-metadata">

**Author:** ![digitalbug](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/digitalbug/32/690424_2.png) [@digitalbug](https://forums.unrealengine.com/u/digitalbug)\
**Post date:** [September 23, 2025, 10:31am UTC](https://forums.unrealengine.com/t/custom-depth-stencil-write-mask-not-work-on-mobile/487755/8 "2025-09-23T10:31:47Z")

</div>

any news on **Custom Depth Stencil** on Mobile?
