Hi everyone, in this video we're going to take a look at using masher control shaders materials
So this involves mail scripting. There's no
Direct connection that you can make from the masher
network to materials and
Because there are different data types. However using a little bit of mail scripting you can
Yeah, you can do what you like and and the good news is that you don't have to do any more scripting whatsoever because mash will do it all for you
Okay, so let's get going. This is a technique. This is extremely simple
But it can get complicated quite quickly
So I'll break this up into two parts first of all
We'll just start controlling a material color with with mash noise and master conometry or whatever and then in the second part of
This will actually use a fall off object to control our material colors and it's pretty cool
But it does involve a little bit of legwork. So
I'm going to show you the quick and dirty way to do this first and then
Yeah, we'll do the we'll do it. We'll do a more complete example
All right, so I'm going to create a cube
I'm just going to do duplicate special and I'm going to have give myself 20 objects. So like so and
There's a mash utility that will take a material of a selected object and then stamp it on to all the other selected objects
You have
That is in create mash utilities and it is stamp material on selection
So I'm going to select my first object. I'm going to give it material. Whoa. What happened there?
Oh with me come on come on. There we go. I'm gonna assign a Lambert and I'm going to call this mash
MTL one
Then I'm going to select all of my other objects and I'm going to click this stamp material on selection and
Then what this has done is it has assigned materials if you look everything that should be editor here
You'll see mash MTL 2 3 4 all the way up to 21. So these all have materials on them. Okay, so
Now we want to create a mash network. Let's go create. So all the objects selected in order you go create mash create mash network
this gives us 21 points and
We now let's just add a
noise node to the position channel and then let's leave it at that. So you've got all these kind of these
Mashed this mash network is kind of animating as you would expect it to down here. I'm just gonna turn on the objects
Let's just grab the instance. I'm actually just gonna move this over here
You can't hide the instance sir because then mash will stop working mash requires the instance sir whether you're using it
Whatever technique you're using the instance has to be shown and you could delete all of these objects from the instance sir
In order to have nothing show. However, I'm going to use them later
So I'm going to leave them there. I'm just gonna move the instance sir off the screen
Right. So remember we've got 21 objects and we've got a different material assigned to each one
so we've now got a noise node which is giving us values between it's giving us noise values between negative one and one and
Yeah, okay
So the utility that mash gives you that sets up these connections these mail scripts is called a breakout utility
So I'm just gonna load that up
Let's with the way to select it hit get waiter and this is where you choose what channel and which axis from that channel is going to
affect the nodes so well the
Target objects and this breakout utility can affect any animated object like you can affect any animated
attribute so it can affect things like an extrude amount or should random or
the bend to form a
Envelope or anything like that at the bender for my angle anything and so let's select
materials that we want to affect
by turning off that dark only objects and then we just need to select these in order and
It's pretty frustrating that my does not organize these things alphabetically or or handle padding well really
And I've got a mail script somewhere that'll sort this out for you
Actually, I think it's a Python script somewhere that'll sort this out for you and I'll try and put that online somewhere
But let's we've only got 21 objects. I'm just going to select these by hand
And then I'm gonna get targets. It's just important that you have these kind of in order
so
Yeah, so that's done and then let's all we have to do is assign and these channels to the target channels
So position X. I'm gonna pipe into color B. I'm gonna hit connect
Position Y and going to connect to color G. It connects and then Z to our connects now
If I just press play
You've got the noise affecting the material of these objects now the order of actually in this situation the order that I selected
These in is not important because they're kind of almost getting random colors
It's not important
However, it will be in a second when I start controlling the color with a trigonometry node. So bear with me
All right
So the first there's a problem with this and that is that these colors some of these colors that these objects are getting are will
Be negative values and that's because the noise node and mash
Creates negative numbers as well as positive ones. So we can just fix that by clicking this uniform noise button here
Then if we press play, oh not uniform. Sorry, absolute noise
Then if we just press play we get and all positive all positive values, which gives us more color less black
Okay, so that's that I'm just gonna turn off this noise node and I'm gonna use a trigonometry node in the position channel
And let's just set these values to one
And then if I press play, you'll see the result and just gonna add some frames here
And you see we're kind of cycling through the the spectrum here if I just increase the step
You'll see you can you can see more of a difference between the colors and now it's worth
Noting that had I not selected the materials in order
So if these materials weren't in alphabetical order here, these colors wouldn't wouldn't
Kind of work in a gradient here. They'd just be assigned to run them run them blocks
So just make sure that this stuff's in alphabetical order
It's in the same order that you add things to the mesh network. It's just one of those things to bear in mind
Okay, so that's done and that's how you can use
just some some of the mesh and nodes to
to control
It's how you can use some of the mesh nodes to control color values
And like I said, you can use it for anything. So next up and we've got
We're gonna show you how to use a fall-off node to run through these just to set it all up
So in this section of this tutorial, we're going to look at using a fall-off object to control
Materials so a mash fall-off object to control materials. This gets slightly complicated
So you're gonna have to bear with me. We need to start again. Whoops. We need to start again. So let's create our object
We'll just do the duplicate special to get another 20 of them
We'll select our objects in order and then I'm going to do the whole actually
I think I need to assign a material. I need to
assign a material first
Call this mash M T L
Mash M T L 1 actually and then
What we do is we select our objects
in order and then we go
mash
utilities
Stamp material on selection, which will give us all the different materials same as the first part of the tutorial
then select the objects in order go create mash create a mesh network and
And
Then we with with the mash network created
what we can do is
These original objects we can
Hide and they're all in the instance there because they were all selected when we created the mash network
What we can do is we can create an initial state node. So we add an initial state which puts all these objects into the right place
So it gets these positions and then feeds them into mash
So that's an initial state node and then we can add an ID node
So we just go add to ID and then all of these objects will have the correct ID
So object zero will correspond to that one and I'll get 20 or correspond to that one whatever and so on fairly standard stuff for mash
Now let's have a look at the rotation values. So
If we create an
Let's say let's do this hole. Let's create a trigonometry node in the rotation channel and
We want values between zero
Values between zero one
So we just set these amplitudes to one and then we have absolute values here. Now, you won't be able to see anything going on really here
Because one degree rotation isn't really gonna look like much in a viewport, but they are rotating ever so slightly
We'll create a bit more of a gap between these objects
Like that and then we need to set up the
Set up the breakout utility. So let's just go create mash utilities breakout utility
We'll select the waiter hit get waiter and then we need to find our materials and select them in order
Remember, this is boring thing. So we go one two
two three four five six seven eight nine ten
Ten eleven twelve thirteen fourteen fifteen sixteen
There you go. Now, you know, I can count to twenty one if we do get objects and then as before we hook up the
we hook up the
Source axes to the target channels
Now we're gonna use rotation channel this time because the position channel is busy and the position channel is busy because mash is
Needing to know where these objects are. So we're using rotation and we go rotation
X can equal car
Why can you call color G and then a note that can equal color B?
I'll get that right. There you go. So now if I press play and this is our results. I
Feel like something's not quite in order. Yes, that's right
Something's definitely not in order. Oh, that's annoying. I'm gonna have to do that again and do and do and do
Okay, I need to get those targets again. So one two three four five six seven eight nine ten eleven twelve
Fifteen sixteen
I
Get targets right now. They're in the right order. Oh, that was annoying. So we want X for
We want Y for G
We want Z for B
That's better
Sorry about that chaps, right? Okay, so
Let's go back onto the waiter here over to the trig rotation and which has got our nice values on it
Absolutely values. Um, okay. So
We're kind of rolling through the spectrum here and that's fine
So let's say that we only want the objects to be that are inside a fall-off object to be affected by this material
So remember, you don't have to use a trig node here. It could be random
It could be an offset if you just want them to go from black to white. It could be
The noise node whatever so it doesn't just have to be the trig. I'm just using the trig because it gives this interesting animation
so
So we're on the trig on the rotation and now what we do is create a fall-off object like so
Now you'll see that nothing's changed and nothing will change until you press play. That's pretty cool
And nothing will change until you press play. That's because updates aren't live when you've got everything connected up through
Malscripts, so I'm just going to move this fall-off object out of the way and going to set a position keyframe on it
No, that was a bad idea
I'm going to set a position keyframe on it here like so and then on one two five
I'm going to go all the way through and then set a position keyframe here and
Then I'm going to rewind and I'm just going to play through and you'll see
that the mash
Mash network is controlling the color of the objects
So on the fall-off object itself, we can increase the inner zone
So that they have got color for longer and then we can make this smooth
So that we have a smoother fall off
So there you go, I mean, it's it's pretty simple and we're using this is a this is all in the mash network actually if we
Um, if we were to unhide these objects here, they would have been doing exactly the same thing like if I was just to do show selected
They would be doing exactly the same thing. So it depends. It's up to you which ones you show
So, uh, yeah, I mean, uh, if I have it, I just show the instance there just because you know, it will render properly
So, um, yeah, there you go. That's the fall-off object controlling the material of objects
The fall-off object controlling the material of objects
