public NoiseGenerator(int seed, float frequency) { _hash1 = new XXHash(seed); _hash2 = new XXHash(seed ^ 0x1327495a); _hash3 = new XXHash(seed ^ 0x3cbe84f2); _fractal = 2; _frequency = frequency; _time = 0; }
public static float2 Float2(float3 v, uint seed) { var hash = new XXHash(seed); return(math.float2( noise.snoise(v + hash.Float3(-1000, 1000, 1)), noise.snoise(v + hash.Float3(-1000, 1000, 2)) )); }
public NoiseGenerator(float frequency) { _hash1 = XXHash.RandomHash; _hash2 = XXHash.RandomHash; _hash3 = XXHash.RandomHash; _fractal = 2; _frequency = frequency; _time = 0; }
public static float2 Float2Fbm(float3 v, int octave, uint seed) { var hash = new XXHash(seed); return(math.float2( Fbm(v + hash.Float3(-1000, 1000, 1), octave), Fbm(v + hash.Float3(-1000, 1000, 2), octave) )); }
public static quaternion Rotation(float2 v, float3 angles, uint seed) { var hash = new XXHash(seed); angles *= math.float3( noise.snoise(v + hash.Float2(-1000, 1000, 1)), noise.snoise(v + hash.Float2(-1000, 1000, 2)), noise.snoise(v + hash.Float2(-1000, 1000, 3)) ); return(quaternion.EulerZXY(angles)); }
public static quaternion RotationFbm (float3 v, int octave, float3 angles, uint seed) { var hash = new XXHash(seed); angles *= math.float3( Fbm(v + hash.Float3(-1000, 1000, 1), octave), Fbm(v + hash.Float3(-1000, 1000, 2), octave), Fbm(v + hash.Float3(-1000, 1000, 3), octave) ); return(quaternion.EulerZXY(angles)); }
// Token: 0x06002E44 RID: 11844 RVA: 0x000E2650 File Offset: 0x000E0A50 public static uint GetHash(int data, int seed) { uint num = (uint)(seed + 374761393); num += 4u; num += (uint)(data * -1028477379); num = XXHash.rotl32(num, 17) * 668265263u; num ^= num >> 15; num *= 2246822519u; num ^= num >> 13; num *= 3266489917u; return(num ^ num >> 16); }
void Update() { var hash = new XXHash(_randomSeed + 100); var t = Time.time; for (var i = 0u; i < _instanceCount; i++) { var p = _bars[i].transform.localPosition; var spd = (hash.Float(i) + 0.5f) * _speed; p.x = ((spd * t) % _width) - _width * 0.5f; _bars[i].transform.localPosition = p; } }
void Start() { _bars = new GameObject[_instanceCount]; var hash = new XXHash(_randomSeed); for (var i = 0u; i < _instanceCount; i++) { var seed = i * 2; var y = (hash.Float(seed) - 0.5f) * _height; var hue = hash.Float(seed + 1); var go = Instantiate(_prefab, transform); go.transform.localPosition = new Vector3(0, y, 0); go.GetComponent <Light>().color = Color.HSVToRGB(hue, 0.8f, 1); _bars[i] = go; } }
void OnEnable() { var shader = Shader.Find("SpherePoints"); _material = new Material(shader); _material.hideFlags = HideFlags.DontSave; var hash = new Klak.Math.XXHash(123); var va = new List <Vector3>(); var ia = new List <int>(); for (var i = 0; i < _pointCount; i++) { var rand1 = hash.Value01(i * 2); var rand2 = hash.Value01(i * 2 + 1); var vi = va.Count; va.Add(new Vector3(rand1, rand2, 0)); va.Add(new Vector3(rand1, rand2, 1)); va.Add(new Vector3(rand1, rand2, 2)); va.Add(new Vector3(rand1, rand2, 3)); ia.Add(vi); ia.Add(vi + 1); ia.Add(vi + 2); ia.Add(vi + 1); ia.Add(vi + 3); ia.Add(vi + 2); } _mesh = new Mesh(); _mesh.name = "Points"; _mesh.hideFlags = HideFlags.DontSave; _mesh.vertices = va.ToArray(); _mesh.SetIndices(ia.ToArray(), MeshTopology.Triangles, 0); _mesh.bounds = new Bounds(Vector3.zero, Vector3.one); _mesh.UploadMeshData(true); }
// Token: 0x06002E46 RID: 11846 RVA: 0x000E26C6 File Offset: 0x000E0AC6 public uint GetHash(int data) { return(XXHash.GetHash(data, this.seed)); }
void BuildMesh() { _vbuffer.Clear(); _ibuffer.Clear(); _uv.Clear(); var hash = new Klak.Math.XXHash(1000); for (var i = 0; i < _triangleCount; i++) { var seed = (_randomSeed + Mathf.FloorToInt(i * 0.1f + _time)) * 10000; var i1 = i * 3; var i2 = i1 + 1; var i3 = i2 + 1; var v1 = RandomPoint(hash, i1 + seed); var v2 = RandomPoint(hash, i2 + seed); var v3 = RandomPoint(hash, i3 + seed); v2 = (v1 + (v2 - v1).normalized * _triangleExtent).normalized; v3 = (v1 + (v3 - v1).normalized * _triangleExtent).normalized; var l1 = Perlin.Noise(v1 * _noiseFrequency + _noiseOffset); var l2 = Perlin.Noise(v2 * _noiseFrequency + _noiseOffset); var l3 = Perlin.Noise(v3 * _noiseFrequency + _noiseOffset); l1 = Mathf.Abs(l1 * l1 * l1); l2 = Mathf.Abs(l2 * l2 * l2); l3 = Mathf.Abs(l3 * l3 * l3); v1 *= 1 + l1 * _noiseAmplitude; v2 *= 1 + l2 * _noiseAmplitude; v3 *= 1 + l3 * _noiseAmplitude; _vbuffer.Add(v1); _vbuffer.Add(v2); _vbuffer.Add(v3); _uv.Add(Vector2.zero); _uv.Add(Vector2.zero); _uv.Add(Vector2.zero); _ibuffer.Add(i1); _ibuffer.Add(i2); _ibuffer.Add(i3); } _mesh = new Mesh(); _mesh.hideFlags = HideFlags.DontSave; _mesh.SetVertices(_vbuffer); _mesh.SetUVs(0, _uv); _mesh.SetTriangles(_ibuffer, 0); _mesh.RecalculateNormals(); _vbuffer.Clear(); _ibuffer.Clear(); _renderer = TempRenderer.Allocate(); _renderer.mesh = _mesh; _renderer.material = _material; }