Custom UI Shader Stencil Problem [willing to pay for fix]

custom shader on UI element that needs stencil to work with UI MASK.

The problem is, if the stencil code is used, I can no longer set material colors for the subshader to work correctly, so the palette swap no longer works. (palette swap broken, but ui mask works) (palette swap works, but ui mask broken)