// 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]); }
// 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); }
//------------------------------------------------------------------------- // end: common // GPU compute / grid samples //------------------------------------------------------------------------- // scale-agnostic noise internal static void Compute ( INoiseDataArray output, ComputeShader shader, int kernelId, float seed ) { InitCsId(); Array aOutput = output.GetArray(); int[] dimension = GetDimension(aOutput); ComputeBuffer outputBuffer = SetOutputBuffer(shader, kernelId, aOutput, dimension); seed = JumbleSeed(seed); shader.SetFloat(s_csSeedId, seed); shader.SetInts(s_csDimensionId, dimension); shader.Dispatch(kernelId, dimension[0], dimension[1], dimension[2]); outputBuffer.GetData(aOutput, 0, 0, dimension[0] * dimension[1] * dimension[2]); }