Exemplo n.º 1
0
        public static bool CallFragmentStage(ref Vertex vertex, int x, int y, out Color finallyColor)
        {
            ResetDiscard();

            finallyColor = currentMaterial.CallFragmentStage(ref vertex);

            // color blend
            if (currentMaterial.blendEnbale)
            {
                finallyColor = BlendColor.Calculate(finallyColor, GetBufferColor(x, y),
                                                    currentMaterial.blendOp, currentMaterial.srcFactor, currentMaterial.destFactor, currentMaterial.srcFactorA, currentMaterial.destFactorA);
            }

            // alpha test
            if (IsAlphaTestOn() && !AlphaTest.IsPass(currentMaterial.alphaTest, finallyColor.a, currentMaterial.alphaTestValue))
            {
                Discard();
            }

            if (IsDiscard())
            {
                return(false);
            }

            SetBufferColor(x, y, finallyColor);

            // simple clamp color values to [0, 1]
            finallyColor = Color.Saturate(finallyColor);
            return(true);
        }