mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 18:40:46 +00:00
create PositiveWhiteNoiseSampler
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (c) 2020-2021 Polyhedral Development
|
||||
*
|
||||
* The Terra Core Addons are licensed under the terms of the MIT License. For more details,
|
||||
* reference the LICENSE file in this module's root directory.
|
||||
*/
|
||||
|
||||
package com.dfsek.terra.addons.noise.samplers.noise.random;
|
||||
|
||||
import com.dfsek.terra.addons.noise.samplers.noise.NoiseFunction;
|
||||
|
||||
|
||||
/**
|
||||
* NoiseSampler implementation to produce random, uniformly distributed (white) noise.
|
||||
*/
|
||||
public class PositiveWhiteNoiseSampler extends WhiteNoiseSampler {
|
||||
private static final long POSITIVE_POW1 = 0b01111111111L << 52;
|
||||
// Bits that when applied to the exponent/sign section of a double, produce a positive number with a power of 1.
|
||||
|
||||
public double getNoiseRaw(long seed) {
|
||||
return (Double.longBitsToDouble((murmur64(seed) & 0x000fffffffffffffL) | POSITIVE_POW1) - 1.5) * 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseRaw(long seed, double x, double y) {
|
||||
return (getNoiseUnmapped(seed, x, y) - 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNoiseRaw(long seed, double x, double y, double z) {
|
||||
return (getNoiseUnmapped(seed, x, y, z) - 1);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user