Exemple #1
0
 private void LerpFunc(PaintJob j, int idx, ref object val, float r)
 {
     if (didHit)
     {
         j.stream.normals[idx]  = Vector3.Lerp(j.stream.normals[idx], normal, r);
         j.stream.tangents[idx] = Vector4.Lerp(j.stream.tangents[idx], tangent, r);
     }
 }
        private void LerpFunc(PaintJob j, int idx, ref object val, float r)
        {
            BrushData bd  = val as BrushData;
            var       s   = j.stream;
            Vector3   pos = j.GetPosition(idx);

            pos    = j.renderer.localToWorldMatrix.MultiplyPoint(pos);
            pos.x *= bd.frequency;
            pos.y *= bd.frequency;
            pos.z *= bd.frequency;
            float noise = 0.5f * (0.5f * SimplexNoise.Noise.Generate(pos.x, pos.y, pos.z) + 0.5f);

            noise += 0.25f * (0.5f * SimplexNoise.Noise.Generate(pos.y * 2.031f, pos.z * 2.031f, pos.x * 2.031f) + 0.5f);
            noise += 0.25f * (0.5f * SimplexNoise.Noise.Generate(pos.z * 4.01f, pos.x * 4.01f, pos.y * 4.01f) + 0.5f);
            noise *= bd.amplitude;
            // lerp the noise in
            Color c = s.colors[idx];

            c.r = Mathf.Lerp(c.r, noise, r);
            c.g = Mathf.Lerp(c.g, noise, r);
            c.b = Mathf.Lerp(c.b, noise, r);

            s.colors[idx] = c;
        }