void SetShadingNoise() { const string biomeWarpNoiseSuffix = "_biomeWarp"; const string detailWarpNoiseSuffix = "_detailWarp"; const string detailNoiseSuffix = "_detail"; PRNG prng = new PRNG(seed); PRNG prng2 = new PRNG(seed); if (randomize) { // warp 1 var randomizedBiomeWarpNoise = new SimpleNoiseSettings(); randomizedBiomeWarpNoise.elevation = prng.Range(0.8f, 3f); randomizedBiomeWarpNoise.scale = prng.Range(1f, 3f); randomizedBiomeWarpNoise.SetComputeValues(shadingDataCompute, prng2, biomeWarpNoiseSuffix); // warp 2 var randomizedDetailWarpNoise = new SimpleNoiseSettings(); randomizedDetailWarpNoise.scale = prng.Range(1f, 3f); randomizedDetailWarpNoise.elevation = prng.Range(1f, 5f); randomizedDetailWarpNoise.SetComputeValues(shadingDataCompute, prng2, detailWarpNoiseSuffix); detailNoise.SetComputeValues(shadingDataCompute, prng2, detailNoiseSuffix); } else { biomeWarpNoise.SetComputeValues(shadingDataCompute, prng2, biomeWarpNoiseSuffix); detailWarpNoise.SetComputeValues(shadingDataCompute, prng2, detailWarpNoiseSuffix); detailNoise.SetComputeValues(shadingDataCompute, prng2, detailNoiseSuffix); } }
protected override void Run() { var prng = new PRNG(seed); var offset = new Vector4(prng.Value(), prng.Value(), prng.Value(), prng.Value()) * 10; ComputeHelper.CreateStructuredBuffer <int> (ref minMaxBuffer, 2); minMaxBuffer.SetData(new int[] { int.MaxValue, 0 }); compute.SetBuffer(0, "minMax", minMaxBuffer); compute.SetBuffer(1, "minMax", minMaxBuffer); int threadGroupSize = ComputeHelper.GetThreadGroupSizes(compute, 0).x; int numThreadGroups = Mathf.CeilToInt((float)textureSize / threadGroupSize); compute.SetVector("offset", offset); compute.SetTexture(0, "Result", renderTexture); noiseSettings.SetComputeValues(compute, prng, "_simple"); warpNoiseSettings.SetComputeValues(compute, prng, "_warp"); compute.SetInt("resolution", (int)textureSize); compute.SetFloat("valueFloor", valueFloor); compute.Dispatch(0, numThreadGroups, numThreadGroups, 1); // Normalize if (normalize) { compute.SetTexture(1, "Result", renderTexture); compute.Dispatch(1, numThreadGroups, numThreadGroups, 1); } ComputeHelper.Release(minMaxBuffer); }
void SetShapeNoiseSettings(PRNG prng, bool randomizeValues) { const string suffix = "_shape"; if (randomizeValues) { var chance = new Chance(prng); SimpleNoiseSettings randomizedShapeNoise = new SimpleNoiseSettings() { numLayers = 4, lacunarity = 2, persistence = 0.5f }; if (chance.Percent(80)) // Minor deformation { randomizedShapeNoise.elevation = Mathf.Lerp(0.2f, 3, prng.ValueBiasLower(0.3f)); randomizedShapeNoise.scale = prng.Range(1.5f, 2.5f); } else if (chance.Percent(20)) // Major deformation { randomizedShapeNoise.elevation = Mathf.Lerp(3, 8, prng.ValueBiasLower(0.4f)); randomizedShapeNoise.scale = prng.Range(0.3f, 1); } // Assign settings randomizedShapeNoise.SetComputeValues(heightMapCompute, prng, suffix); } else { shapeNoise.SetComputeValues(heightMapCompute, prng, suffix); } }
protected override void SetShapeData() { var prng = new PRNG(seed); continentNoise.SetComputeValues(heightMapCompute, prng, "_continents"); ridgeNoise.SetComputeValues(heightMapCompute, prng, "_mountains"); ridgeNoise2.SetComputeValues(heightMapCompute, prng, "_mountains2"); warpNoise.SetComputeValues(heightMapCompute, prng, "_warp"); craterSettings.SetComputeValues(heightMapCompute, seed); heightMapCompute.SetFloat("plateauHeight", plateauHeight); heightMapCompute.SetFloat("plateauSmoothing", plateauSmoothing); heightMapCompute.SetVector("params", testParams); }
protected override void SetShapeData() { var prng = new PRNG(seed); continentNoise.SetComputeValues(heightMapCompute, prng, "_continents"); craterSettings.SetComputeValues(heightMapCompute, seed); heightMapCompute.SetFloat("shoreSteepness", shoreSteepness); heightMapCompute.SetFloat("continentFlatness", continentFlatness); heightMapCompute.SetFloat("continentLevel", continentLevel); heightMapCompute.SetFloat("mountainSmoothing", mountainSmoothing); heightMapCompute.SetFloat("mountainBlend", mountainBlend); heightMapCompute.SetVector("maskMinMax", maskMinMax); heightMapCompute.SetVector("params", testParams); }
protected override void SetShapeData() { var prng = new PRNG(seed); continentNoise.SetComputeValues(heightMapCompute, prng, "_continents"); ridgeNoise.SetComputeValues(heightMapCompute, prng, "_mountains"); maskNoise.SetComputeValues(heightMapCompute, prng, "_mask"); heightMapCompute.SetFloat("oceanDepthMultiplier", oceanDepthMultiplier); heightMapCompute.SetFloat("oceanFloorDepth", oceanFloorDepth); heightMapCompute.SetFloat("oceanFloorSmoothing", oceanFloorSmoothing); heightMapCompute.SetFloat("mountainBlend", mountainBlend); heightMapCompute.SetVector("params", testParams); // }
void SetRidgeNoiseSettings(PRNG prng, bool randomizeValues) { const string ridgeSuffix = "_ridge"; const string detailSuffix = "_ridge2"; if (randomizeValues) { // Randomize ridge mask var randomizedMaskNoise = new SimpleNoiseSettings() { numLayers = 4, lacunarity = 2, persistence = 0.6f, elevation = 1 }; randomizedMaskNoise.scale = prng.Range(0.5f, 2f); // Randomize ridge noise var chance = new Chance(prng); var randomizedRidgeNoise = new RidgeNoiseSettings() { numLayers = 4, power = 3, gain = 1, peakSmoothing = 2 }; randomizedRidgeNoise.elevation = Mathf.Lerp(1, 7, prng.ValueBiasLower(0.3f)); randomizedRidgeNoise.scale = prng.Range(1f, 3f); randomizedRidgeNoise.lacunarity = prng.Range(1f, 5f); randomizedRidgeNoise.persistence = 0.42f; randomizedRidgeNoise.power = prng.Range(1.5f, 3.5f); randomizedRidgeNoise.SetComputeValues(heightMapCompute, prng, ridgeSuffix); randomizedMaskNoise.SetComputeValues(heightMapCompute, prng, detailSuffix); } else { ridgeNoise.SetComputeValues(heightMapCompute, prng, ridgeSuffix); ridgeNoise2.SetComputeValues(heightMapCompute, prng, detailSuffix); } }