// 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); }
// 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]); }
//------------------------------------------------------------------------- // 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); }