New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[unity] Unity 2017 SpriteMask support #941
Comments
Doesn't look good so far. The system/API seems pretty enclosed at the moment. |
It's entirely possible. The masking system uses stencil buffer: |
Thanks for the info! Super helpful. What's weird is that (in the above gif) I was using the unmodified |
Perhaps Unity is doing some broken magic internally if no Stencil section is defined in the shader? |
I suppose, under the hood, stencil properties you type in ShaderLab are really just instructions for the UnityEngine's C++ side to call the appropriate graphics library stencil function calls. Maybe there's no reason why their components can't just call those stencil functions regardless of what the ShaderLab code says. No magic. Anyway... I just added this part Sergi mentioned: Stencil {
Ref 1 //Customize this value
Comp Equal //Customize the compare function
Pass Keep
} to the Spine/Skeleton shader. The Ref 1 is an odd magic number though. He says to customize it, but customize it based on what? At the very least, we can just share this in a thread in the forums, with the link and description of what changes were made, so the user can apply the same changes to their own shaders. We'll judge the need to include it in the runtime from there. |
I'll update this later with a version that exposes the stencil properties as material inspector fields. Done |
@pharan Problem with this shader is that this way, it will always do the stencil test. There is no way to turn it off except not having the Stencil block. So two shaders and materials are required to cover everything - one with stencil test, and one without. |
Oh, definitely. I had no intention of officially adding the stencil test to the default shader in the package. I was just doing it to poke at stuff and see how the thing works. |
Related forum bugreport / request: |
… SkeletonMecanim. All mask interaction modes supported. See #941.
… SkeletonMecanim. All mask interaction modes supported. See #941.
Issue with RectMask2D identified as separate issue, now filed separately under #1283. |
Unity 2017.1 introduces SpriteMask.
https://docs.unity3d.com/2017.1/Documentation/ScriptReference/SpriteMask.html
SpriteMask is a component that can mask UnityEngine.Sprites in a certain arrangement in the scene graph.
Example of SpriteMask used on UnityEngine.Sprites:
Under investigation:
Q: Does it require new Shader code on the masked object? Does it require component code?
A: SpriteRenderers that use a Spine/Skeleton shader Material seem to be able to be masked.
Q: Can it mask MeshRenderers? (it can mask Particles. so maybe.)
Q: How is its mask scope determined by code?
The text was updated successfully, but these errors were encountered: