3D procedural textures are actually 3D!
Have you ever thought that you actually can display a 3D procedural (such as Noise, Cellular etc…) in the 3D space? No? Well, then know that it is possible and it’s nothing difficult. Well, the most difficult part will be what should actually represent the color values. The representation is up to you, but for my experiment, I chose simple point helpers (nulls) of a very small size so that they looked almost like points (vertices would have done as well).
Take a look at this short video capturing the result of modeling a noise procedural:
My approach used a very simple way of “sampling” points in space and testing, whether the noise texture in that particular point has a value higher or equal to 0.5 (again, you can choose whatever number you like, the range is from -1 to 1 for noise textures, I only scaled the resulting value to a 0 – 1 range, so 0.5 represents a value of 0.0). I chose a cubic volume (a box) in which I sampled 125 000 points and tested every one of them whether they lie in a color value higher than 0.5. The result yielded 67 632 actual TRUE values, which means that the algorythm created 67 632 point helpers in the exact spot where the color value of the noise function was higher than 0.0 (remember, I scaled the noise, so the test value was 0.5!). The final result can be seen in the short video above.
Now, how did I go about it. Firstly note that I wrote this algo. in about 1 minute
so it’s nowhere near being optimized or “clean”, but it was so simple to write I sticked with it, besides it worked, so, for the sake of the experiment, I didn’t bother investing more time into optimizing it etc… The basic idea is to sample a point in three axis in a given volume. The volume was specified by the box I created at the begining. I simply used it’s .min and .max properties to get the exact bounding box of the object (at first I wanted to try to sample points in a sphere, but then I ditched the idea as writing the actual sphere volume in a script would delay me too much from the experiment I wanted to perform) and then three loops to go through all the values in each of the axis in the volume by a certain increment (remember, you cannot calculate infinite formulas
). Here’s the script that did all the work for me:
step = 2
volume = $Box01
for i = volume.min.x to volume.max.x by step do
(
for j = volume.min.y to volume.max.y by step do
(
for k = volume.min.z to volume.max.z by step do
(
if noiseVal = 0.5*(1.0+(fractalNoise [i/20., j/20., k/20.] 0.5 2.0 5.0)) >= 0.5 do
(
pt = point size:1.0 centerMarker:false axisTripod:false cross:false box:true constantScreenSize:true drawOnTop:false wireColor:white
pt.pos = [i, j, k]
)
)
)
)
I told you it was simple!
The for loops go through the individual directions in the tripod-axis and stop each 2 units in that direction (in this case, the variable step controls this sampling) and tests whether the noise color value is greater than 0.5 then it continues on with the next point and so on and so forth. Each time it hits a value greater or equal to 0.5 it creates a point helper. That’s it, that’s all it does.
Obviously, this could be pushed much much farther, for example, you could actually model a geometrical object based on these values, but, quite frankly, I don’t think I’d be able to code that as that’d require some really complex algorythms to just generate the mesh from vertices it creates. But it’d be interesting to see what the actual mesh would look like as the points look a bit chaotic and blend together, visually.