Does anyone understand the theory behind this noise randomizer problem?


I’m trying to use a random noise texture to randomize cells in a shader, the shader stuff I understand, what I don’t understand is why it’s impossible to make a randomized noise texture!

If I use the Noise filter in Photoshop, the results are just absolutely terrible (it might look noisy, but the actual noise is poorly randomized),

So eventually I found a website that creates really good noise, that average at 128 whenever I use “blur Average”,
However even tho this one is more balanced, I find that mid-range values (those near 128) are WAY more common than high and low values, I was able to confirm this by checkign the Levels filter in Photoshop, notice it shows that the midrange valeus are more common because of how the levels thingy is a steep mountain.

Is it something I’m missunderstanding? (about color profiles? gamma? randomization techniques etc), Why is it impossible to make a noise texture where each pixel is randomized between 0-1 without greatly favoring certain color ranges?


If 8 bit color depth is okay, paste this

 void setup() {
void draw() {
      point(x, y);
       stroke(random(255), random(255), random(255));

then press play button, then stop, then export to png


Thanks so much, but strangely enough this has the EXACT same problem! (even tho we can see the code in plain view)

Notice in this picture from that code, that the histogram shows that midvalues are way more common than dark and light colors.

now you could think maybe it’s just photoshops histogram that is broken, so I made a test,
I set the treshold to 64, meaning that I should see 25% of pixels, yet when I manually count 8x8 pixels = 64 I get only 8 black pixels, meaning that treshold of 64 only got 12.5% pixels, half what I expected!

So weird right!


The histogram that you see in Photoshop’s Levels filter is the wrong tool to use for measuring how random your texture is. The steep mountain that you see matches the bell curve visualization of probability that a pixel will have a certain value.

From what you’ve been saying, you seem to be expecting a flat rectanglar-shaped histogram in the Levels filter since truly random textures should have equal probability of values, right? Well, that would be only half-correct. Each pixel does have an equal probability, but statistically, most of the pixels will fall into the midrange. So no matter what random noise texture you throw into the Photoshop Levels filter, you’ll get a variation of that steep mountain.

So, to measure how random your texture is, you need to use a different tool. For most cases, the human eye is good enough. If you can’t spot any pattern in the noise, then the texture is random enough for most purposes.


Weird indeed. I opened that image in Photoshop. Window->Histogram showed a flat distribution as you would expect. Let me check again. Maybe that levels panel is something else, the panel was labeled histogram when I checked, not levels (latest photoshop version)


Ok the secret sauce was “cache level”. Photoshop uses a scaled down version of the image to quickly compute the histogram.

Scaling down averages the pixels which results in that bell curve we see. When you click the warning icon cache level 0 (unscaled) is activated temporarily and the flat histogram is shown.