Rectangular Noise

Started by Hetzen, March 09, 2010, 11:28:51 AM

Previous topic - Next topic

Hetzen

Here's a challengs, I've been struggling recently to try and create angular flat rock type textures with PFs and/or Voronoi. The problem I've had, has been creating random levelled steps, without spikes. So I tried a new approach, by creating a new noise type through the functions. I've borrowed Goms' direction shader network to define whether x or z noise is applied depending on which direction the surface normal is facing. (thanks Goms, I think there's a whole lot more exploitation possibilities with that little node gem).

At the moment I have control over Step Size, Angle Between Steps, Noise Scale, and Noise Seed on each of the three axis. It's just a proof of concept for now. The idea will be to modulate these settings, so that each 'square' shape will be more random, and by changing the bias of the steps, the extrusions will be more interesting and unique. Well that's the theory.

Anyone else have any ideas on how to create more rectangular noise?

dandelO

For a basic square/rectangular noise function I've used extreme stretching of a close-scaled fractal(say scales of 10,10 and 10), duplicate the node and have one stretched, say, X = '100' and the duplicate, X = '-100'. Do this on the Z axis as well with another copy of these nodes and the colour outputs can be merged.

Because they're fractal, though, it's somewhat random. I don't know how to go about repeating an exact pattern this way. ???

http://forums.planetside.co.uk/index.php?topic=6149.msg64869#msg64869
I used displacement in this, too. A colour output on its own could be used as a mask, though.

EDIT: Actually, you've commented there before, sorry. :D

Hetzen

#2
Yeah that was a while back. Interesting little exercise that, although I've tried using clamped stretched noise, and I guess it's still a possibility, but one of the issues I was having, was the 'equalness' of the steps. Ie, if you layer up some stretched noise, say 4, your resulting extrussion will have four steps in it. If you start using difference subtraction, you then start getting a lot of spikes. There maybe a happy medium out there, but I thought it might be interesting doing it in blues. Although saying that, I'm only just managing to stop my brain from ouzing out of my ears from abstract math at the moment.

This is where I'm trying to go with this...




choronr

Looking, absorbing and learning ...great stuff you guys.

mogn

I know tha dandelO has worked a lot with this problem.
Her is my solution (using a perlin noise):

Tangled-Universe

Hi Jon,

A couple of weeks ago (feb 15th) you sent/showed me a very nice example of this technique when you had this slightly more PF-based rather than function-based.

I don't know if you would like it if I show that image here, but I hope you remember which one I mean: in that image you already had much of the effect you tried to achieve. Sqaured looking fractals, quite like in your reference and also with variation in level steps.

I was just wondering if you lost this setup or deviated too much from it in the meantime? It looked really good!

Martin

Hetzen

@mogn, your approach is actualy quite simillar to mine, but I didn't use the smooth step node, quite simply because I'm not entirely sure what it does. But the main addition I made was sampling whether the previous modulo loop was higher or lower than the current modulo loop, so that I could define an up or down ramp to the next level, rather than have a 90degree cutoff, which kind of messes up any side texturing or displacment.

@TU, I don't mind if you post it at all Martin, I've lost mine in the myriad of temp files. The problem I was reaching, was the regularity of the steps, and breaking that up. But Dandel'o mentioned something earlier about similar sized scale fields, which is something I didn't play around with too much, and since my latest attempt shown below, to modulate these squares, the render time has become close to way excessive for my liking. So I think I may have to go back to the PF approach.

Tangled-Universe

#7
I must say that example you have now looks quite interesting, but I prefer the result shown below here in my post.
It's probably less node heavy and faster and if it's up to me it looks better as well.

I can easily imagine different scales for the fractals there, with other displacement amplitudes as well.
Then use that as a base and add "normal" fractals for details etc. etc.

(the file you sent me then, and shown here below, was called "tgout.0007.jpg" and was from feb 15th....hope you find those files again!)

dandelO

The last example is very close to random, natural looking noise. I can see very little texture stretching, either. Some smaller scaled perlin would lay across that nicely without any sharp cut-off stretching, I'd imagine.

The example above it still has some stretching on some vertical/horizontal that reduces the realism a bit.

Could the shader array node be fed by these functions to rotate areas off of perfectly vertical/horizontal? Or, maybe just some warp function following the function layout would do?

This is great work, far beyond my paltry brain, though, I'm afraid. It looks like Spider Man has been inside your node network, Hetzen!

Really cool, well done!

Hetzen

#9
Lol Dandel'O, the nodes were compacted and then duplicated per axis, so when it was initially put together, it was a little more spread out and clearer. But that node pic does describe quite well on how close my head came to exploding.

The problem with the PF approach, is controlling the spikes you can see on the right hand side. It's certainly quick to render, and I went through several process of combining the stretched noise, some containing something like 64 PFs!, yet it was still quite renderable. I think I'll roll back a little and see if I can take that further.

The problem with the blue approach, is modulating the modulo's. I was getting some pretty bizzare shapes yesterday, which looked almost like rose petals!! Interesting, but not rock like.....

I suppose it could be used to warp the regularity, simulating tension in the rock where it has been compressed, if the steps weren't too thin..

EDIT - The steps in the Blue approach modulated above, come from using voronoi scaler noise, which has hard cuttoff's unfortunately. To get rid of those, I'd probably have to feed in a new smooth stepped square function with a larger scale.

mogn

@hetzen. I like such networks, but I have a personal dislike of conditionals.

