Camouflage

This week, filler Wednesday is actually a warm-up for a post for next week. It just seemed weird to write a post about the evolution of a concept that had not even been introduced. Thus, this is pretty basic.


This is camouflage, as popularised by military dudes wanting to turn invisible. It is also just several layers of Perlin noise stacked on top of each other.

For each layer of noise, a binary condition is tested: Either the layer is opaque, or the algorithm moves on to the next layer. This is the test:

if (noise(x,y) > .6) {setColorToDraw1} else
if (noise(x,y) > .59) {setColorToDraw2} else
...

Depending on how far the algorithm goes before it finds a test which returns true, the colour can be light green, leaf green, sandy, brown or grey. If no tests return true, a background colour of dark pine is used.

Each noise layer has slightly different conditions, or in short, slightly different scales. Some are more high-frequency than others. I don't think there's much rhyme or reason, just a slight attempt at making the shapes different from each-other.

I think the most important note is that there is a hierarchy, and one needs to adjust for that. If all layers had the same chance of returning true, the "front" colour would be seen most often. Instead, the first layers have higher chance of being transparent, to accomodate for this. Thus the final camouflage pattern has an almost equal mix of colours.

Demonstration and code can be found on Open Processing.

Comments