public DelegateParameterArrayBinding <T> Set <T>(EffectParameter parameter, Action <DelegateParameterArrayBinding <T>, RenderContext, T[]> computeParameter)
        {
            DelegateParameterArrayBinding <T> binding;
            int index = ParameterBindings.IndexOf(parameter);

            if (index >= 0)
            {
                // An effect parameter binding already exists.
                binding = ParameterBindings[index] as DelegateParameterArrayBinding <T>;
                if (binding != null)
                {
                    // Update existing binding.
                    binding.ComputeParameter = computeParameter;
                }
                else
                {
                    // Replace existing binding.
                    binding = new DelegateParameterArrayBinding <T>(Effect, parameter, computeParameter);
                    ParameterBindings[index] = binding;
                }
            }
            else
            {
                // Create a new binding.
                binding = new DelegateParameterArrayBinding <T>(Effect, parameter, computeParameter);
                CheckHint(binding);
                ParameterBindings.Add(binding);
            }

            return(binding);
        }
        private static void GetBaseClipmapOrigins(DelegateParameterArrayBinding <Vector2> binding, RenderContext context, Vector2[] values)
        {
            var origins = GetTerrainNode(context).BaseClipmap.Origins;

            for (int i = 0; i < Math.Min(origins.Length, values.Length); i++)
            {
                values[i] = (Vector2)origins[i];
            }
        }
        private static void GetDetailClipmapOffsets(DelegateParameterArrayBinding <Vector2> binding, RenderContext context, Vector2[] values)
        {
            var offsets = GetTerrainNode(context).DetailClipmap.Offsets;

            for (int i = 0; i < Math.Min(offsets.Length, values.Length); i++)
            {
                values[i] = (Vector2)offsets[i];
            }
        }
        private static void GetTerrainClearValues(DelegateParameterArrayBinding <Vector4> binding, RenderContext context, Vector4[] values)
        {
            var terrain     = GetTerrainNode(context).Terrain;
            var clearValues = (context.RenderPass == "Base") ? terrain.BaseClearValues : terrain.DetailClearValues;

            for (int i = 0; i < Math.Min(clearValues.Length, values.Length); i++)
            {
                values[i] = (Vector4)clearValues[i];
            }
        }
        private static void GetDetailClipmapCellSizes(DelegateParameterArrayBinding <float> binding, RenderContext context, float[] values)
        {
            var cellSizes = GetTerrainNode(context).DetailClipmap.CellSizes;

            for (int i = 0; i < Math.Min(cellSizes.Length, values.Length); i++)
            {
                values[i] = cellSizes[i];
            }

            for (int i = 1; i < values.Length; i++)
            {
                if (Numeric.IsNaN(values[i]))
                {
                    values[i] = values[i - 1] * 2;
                }
            }
        }