You can avoid conditionals and make 3 comparisons in parrallel:

"Subtract vector"("Add vector"([X1,X2,X3],[Z1,Z2,Z3]), "Difference colour"([X1,X2,X3],[Z1,Z2,Z3)) == 2*[min(X1,Z1), min(X2*Z2),min(X3,Z3) ]
You can always use a colour function if the vector function is not implemented.

another minor thing: "Abs scalar" gives a noncontinous second derative (slope of slope) of the noise function.

Hetzen

Thanks Mogn. Conditionals have a logic I can understand. I'm afraid I don't understand....

"Subtract vector"("Add vector"([X1,X2,X3],[Z1,Z2,Z3]), "Difference colour"([X1,X2,X3],[Z1,Z2,Z3)) == 2*[min(X1,Z1), min(X2*Z2),min(X3,Z3) ]

...or how to write that in node form. I would seriously appreciate it if you could explain this to me step by step if you get the time. Something I don't like about the Conditional Function, is the amount of hoops you have to jump through to get a smooth cut-off between your logic argument. ie, if x > 10 then smoothly mix to y over 10 meters.

The Abs Scaler was simply put there to keep things positive (sure, I could +1 then /2), but was also used to get more variation from the Perlin Noise. As I am only sampling one point on the Perlin curve, and comparing that value with a sample point one modulo phase previous, it didn't matter whether there were billows or ridges in the noise. The noise is only there to give a single amplitude value which is used through out one modulo cycle, but I need to know whether the previous step is higher or lower than the current one, to define whether the step smoothing is rising or falling.

mogn

Quote from: Hetzen on March 11, 2010, 06:24:29 AM
Thanks Mogn. Conditionals have a logic I can understand. I'm afraid I don't understand....

"Subtract vector"("Add vector"([X1,X2,X3],[Z1,Z2,Z3]), "Difference colour"([X1,X2,X3],[Z1,Z2,Z3)) == 2*[min(X1,Z1), min(X2*Z2),min(X3,Z3) ]

...or how to write that in node form. I would seriously appreciate it if you could explain this to me step by step if you get the time. Something I don't like about the Conditional Function, is the amount of hoops you have to jump through to get a smooth cut-off between your logic argument. ie, if x > 10 then smoothly mix to y over 10 meters.


The notation [X1, X2, X3] means a vector with the values x=X1, y=X2, z= X3
So the top (first level) of the node networks starts with two "Build vector" or "Constant vector"
The second level level contains an "Add vector" where the two inputs are connected to output of the two vectors in the first level.
So the output of this node is [X1+Z1, X2+Z2, X3+Z3]
The second level also contains a "Difference Colour" the inputs in this node is also connected to the outputs of the nodes in the first level.
There is no difference in TG2 between vectors and colours. The output if this node is [max(X1,Z1)-min(X1,Z1), max(X2,Z2)-min(X2,Z2), max(X3,Z3)-min(X3,Z3)]
In the attached picture node the network the example shows the two input vectors with the values [7, 13, 15] and [4,16,12]
the values of the second level are thus [11=7+4, 29=13+16, 27=15+12] and [3=7-4, 3=16-13, 3=15-12]
The third level consist of a "Subtract vector", the left input is connected to the output of the "Add vector" in level 2,
and the right input is connected to the output of the "Difference node" in the second level.
The output of this node is thus [X1+Z1-(max(X1,Z1)-min(X1-Z1)), X2+Z2-(max(X2,Z2)-min(X2-Z2)), X3+Z3-(max(X3,Z3)-min(X3-Z3))]
This shows that the max values are subtracted from the sum, and the minimum valuse are added to the  sum, leaving the twice the minimum components.
If and "Add vector" is used instead of a subtract, the minimum values ar subtracted from the sum, and the maximum values added to the sum, thus leaving
the maximum of the components.





Hetzen

Thank you for taking time out to explain this to me. It's making a little sense.

In the node network I posted above, the logic goes:

Convert a Get position statement to give X,
Create a value loop for X of 0 to 100 through a Modulo function,
Subtract the output of the Modulo loop from the true value of X (this will give me one constant value out every 100 steps in X)
Which is then fed into a Perlin function that will give me a new value every 100 of X. Lets call this D (displacement value out of the Perlin)


So far, this is pretty much the same as your function posted earlier to define squares. What I want to do next is to say within that Modulo sequence of 0 to 100, I want to blend between 0 to 10, the difference between D and (D of X-100).

To do this, I need to feed a new Perlin function (with the same seed and scale) the same X but minus one phase of the modulo. This give me the D of the previous square. (D of X-100)

What I now need to do, is find out if (D of X-100) is greater than or less than D.
Because if D is Less Than, then I need to add (the difference of the two Ds divided by 10 multiplied by (10 minus (our modulo only up to 10)).
Otherwise D is Greater Than, and I need to subtract (the difference of the two Ds divided by 10 multiplied by (10 minus (our modulo only up to 10)).


There are 2 conditionals to consider in the above argument. One to work out if the previous step is higher or lower. The other to only count to 10 in our 100 step.

I can sort of see how you may get a 1 or -1 from your vector approach, I can also see how you could get a 0 to 10 from the modulo too with clamping. But does this really save much on processing to put in the extra math over using conditionals?

mogn

In other words what you want is generating a smooth pseudo random curve for each 100m, with the value at the zero end of the interval as the end value of the previous interval?
I will think about how to do that without conditionals. (clamp and step function are allowed even it is a form of a conditional)