示例#1
0
        // scaled periodic noise
        internal static void Compute
        (
            INoiseDataArray output,
            ComputeShader shader,
            int kernelId,
            NoiseScale scale,
            NoiseOffset offset,
            NoisePeriod period,
            int numOctaves,
            float octaveOffsetFactor
        )
        {
            InitCsId();

            Array aOutput = output.GetArray();

            int[] dimension = GetDimension(aOutput);

            ComputeBuffer outputBuffer = SetOutputBuffer(shader, kernelId, aOutput, dimension);

            shader.SetInts(s_csDimensionId, dimension);
            shader.SetFloats(s_csScaleId, scale.GetArray());
            shader.SetFloats(s_csOffsetId, offset.GetArray());
            shader.SetFloats(s_csPeriodId, period.GetArray());
            shader.SetInt(s_csNumOctavesId, numOctaves);
            shader.SetFloat(s_csOctaveOffsetFactorId, octaveOffsetFactor);

            shader.Dispatch(kernelId, dimension[0], dimension[1], dimension[2]);

            outputBuffer.GetData(aOutput, 0, 0, dimension[0] * dimension[1] * dimension[2]);
        }
示例#2
0
        // scaled periodic noise
        internal static void Compute
        (
            INoiseDataArray input,
            INoiseDataArray output,
            ComputeShader shader,
            int kernelId,
            NoiseScale scale,
            NoiseOffset offset,
            NoisePeriod period,
            int numOctaves,
            float octaveOffsetFactor
        )
        {
            InitCsId();

            Array aInput  = input.GetArray();
            Array aOutput = output.GetArray();

            ComputeBuffer outputBuffer = SetInputOutputBuffers(shader, kernelId, aInput, aOutput);

            shader.SetFloats(s_csOffsetId, offset.GetArray());
            shader.SetFloats(s_csScaleId, scale.GetArray());
            shader.SetFloats(s_csPeriodId, period.GetArray());
            shader.SetInt(s_csNumOctavesId, numOctaves);
            shader.SetFloat(s_csOctaveOffsetFactorId, octaveOffsetFactor);

            shader.Dispatch(kernelId, aInput.Length, 1, 1);

            outputBuffer.GetData(aOutput, 0, 0, aOutput.Length);
        }
示例#3
0
        //-------------------------------------------------------------------------
        // end: GPU compute / grid samples


        // GPU compute / custom samples
        //-------------------------------------------------------------------------

        public static void Compute(Vector2Array input, FloatArray output, NoiseScale scale, NoiseOffset offset, int numOctaves, float octaveOffsetFactor)
        {
            ComputeShader shader;
            int           kernelId;

            GetClassicCustom2(out shader, out kernelId);
            NoiseCommon.Compute(input, output, shader, kernelId, scale, offset, numOctaves, octaveOffsetFactor);
        }
示例#4
0
        //-------------------------------------------------------------------------
        // end: common


        // GPU compute / grid samples
        //-------------------------------------------------------------------------

        public static void Compute(FloatArray output, NoiseScale scale, NoiseOffset offset, int numOctaves, float octaveOffsetFactor)
        {
            ComputeShader shader;
            int           kernelId;

            GetClassicGrid2(out shader, out kernelId);
            NoiseCommon.Compute(output, shader, kernelId, scale.GetArray(), offset, numOctaves, octaveOffsetFactor);
        }
示例#5
0
        public static void Compute(Vector3Array output, NoiseScale scale, NoiseOffset offset, int numOctaves, float octaveOffsetFactor)
        {
            ComputeShader shader;
            int           kernelId;

            GetSimplexGradientGrid3(out shader, out kernelId);
            NoiseCommon.Compute(output, shader, kernelId, scale, offset, numOctaves, octaveOffsetFactor);
        }