public void Execute(int i) { if (double.IsNegativeInfinity(Heights[i]) == false) { Heights[i] += SgtTerrainTopology.Sample_Cubic_Equirectangular(Data, Stride, Offset, Size, Points[i]) * Displacement; } }
public void Execute(int i) { if (double.IsNegativeInfinity(Heights[i]) == false) { var weight = 1.0f; if (AreaWeights.Length > 0) { weight = SgtTerrainTopology.Sample_Cubic_Equirectangular(AreaWeights, AreaSplatCount, Area, AreaSize, Points[i]); weight = math.clamp(20000.0f - weight, 0.0f, 20000.0f) / 20000.0f; } if (weight > 0.0f) { Heights[i] -= FBM(Points[i] * Frequency, Amplitude) * weight; } } }
private void Schedule(Chunk chunk) { var rng = (double)noise.snoise((float3)chunk.PointC); chunk.Clones = new List <GameObject>(); var jobArea = default(int); var jobAreaSize = default(int2); var jobAreaSplatCount = default(int); var jobAreaWeights = default(NativeArray <float>); if (cachedTerrain.Areas != null && cachedTerrain.Areas.SplatCount > 0) { jobArea = math.clamp(area, 0, cachedTerrain.Areas.SplatCount - 1); jobAreaSize = cachedTerrain.Areas.Size; jobAreaSplatCount = cachedTerrain.Areas.SplatCount; jobAreaWeights = cachedTerrain.Areas.Weights; } else { jobArea = 0; jobAreaSize = int2.zero; jobAreaSplatCount = 0; jobAreaWeights = tempWeights; } for (var i = 0; i < limit; i++) { var u = (float)(math.abs(rng * 6829.0) % 1.0); var v = (float)(math.abs(rng * 7351.0) % 1.0); var point = chunk.PointC + chunk.PointH * u + chunk.PointV * v; var weight = 1.0f; if (jobAreaWeights.Length > 0) { weight = SgtTerrainTopology.Sample_Cubic_Equirectangular(jobAreaWeights, jobAreaSplatCount, jobArea, jobAreaSize, point); if (weight > 0.0f) { weight = math.sqrt(weight) / 255.0f; } weight = math.saturate(1.0f - weight); weight = Mathf.InverseLerp(threshold, 1.0f, weight); } var sample = (float)(math.abs(rng * 4334.94437) % 1.0); if (sample > weight) { break; } var clone = Spawn(point, chunk.PointH * 0.01, chunk.PointV * 0.01, sample); chunk.Clones.Add(clone.gameObject); rng *= 3.12345; } }