Question about the Node Network

Started by archre, May 24, 2011, 06:03:26 AM

Previous topic - Next topic

archre

Hi folks.
I'm very new to TG2 and before I'm gonna start a project, I want to understand the node network thoroughly. I've been working with Max/MSP a lot, which is a graphical IDE for audio, and also based on a node network
http://www.benjaminyobp.com/blog/wp-content/uploads/2010/02/maxpatch.jpg

Coming from that background, one thing I don't understand yet about TG2. When I'm using a get position-node, extract the x value, mess around with it and then feed its output into a Displacement Shader, how does the shader know that the input applies to 'x'? If that would be Max/MSP, you would probably need to feed it a list of tuples (x,f(x)). Does TG2 automatically work with x first, then y, etc..?
I know this is a question going down deep into the implementation of TG2, but in order to understand what's happening, I want to know that.

Another thing is the order of node-arguments: Right to left (as in Max/MSP) or left to right or other? I don't know yet if this is relevant for TG2 at all, as you don't have streams of data you need to synchronize between (and make sure all arguments are calculated yet).

Thanks!

Hetzen

The Get nodes take their value at render time, ie, they work on the final positioning of everything in the node chain. Chains tend to work top down, but there are exceptions, like "final normal" in the surface layer node. As for order of calculation with say two get positions, I would hazard a guess that the first one created would have priority over a second, but that's just conjecture.

For using the X part of a Get node, you then need to either use a convert x to scaler node, or negate the Y and Z portion by multiplying with a constant vector with the values (1,0,0) . If you now want this value to displace in X, then plug the previous into a Redirect shader on it's X input. If you want to warp the colour space (ie not displacement) of a fractal, then plug the same redirect into the warper part of a Warp shader, and the PF (power fractal) into the shader input of the Warp node.

All the best

Jon

archre

#2
Thanks a lot Hetzen!

Quote from: Hetzen on May 24, 2011, 07:39:29 AM
For using the X part of a Get node, you then need to either use a convert x to scaler node, or negate the Y and Z portion by multiplying with a constant vector with the values (1,0,0) . If you now want this value to displace in X, then plug the previous into a Redirect shader on it's X input. If you want to warp the colour space (ie not displacement) of a fractal, then plug the same redirect into the warper part of a Warp shader, and the PF (power fractal) into the shader input of the Warp node.

Yeah I know how you get the x component of a position, but what I didn't get so far is how the shader knows about what is fed into it. If you want so, I'm missing a connection from "get position" to the shader, so I'd guess the shader gets the position automatically?

rcallicotte

Depends on what  you mean by "get position".  X is X.  But, there won't be exact measurements of placement, if that's what you mean.  Not sure what you mean.
So this is Disney World.  Can we live here?

archre

#4
Example: Let's assume we want want to displace the point (A,B,C) by displacement d.

Please correct me if I'm wrong, but as far as I got it, I think with TG2 you need to use getPosition -> X to scalar, Y to scalar, Z to scalar and connect those to 3 conditional scalars which output 1 if the condition is correct and 0 otherwise and then multiply the outputs and then use a 4th cond scalar which outputs d if the input is 1.

What I had first expected was a shader with 3 inputs where you can directly specify a position (A,B,C) and a displacement value d - which would have been more direct and much easier...

Henry Blewer

Doesn't the Transform node do this?
http://flickr.com/photos/njeneb/
Forget Tuesday; It's just Monday spelled with a T

Matt

#6
It sounds like you want to displace just a single point, leaving the rest of the surface untouched. You can't really displace a single point because the renderer is unlikely to create a microvertex at the exact coordinates you need, but you can displace a small area, and there are shaders specifically for this purpose. The Simple Shape Shader colours and/or displaces all points within an area that you choose.

If you need to specify the position dynamically within the function network, then yes, you'd need to set it up a bit like you described. You'd want to increase the catchable area of the point, however, so that it gets sampled by the microvertices of the terrain. You might do that by subtracting Get Position from the point of interest, taking the length of the resulting vector, and feeding that through a Soft Step Scalar with appropriate begin and end values. Just as an example.
Just because milk is white doesn't mean that clouds are made of milk.

Tangled-Universe

What I find difficult about this function-network stuff is the math behind it and also the logic.
For example:
What does "length" of a vector mean, I suppose magnitude, but how does an undisplaced microvertex can have a vector with a magnitude?
That calculation would need to look further "down" into the network for a displacement value?
How is TG doing this?

Matt

