private void updateMarginsAndPasses()
 {
     if (mBlurX == 0 && mBlurY == 0)
     {
         mBlurX = 0.001f;
     }
     setNumPasses(AsMath.ceil(mBlurX) + AsMath.ceil(mBlurY));
     setMarginX(4 + AsMath.ceil(mBlurX));
     setMarginY(4 + AsMath.ceil(mBlurY));
 }
        private void updateParameters(int pass, int textureWidth, int textureHeight)
        {
            float sigma      = 0;
            bool  horizontal = pass < mBlurX;
            float pixelSize  = 0;

            if (horizontal)
            {
                sigma     = AsMath.min(1.0f, mBlurX - pass) * MAX_SIGMA;
                pixelSize = 1.0f / textureWidth;
            }
            else
            {
                sigma     = AsMath.min(1.0f, mBlurY - (pass - AsMath.ceil(mBlurX))) * MAX_SIGMA;
                pixelSize = 1.0f / textureHeight;
            }
            float twoSigmaSq = 2 * sigma * sigma;
            float multiplier = 1.0f / AsMath.sqrt(twoSigmaSq * AsMath.PI);
            int   i          = 0;

            for (; i < 4; ++i)
            {
                sTmpWeights[i] = multiplier * AsMath.exp(-i * i / twoSigmaSq);
            }
            mWeights[0] = sTmpWeights[0];
            mWeights[1] = sTmpWeights[1] + sTmpWeights[2];
            mWeights[2] = sTmpWeights[3] + sTmpWeights[4];
            float weightSum    = mWeights[0] + 2 * mWeights[1] + 2 * mWeights[2];
            float invWeightSum = 1.0f / weightSum;

            mWeights[0] = mWeights[0] * invWeightSum;
            mWeights[1] = mWeights[1] * invWeightSum;
            mWeights[2] = mWeights[2] * invWeightSum;
            float offset1 = (pixelSize * sTmpWeights[1] + 2 * pixelSize * sTmpWeights[2]) / mWeights[1];
            float offset2 = (3 * pixelSize * sTmpWeights[3] + 4 * pixelSize * sTmpWeights[4]) / mWeights[2];

            if (horizontal)
            {
                mOffsets[0] = offset1;
                mOffsets[1] = 0;
                mOffsets[2] = offset2;
                mOffsets[3] = 0;
            }
            else
            {
                mOffsets[0] = 0;
                mOffsets[1] = offset1;
                mOffsets[2] = 0;
                mOffsets[3] = offset2;
            }
        }