Exemplo n.º 1
0
    // TODO: change to be a "multiplier" for cave intensity
    public NoiseSample3 Abyss(float3 pos)
    {
        var abyssX = new NoiseSample3 {
            val = pos.x, gradient = float3(1, 0, 0)
        };
        var abyssZ = new NoiseSample3 {
            val = pos.z, gradient = float3(0, 0, 1)
        };

        const float radius = 555;

        var strength = fsnoise(pos.y + 999, radius * 6, 2);

        var offsX = fsnoise(pos.y + 10000, radius * 2, 3) * radius * (0.6f + strength * 0.5f);
        var offsZ = fsnoise(pos.y - 10000, radius * 2, 3) * radius * (0.6f + strength * 0.5f);

        abyssX.val        += offsX.val;
        abyssX.gradient.y += offsX.gradient;

        abyssZ.val        += offsZ.val;
        abyssZ.gradient.y += offsZ.gradient;

        var radiusSample = new NoiseSample3 {
            val = 555, gradient = 0
        };

        var radiusScale = 1f + fsnoise(pos.y + 20000, radius * 4, 3) * 0.7f;

        radiusSample *= new NoiseSample3 {
            val = radiusScale.val, gradient = float3(0, radiusScale.gradient, 0)
        };

        return((radiusSample - sqrt(abyssX * abyssX + abyssZ * abyssZ)) / radiusSample);
    }
Exemplo n.º 2
0
    public static NoiseSample3 snoise(float3 pos, float3 invFreq, int seed = 0)
    {
        var sampl = new NoiseSample3();

        sampl.val       = noise.snoise(pos * invFreq + float3(_fixBugX, _fixBugY, _fixBugZ + (float)seed), out sampl.gradient);
        sampl.gradient *= invFreq;
        return(sampl);
    }
Exemplo n.º 3
0
 public static NoiseSample3 max(NoiseSample3 l, NoiseSample3 r)
 {
     l.gradient = select(r.gradient, l.gradient, l.val >= r.val);
     l.val      = math.max(l.val, r.val);
     return(l);
 }
Exemplo n.º 4
0
 public static NoiseSample3 sqrt(NoiseSample3 x)
 {
     x.val      = math.sqrt(x.val);
     x.gradient = 0.5f / x.val * x.gradient;
     return(x);
 }