Masking Texture2D without shaders?

Hello again

I’m trying to create mask for textures, but so far no luck.

The last answer in this page is close to what I’d like to have, but for some reason it won’t work.
Here’s my code uploaded to Pastebin, and Textures uploaded to Postimage

I’m I doing something wrong or is it a bug? I 'm using VS2015 with DesktopGL Project.

Before no one answers, here are the stencil operations I used, maybe try with these. They are for 3d light culling, so maybe not ideal (The StencilOperations in the second one should be Keep instead of Zero for your case)
I don’t have the time right now to check your code :frowning:

_stencilCullPass1 = new DepthStencilState()
                DepthBufferEnable = true,
                DepthBufferWriteEnable = false,
                DepthBufferFunction = CompareFunction.LessEqual,
                StencilFunction = CompareFunction.Always,
                StencilDepthBufferFail = StencilOperation.IncrementSaturation,
                StencilPass = StencilOperation.Keep,
                StencilFail = StencilOperation.Keep,
                CounterClockwiseStencilFunction = CompareFunction.Always,
                CounterClockwiseStencilDepthBufferFail = StencilOperation.Keep,
                CounterClockwiseStencilPass = StencilOperation.Keep,
                CounterClockwiseStencilFail = StencilOperation.Keep,
                StencilMask = 0,
                ReferenceStencil = 0,
                StencilEnable = true,

        _stencilCullPass2 = new DepthStencilState()
            DepthBufferEnable = false,
            DepthBufferWriteEnable = false,
            DepthBufferFunction = CompareFunction.GreaterEqual,
            CounterClockwiseStencilFunction = CompareFunction.Equal,
            StencilFunction = CompareFunction.Equal,
            StencilFail = StencilOperation.Zero,
            StencilPass = StencilOperation.Zero,
            CounterClockwiseStencilFail = StencilOperation.Zero,
            CounterClockwiseStencilPass = StencilOperation.Zero,
            ReferenceStencil = 0,
            StencilEnable = true,
            StencilMask = 0,