- Home /
Are sprite masks incompatible with Render Textures?
Hello everyone,
I've just noticed on a new project that Sprite Masks don't seem to work when the camera renders to a texture via a Render Texture target. Everything works just fine on the Camera and in-editor views, but the RenderTarget texture appears as though neither the masks nor one of my custom shaders are active.
The custom shader that isn't working correctly makes use of the stencil buffer. Thus, I'm assuming the stencil buffer is the culprit and that the built-in Sprite Masks are implemented with the stencil buffer.
Is this a bug? Intended behavior that I'm misunderstanding?
I haven't tried writing the pixels from the Camera over to the texture myself yet as I'm about to head to bed, but that's what I'll try next. Figured asking here might save me some time and effort tomorrow with any luck :)
Any insight is appreciated. Thank you all!
Answer by AdayMelian · Nov 13, 2020 at 02:06 PM
I know this is old but I stepped into this problem now with Unity 2020 and I could solve it by changing "Depth Buffer" into RenderTexture object on Project Tab to "At least 24 bits depth (with stencil)"
I hope this helps!
Thanks - I will give that a try! (I still haven't found a fix, so thanks for sharing!) :D
Hmmm. Where is this setting? I can't seem to find it in Unity 2019. :/
Answer by Brachiosaurus · Jun 22, 2021 at 06:57 PM
Hey, I know this whole discussion is pretty old, but I was having the same issue and I fixed it just by enabling Post Processing on the camera in the inspector.
If anybody out there is struggling with this, give that a try.
Answer by Khelz · Jul 11, 2018 at 02:45 AM
I'm happy to post screenshots or provide any additional information that might help us get to the bottom of this!
Answer by DanTaylor · Mar 16, 2020 at 06:06 AM
I am having the same problem. Sprite Masks work fine in a normal camera... but don't work when shown in a render texture. Any solutions? Cheers, Dan
Hi Dan,
This was a long time ago but I don't think I ever got this fixed.
Sorry, that isn't much help but I didn't want to leave you hanging on any false hope.
Thanks for the info - that's much appreciated. Looks like I'll just have to write a specific shader to handle masking then. Yay. :/