#8
Quote from: Tangled-Universe on May 24, 2011, 12:50:30 PM
What does "length" of a vector mean, I suppose magnitude, but how does an undisplaced microvertex can have a vector with a magnitude?

If a vector represents a position, then it is the vector from the origin (0,0,0) to the position. Therefore the length (magnitude) of the vector is the distance from the origin. That in itself is not always useful.

However, if I subtract one position from another, I get a vector from one point to another. The length of that vector is the distance between the two points.

http://en.wikipedia.org/wiki/Euclidean_vector
Just because milk is white doesn't mean that clouds are made of milk.

Hetzen

To give you an idea how you could use this Martin.

If you want to create a sphere in clouds, you use a get position, then plug that into a "length to scaler" node, which works out the length between (0,0,0) to your get position (x,y,z). You can then use a conditional scaler to look at that length from the origin and if it's less than your sphere's radius (let's say a constant of 1000m), then the output is 1 (white), if not, it's 0. This plugged into a cloud node with the right altitude and depth values, will create a cloud sphere.

But because your natural origin is (0,0,0), then you will only see a semisphere, as the rest will be under your planet surface....

You can position your origin, by subtracting a vector to the get position, to trick the length to scaler in thinking it's measurement is away from (0,0,0). So by by subtracting a constant vector of say (0,1000,0), with a cloud altitude of 1000, and a cloud depth of say 4000 (this negates the cloud nodes internal algorithm of soft clipping the top and bottom of a cloud), then you'll have a sphere.

To play a little more with this, you could then add a perlin noise function to the get position value to trick again a modulating centre point, which will then give you a 'wobbly' spherical cloud.

To expand a little more, you could use a modulo scaler on the x,y,z to offset the origin by steps of say 2000m, and you'll get a 'grid' of wobbly cloud shapes.

Fun stuff. :D

rcallicotte

You guys are fantastically wearisome.  I appreciate the math, but I don't want to understand.    :-*
So this is Disney World.  Can we live here?

Hetzen

That's a shame Calico, but understandable. 8)

Thing is, these tools should allow you to do almost anything in what has to be one of the most stable graphic applications out there.

I'm positive you can create the Great Wall of China running and meandering along hills with stone texture, ramparts, towers every 100m and arched gates every 1000m, pretty much all based on simple math rules.

Take that a little further, and create cities with streets and skyscrapers, that light up when the sun goes down.

There are levels of math required to do the above, but it can be as simple as you like with repeated textures, dirty conditional logic, or pure applied Mogn trigomath.

Blues aren't as frightening as people make them out to be.

dandelO

* In fool's terms(all I'm capable of, really), I found the length to scalar node converts any scalar into a simple, infinite length line output with (default)1m falloff(0.5m each side), according to which direction the scalar is running.

If you take an X to scalar and output that to a length to scalar, you will end up with a 1m, smooth-falloff line running back/forth, Z to scalar becomes a 1m falloff left/right line. A Y to scalar becomes the same but in the vertical direction. The actual length of the line is infinite.

The output, though, seems to actually be inverted in practice, i.e. the default 'line' is black which fades to white over the scale. Invert this to have a simple, single line function which can be manipulated any way you choose from there.

Excuse my terrible ignorance of the maths(and life, in general), I'm just a mere fumbler. But it does do this if that's all you want from it.

* ^^ Bullsh*t and useless as far as maths goes, I know. Just posting the idiot's version on the function, as far as I've used it in the past.

Matt

#13
dandelO,

The "length to scalar" part above isn't necessary since you already have a scalar (you have X to scalar etc.). "Length to scalar" is for taking a vector and finding its length (which is a scalar). If the input to "length to scalar" is a scalar, then because it expects a vector it first creates a vector (with all components being equal to the scalar), and then it calculates the length of that vector. The result is a little bit longer than the original scalar, BTW, but basically it's not a useful calculation.

EDIT: Oh, I forgot, it does do something useful because it turns all values into positive values. What you can do instead is use the "Abs scalar" function.
Just because milk is white doesn't mean that clouds are made of milk.

dandelO

Matt, what would be a correct method to create a simple line function according to the direction you want to use then?

My tinkering has been that; if I take a line-out from any scalar then, the 'length to scalar' function creates the inverse of what I want, all that's required to convert that is an 'inverse' function, or a colour adjust shader, to invert the output, which can then be scaled according to a constant.
This seems the easiest to me, for now, but I do understand that I don't really understand these maths functions in any great detail! :D

Sorry for this digression, archre.