mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
NoiseSampler.scaled: the noise with an extra coordinate scale, folded into the host's generator
This commit is contained in:
1 parent
904a6599b3
commit
44c98dcd8b
3 files changed
+49
No files matched your search
@@ -23,4 +23,34 @@ public interface NoiseSampler {
|
||||
default double signed(double worldX, double y, double worldZ) {
|
||||
return sample(worldX, y, worldZ) * 2D - 1D;
|
||||
}
|
||||
|
||||
/** This noise with its coordinates multiplied by {@code factor}: a factor above 1 squeezes the pattern, below 1
|
||||
* stretches it. A host folds the factor into the generator's own scale, so the result is the very noise the style
|
||||
* would give with that extra scale (same values and float rounding), and builds it without touching this sampler.
|
||||
* The default multiplies the coordinates before sampling, which may round differently.
|
||||
*/
|
||||
default NoiseSampler scaled(double factor) {
|
||||
NoiseSampler source = this;
|
||||
return new NoiseSampler() {
|
||||
@Override
|
||||
public double sample(double worldX, double worldZ) {
|
||||
return source.sample(worldX * factor, worldZ * factor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double sample(double worldX, double y, double worldZ) {
|
||||
return source.sample(worldX * factor, y * factor, worldZ * factor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double signed(double worldX, double worldZ) {
|
||||
return source.signed(worldX * factor, worldZ * factor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double signed(double worldX, double y, double worldZ) {
|
||||
return source.signed(worldX * factor, y * factor, worldZ * factor);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user