You are using java.util.Random
to generate your texture. Nothing is really random in computers, of course. The standard Java library uses the classic linear congruential pseudorandom number generator, which is fast and good for most purposes, but is still considered weak for serious stuff. By "weak" I means it can be predictable and exhibits "non-randomness" when used intensively. This is possibly the source of the patterns that you see here.
Another possible source of problem is that you are first generating an array of random seeds. But if you look at the implementation of Random.next()
in java.util
:
protected int next(int bits) {
long oldseed, nextseed;
AtomicLong seed = this.seed;
do {
oldseed = seed.get();
nextseed = (oldseed * multiplier + addend) & mask;
} while (!seed.compareAndSet(oldseed, nextseed));
return (int)(nextseed >>> (48 - bits));
}
you see that the process of Random is to generate a new seed and return a value based on a simple calculation on that seed. I don't have the mathematical background to be sure of that, but maybe this technique would produce a list of seeds that would produce similar pseudo-random sequences when you use them afterwards because they are dependent on each other in some way, having been produced by the same random generator, and would also generate patterns.
What you can try: use a better pseudo-random generator. You can use java.security.SecureRandom
, which is "cryptographically strong", so it should be good enough for your usage. Unfortunately, it is not as fast as java.util.Random
. But you can at least give it a try and see if you find the same patterns. If not, then the random generator was bad; if you still find patterns, then most probably it is coming from your algorithm.
If I am right to say that the pseudo-random generator is not random enough, and if SecureRandom
is too slow for you, you can find online an implementation of the "Mersenne Twister" algorithm, which is fast and better than the linear congruential method.