void Start() { var hash = new XXHash(_randomSeed); var mat = new MaterialOverride(_randomSeed); var parent = transform; var rot = quaternion.identity; // Column - Row - Depth for (var col = 0u; col < _extent.x; col++) { for (var row = 0u; row < _extent.y; row++) { // Per-strip parameters var seed = hash.UInt(col) + hash.UInt(row); mat.SetParameters(seed + 500); for (var depth = 0u; depth < _extent.z; depth++) { // Random removal if (hash.Float(seed + depth) < _removalRate) { continue; } // Instance position var p = math.float3(col, row, depth); p.xy = p.xy - _extent.xy / 2 + math.float2(0, 0.5f); // Instantiation and material overriding mat.Apply(Instantiate(_prefab, p, rot, parent)); } } } }
void Start() { var hash = new XXHash(_randomSeed); var mat = new MaterialOverride(_randomSeed); var parent = transform; // Column - Row - Edge x3 - Depth for (var col = 0u; col < _extent.x; col++) { for (var row = 0u; row < _extent.y; row++) { // Tube origin var org = math.float2(col, row) - _extent.xy / 2; org.x += (row & 1) * 0.5f; org *= math.float2(3, 0.87f); for (var i = 0u; i < 3u; i++) { // Per-strip random seed var seed = hash.UInt(col) + hash.UInt(row) + i; // Per-strip random material properties mat.SetParameters(seed + 500); // Rotation var phi = (i - 1.0f) * math.PI / 3; var rot = quaternion.RotateZ(phi); // Position var pos = math.mul(rot, math.float3(0, 0.87f, 0)); pos.xy += org; for (var depth = 0u; depth < _extent.z; depth++) { // Random removal if (hash.Float(seed + depth) < _removalRate) { continue; } // Instantiation and material overriding pos.z = depth; mat.Apply(Instantiate(_prefab, pos, rot, parent)); } } } } }