PSSMDemo.GaussianBlurEffect.SetKernelWeights C# (CSharp) Method

SetKernelWeights() public method

public SetKernelWeights ( ) : void
return void
        void SetKernelWeights()
        {
            if ((dirtyFlags & DirtyFlags.KernelWeights) != 0)
            {
                var totalWeight = 0.0f;
                var sigma = (float) radius / amount;

                var weight = CalculateGaussian(sigma, 0);

                horizontalKernels[0].Z = weight;
                verticalKernels[0].Z = weight;

                totalWeight += weight;

                for (int i = 0; i < kernelSize / 2; i++)
                {
                    int baseIndex = i * 2;
                    int left = baseIndex + 1;
                    int right = baseIndex + 2;

                    weight = CalculateGaussian(sigma, i + 1);
                    totalWeight += weight * 2;

                    horizontalKernels[left].Z = weight;
                    horizontalKernels[right].Z = weight;

                    verticalKernels[left].Z = weight;
                    verticalKernels[right].Z = weight;
                }

                // Normalize
                float inverseTotalWeights = 1.0f / totalWeight;
                for (int i = 0; i < kernelSize; i++)
                {
                    horizontalKernels[i].Z *= inverseTotalWeights;
                    verticalKernels[i].Z *= inverseTotalWeights;
                }

                dirtyFlags &= ~DirtyFlags.KernelWeights;
            }
        }