2 ms·
This (edit: the first one) works way better than I expected! Your h1 and h2 are always the same since hash is deterministic when I assume you want them to be d
by gpm 9y ago
This (edit: the first one) works way better than I expected!
Your h1 and h2 are always the same since hash is deterministic when I assume you want them to be distinct, and they're in the range [-1, 1] instead of [0.5, -0.5] which I think makes more sense. I'm also not sure why you made r instead of just hashing fragCoord directly?
I also think adding time to the hash makes it look better, though if you stand still it's somewhat nauseating (switch all time variables in getColor to 0.0). Anyways I ended up with the following which I think looks great :)
float h1 = (hash(time + fragCoord.x) + hash(time + fragCoord.y)) / 4.0;
float h2 = (hash(time - fragCoord.x) + hash(time -fragCoord.y)) / 4.0;
- entropicdrifter 9y agoHash is pseudorandom. It amplifies the rounding error of the sine function, as explained here: https://stackoverflow.com/a/4275343 https://stackoverflow.com/a/4275343 The reason I didn't use fragCoord was because I wasn't sure it would be within range, though thinking about it, I can't really see why it wouldn't be since before the engine was using it directly (d'oh). Anyways I did the mod 9 and divide by 10 to ensure it was in the range of [0, 0.8999999...]. The idea there was I got initial the impression (though I didn't really dig) that the hash function generates a point between x and y of the vector. Reviewing, it seems this was a silly notion. I think you're right, now that I'm looking at it again. Your way of getting h1 and h2 is much more efficient.