# Uniformal Scaling and Offsetting - the Transformation2D node

General / 15 May 2019

I briefly showed one of my function graphs in my 'Key Ring Generator' pieces about how the key's head scaling worked. I wanted to discuss that particular feature a bit more, but I also didn't want to got too off-topic in my documentation/breakdown. So I figured that I'd make a separate blog entry about it instead!

This is nothing new for experienced Substance Designer users or anything revolutionary at all. I just want to show a specific case of when a bit of math and dabbling in the function graphs can automate an otherwise tedious and manual process.

In my 'Key Ring Generator', all key heads border the bottom of the canvas (so that no manual re-adjustment to the offset is needed to assemble a full key). This poses a problem, because they can't be scaled using the Transformation2D node without also having to adjust the offset to keep the keys bordering the bottom of the canvas (because the Transformation2D node scales in relation to the center of the canvas).

I absolutely do not want something like this to limit what my graphs can do or that the user have to manually adjust the offset whenever the user scales the key's head.

So lets take a look at how the Transformation2D node works and what we got to work with:

This is what the essential transformation settings look like in an unmodified 'Transformation2D' node once we click the "Matrix" button (this is where we see the state of the Transformation2D node, it does not reset after changes unlike the other GUI).

These are three instances of the Transformation2D node. They are all uniformly scaled versions of a hexagon, that borders the bottom of the canvas, and offset so that the hexagon still borders the bottom of the canvas:

With these cases, we can see the relation between the 'transform matrix' and the 'offset'. It's absolutely necessary that we observe multiple cases, as some patterns between the numbers may look like a relation but are just a coincidences.

Offset = -('Transform Matrix X1' - 1)/2  is the relation we're looking for, which keen minds will recognize from the 'Key Ring Generator' documentation:

(In this case, 'Transform Matrix X1' is called 'scaleoffset' which is, in hindsight, a very bad and confusing name for that specific variable).

Cleaning this up and adding more approachability and utility to the function graph, it looks like this:

(1 divided by 'scale') is the 'Transform Matrix X1' in this case. This way, we can input a value between 0 and 1 where a lower value means a smaller scale. 'x_offset' and 'y_offset' are additional exposed values that control the offset on each axis. (x_offset = 0 , y_offset = -1) means middle of the x axis, at the bottom of the canvas.

Just for comprehensive sake, here's what the 'Transform Matrix's function graph looks like:

And that's how I automated a small portion of my graphs for the 'Key Ring Generator', to avoid manual inputs.

One extra little thing I wanted to mention, because I don't think this is a very visible feature in Substance Designer but can be very useful: This is what happens when we start inputting non-uniform numbers into the Transform Matrix.

Well that's that. It's 03:30 (am) and I really need to stop. Good night everybody!