コード例 #1
0
ファイル: Invert.cs プロジェクト: sunny8751/BurstLibNoise
        /// <summary>
        /// Returns the output value for the given input coordinates.
        /// </summary>
        /// <param name="x">The input coordinate on the x-axis.</param>
        /// <param name="y">The input coordinate on the y-axis.</param>
        /// <param name="z">The input coordinate on the z-axis.</param>
        /// <returns>The resulting output value.</returns>
        public static float GetBurstValue(float x, float y, float z, NativeArray <ModuleData> data, int dataIndex)
        {
            ModuleData moduleData = data[dataIndex];

            // Debug.Assert(Modules[0] != null);
            return(-BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(0)));
        }
コード例 #2
0
        /// <summary>
        /// Returns the output value for the given input coordinates.
        /// </summary>
        /// <param name="x">The input coordinate on the x-axis.</param>
        /// <param name="y">The input coordinate on the y-axis.</param>
        /// <param name="z">The input coordinate on the z-axis.</param>
        /// <returns>The resulting output value.</returns>
        public static float GetBurstValue(float x, float y, float z, NativeArray <ModuleData> data, int dataIndex)
        {
            ModuleData moduleData = data[dataIndex];
            float      _min       = moduleData[0];
            float      _max       = moduleData[1];

            // Debug.Assert(Modules[0] != null);
            if (_min > _max)
            {
                var t = _min;
                _min = _max;
                _max = t;
            }
            var v = BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(0));

            if (v < _min)
            {
                return(_min);
            }
            if (v > _max)
            {
                return(_max);
            }
            return(v);
        }
コード例 #3
0
ファイル: ScaleBias.cs プロジェクト: sunny8751/BurstLibNoise
        /// <summary>
        /// Returns the output value for the given input coordinates.
        /// </summary>
        /// <param name="x">The input coordinate on the x-axis.</param>
        /// <param name="y">The input coordinate on the y-axis.</param>
        /// <param name="z">The input coordinate on the z-axis.</param>
        /// <returns>The resulting output value.</returns>
        public static float GetBurstValue(float x, float y, float z, NativeArray <ModuleData> data, int dataIndex)
        {
            ModuleData moduleData = data[dataIndex];
            float      _scale     = moduleData[0];
            float      _bias      = moduleData[1];

            return(BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(0)) * _scale + _bias);
        }
コード例 #4
0
        /// <summary>
        /// Returns the output value for the given input coordinates.
        /// </summary>
        /// <param name="x">The input coordinate on the x-axis.</param>
        /// <param name="y">The input coordinate on the y-axis.</param>
        /// <param name="z">The input coordinate on the z-axis.</param>
        /// <returns>The resulting output value.</returns>
        public static float GetBurstValue(float x, float y, float z, NativeArray <ModuleData> data, int dataIndex)
        {
            ModuleData moduleData = data[dataIndex];
            float      _exponent  = moduleData[0];

            // Debug.Assert(Modules[0] != null);
            var v = BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(0));

            return(math.pow(math.abs((v + 1.0f) / 2.0f), _exponent) * 2.0f - 1.0f);
        }
コード例 #5
0
ファイル: Translate.cs プロジェクト: sunny8751/BurstLibNoise
        /// <summary>
        /// Returns the output value for the given input coordinates.
        /// </summary>
        /// <param name="x">The input coordinate on the x-axis.</param>
        /// <param name="y">The input coordinate on the y-axis.</param>
        /// <param name="z">The input coordinate on the z-axis.</param>
        /// <returns>The resulting output value.</returns>
        public static float GetBurstValue(float x, float y, float z, NativeArray <ModuleData> data, int dataIndex)
        {
            ModuleData moduleData = data[dataIndex];
            float      _x         = moduleData[0];
            float      _y         = moduleData[1];
            float      _z         = moduleData[2];

            // Debug.Assert(Modules[0] != null);
            return(BurstModuleManager.GetBurstValue(x + _x, y + _y, z + _z, data, moduleData.Source(0)));
        }
コード例 #6
0
        /// <summary>
        /// Returns the output value for the given input coordinates.
        /// </summary>
        /// <param name="x">The input coordinate on the x-axis.</param>
        /// <param name="y">The input coordinate on the y-axis.</param>
        /// <param name="z">The input coordinate on the z-axis.</param>
        /// <returns>The resulting output value.</returns>
        public static float GetBurstValue(float x, float y, float z, NativeArray <ModuleData> data, int dataIndex)
        {
            ModuleData moduleData = data[dataIndex];

            // Debug.Assert(Modules[0] != null);
            // Debug.Assert(Modules[1] != null);
            // Debug.Assert(Modules[2] != null);
            var a = BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(0));
            var b = BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(1));
            var c = (BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(2)) + 1.0f) / 2.0f;

            return((float)Utils.InterpolateLinear(a, b, c));
        }
コード例 #7
0
ファイル: Displace.cs プロジェクト: sunny8751/BurstLibNoise
        /// <summary>
        /// Returns the output value for the given input coordinates.
        /// </summary>
        /// <param name="x">The input coordinate on the x-axis.</param>
        /// <param name="y">The input coordinate on the y-axis.</param>
        /// <param name="z">The input coordinate on the z-axis.</param>
        /// <returns>The resulting output value.</returns>
        public static float GetBurstValue(float x, float y, float z, NativeArray <ModuleData> data, int dataIndex)
        {
            ModuleData moduleData = data[dataIndex];

            // Debug.Assert(Modules[0] != null);
            // Debug.Assert(Modules[1] != null);
            // Debug.Assert(Modules[2] != null);
            // Debug.Assert(Modules[3] != null);
            var dx = x + BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(1));
            var dy = y + BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(2));
            var dz = z + BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(3));

            return(BurstModuleManager.GetBurstValue(dx, dy, dz, data, moduleData.Source(0)));
        }
コード例 #8
0
        /// <summary>
        /// Returns the output value for the given input coordinates.
        /// </summary>
        /// <param name="x">The input coordinate on the x-axis.</param>
        /// <param name="y">The input coordinate on the y-axis.</param>
        /// <param name="z">The input coordinate on the z-axis.</param>
        /// <returns>The resulting output value.</returns>
        public static float GetBurstValue(float x, float y, float z, NativeArray <ModuleData> data, int dataIndex)
        {
            // Debug.Assert(dataIndex + 3 < data.Length);
            ModuleData moduleData = data[dataIndex];
            float      _min       = moduleData[0];
            float      _max       = moduleData[1];
            float      _fallOff   = moduleData[2];

            float cv = BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(2));

            if (_fallOff > 0.0)
            {
                float a;
                if (cv < (_min - _fallOff))
                {
                    return(BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(0)));
                }
                if (cv < (_min + _fallOff))
                {
                    var lc = (_min - _fallOff);
                    var uc = (_min + _fallOff);
                    a = (float)Utils.MapCubicSCurve((cv - lc) / (uc - lc));
                    return((float)Utils.InterpolateLinear(BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(0)),
                                                          BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(1)), a));
                }
                if (cv < (_max - _fallOff))
                {
                    return(BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(1)));
                }
                if (cv < (_max + _fallOff))
                {
                    var lc = (_max - _fallOff);
                    var uc = (_max + _fallOff);
                    a = (float)Utils.MapCubicSCurve((cv - lc) / (uc - lc));
                    return((float)Utils.InterpolateLinear(BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(1)),
                                                          BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(0)), a));
                }
                return(BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(0)));
            }
            if (cv < _min || cv > _max)
            {
                return(BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(0)));
            }
            return(BurstModuleManager.GetBurstValue(x, y, z, data, moduleData.Source(1)));
        }