Vector Control

Started by WAS, May 21, 2018, 12:53:44 PM

Previous topic - Next topic

WAS

Curious why you have to build a vector from scaler, and can't take X, Y, or Z of a vector and manipulate it like other languages? For example, in Java I can make adjustments to X, Y, or Z individually on a vector. For example creating a vector function that represents a arch. 

As a secondary question, with a vector/scalar/displacement, is there anyway to isolate the "faces" and not "depressions"?

Dune

You can do that. There are x to scalar, blue to scalar, that sort of functions. Then manipulate those and rebuild the vector.

WAS

Quote from: Dune on May 22, 2018, 01:41:25 AM
You can do that. There are x to scalar, blue to scalar, that sort of functions. Then manipulate those and rebuild the vector.

That comes back to the first question. Why do you have to do this and rebuild a vector? Didn't think about the blue to scalar etc, that would at least be able to retain appropriate channel data, or would it, since a scalar has no overhanging data?

Dune

An X or Z value has overhanging data by itself if other than zero, I'd say. But maybe I don't understand your question. I see it as a machine. If you want to alter one part, you have to take it apart, change your stuff and assemble again. Can't change without taking apart.

WAS

Quote from: Dune on May 23, 2018, 02:11:55 AM
An X or Z value has overhanging data by itself if other than zero, I'd say. But maybe I don't understand your question. I see it as a machine. If you want to alter one part, you have to take it apart, change your stuff and assemble again. Can't change without taking apart.

I see. I'm just I guess used to programing languages and being able to alter aspects of things without disassembly.  Course I'm also used to XYZV vectors. TG has no velocity. Though such a thing would dramatically change the name of the game for animation.

Matt

I'm also a programmer but I'm not sure I understand the question. Vectors are composed of XYZ values. What exactly are you trying to do?

Matt

Just because milk is white doesn't mean that clouds are made of milk.

WAS

Quote from: Matt on May 30, 2018, 01:46:12 PM
I'm also a programmer but I'm not sure I understand the question. Vectors are composed of XYZ values. What exactly are you trying to do?

Matt

I think to simplify it, I'm wondering how to effectively manipulate vectors like you would in other languages. I'm still very confused with the shader fucntions.

For example I was trying to create a moire radial to vortex warp for galaxy bands from a source (instead of using an image) but can't make sense of the functions in relation to a formula, or another language. I'm terrible with math though, like physically, I have dyscalculia, so I am easily confused, lost, or rearrange/swap values in my head, so there is more frustration than what is actually there for me in a lot of cases.

Matt

#7
In many programming languages such as C and Java, if you have a 3-component vector called 'thing' and want to change its X component, you usually use an assignment statement. Something like:

thing.x = 0.5

As I'm sure you know. But in functional programming languages you don't tend to use assignment statements like this. Instead, you use a function that returns a new vector, and with this you can construct a new vector with some of the old components and some of the new, e.g.

newThing = vector(0.5, oldThing.y, oldThing.z)

or another example might be:

newThing = vector(oldThing, 0.5, null, null)

Terragen's function nodes (blue nodes) work quite like a functional programming language.

"Build Vector" node constructs a vector but it's quite flexible. It works like the last example above. If the main input is another vector, it uses the values from that vector as a starting point. Then you can assign new values to some, all, or none of the X Y Z components. This means that if you have a vector but you want to change the X value, you feed your vector into a Build Vector's main input and then feed another node into the 'X' input, leaving Y and Z empty.

If you want to get the X, Y or Z components from a vector, you can use the "X to scalar", "Y to scalar" or "Z to scalar" nodes. So if you want to do something like this:


x = thing.x
y = thing.y
z = thing.z


then you would plug 'thing' into the main input of "X to scalar", "Y to scalar" and "Z to scalar".

I hope this helps.

Matt

https://planetside.co.uk/wiki/index.php?title=Build_Vector
https://planetside.co.uk/wiki/index.php?title=X_to_Scalar
Just because milk is white doesn't mean that clouds are made of milk.

Matt

For a lot of spatial calculations it can be more compact to work entirely with vectors and functions that operate on vectors as a whole, rather than individual scalar components. But any time you want to break a vector out into its individual components, you can with the X/Y/Z to Scalar functions. And you don't always need to "put them back together" because the Build Vector can update as many or as few of the components as you want.

But as a programmer I agree that sometimes it's much easier to express an idea in code (preferably in a non-strictly-functional language).

Matt
Just because milk is white doesn't mean that clouds are made of milk.

WAS

Quote from: Matt on May 30, 2018, 06:45:00 PM
For a lot of spatial calculations it can be more compact to work entirely with vectors and functions that operate on vectors as a whole, rather than individual scalar components. But any time you want to break a vector out into its individual components, you can with the X/Y/Z to Scalar functions. And you don't always need to "put them back together" because the Build Vector can update as many or as few of the components as you want.

But as a programmer I agree that sometimes it's much easier to express an idea in code (preferably in a non-strictly-functional language).

Matt

Thanks for the explanation. I think, in general, I was had an idea that "Scalar" meant more than it appears to be within TG. While individually you can work with scalars (like the displacement on Y) they're also sorta like bare input, and also corresponds to contrast/colour?


Matt

A scalar is just a number (a real/float). What it's used for depends on where you connect it to in your shader network.

Matt
Just because milk is white doesn't mean that clouds are made of milk.