Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
In this section we are going to explore how to start writing some simple expressions. Now that you have created some Per Particle attributes, we have a place to put the expressions. The first thing that we're going to do is explore a way of writing an expression for color. And last time I had this arrayMapper out here and I want to break the Connection to that ramp that I had put in a color before. Now it's clean and I can right click on it again and go Creation Expression. When I do that, an Expression Editor pops right up.
So when the Expression Editor pops up, I see that it is on rgbPP and Creation button has been selected because I am writing a Creation Expression, which means when the particles are born they are this color. My particles right now are already born. They are sitting there. So the first thing I do is I copy this, Selected Object and Attribute. I paste it down here, and I put an equal sign on it. And I am going to say = .3.
Okay. Colors in Maya have float values from 0 to 1 basically and I am going to go Create. Now let's see if we do a render of my particles, what color are they? They are all gray. Because this is influencing the red, the green, and the blue of the particles and it's making them all the same color, .3. If we go into the Color Chooser, for example, and I go into RGB, you'll see I have Red, Green, and Blue values here and you will see how those values take numbers.
So if I make each of them .3, you'll see I come up with the gray value. So I want to change my expression now. I don't want them all to come up the same color. I could make them like .7 or .2. And I can go Edit because I am changing the expression, so I have to hit Edit. Then I do a Quick Render and I get a different color of gray.
Let's say that I want to randomize the gray that these things are going to come out. I am going to go rand and rand is something that you are going to use a lot to make things random. And I am going to say I want the colors to be anywhere randomly chosen between like .2 and I am going to put a comma and 1 and close that in a parenthesis. Then I am going to hit Edit. That will change the expression. And I will rewind my particles back to beginning when they are sitting there.
And you will see now I have a variety of gray particles. They are all randomly coming out somewhere between .2 and 1 for the colors, the Red, Green, and Blue Per Particle. However, say I want to change my particles so with the Red, the Green, and the Blue are going to get different values. I can do what's called a vector expression instead. And to set up a vector expression, which is something that you'll be using a lot, I will just put two of these little arrow things here and then I am going to make my Red .3, I am going to make my White .1 and a comma after that and I'll make my Blue .7.
So this thing should look more blue than anything else I guess. And I am going to go Edit. I will take that space away there. Now let's do a Quick Render, I am going to rewind it. Put that down there and you see I have kind of blue-purple particles because they have been given different values. The Red, the Green, and the Blue have been given different values. Now say I want to randomize one of those values. So right within that expression, I say I want to randomize but the blue comes out. So right within this expression, I can put rand and enclose it once again the same way in these parentheses, .1, .7 and close it again in a parenthesis. The red is still going to be .3. The green is still going to be .1. But I am going randomize what color blue the particle is going to get. And I am going to go Edit again.
And always if you do it correctly, it will tell you down in the bar here, the Command bar, that you have been correct, Result particleShape1. So now once again I will do another render. I am going to just make sure I have saved this one out. Show you the difference. And you can see my particles are randomly colored differently because of that. Is that making sense? All right, so now that we have talked about some rudimentary ways to influence the color, I want to talk about influencing the opacity as well. So we right click in the Opacity slot there and go up, Creation Expression. And in the Expression Editor once again I have the opacityPP. I am going to take this here. You will see that I have my color expression there as well. Down here, Ctrl+V paste it down, equals, and so we'll once again we can do a next expression for opacity the same way that we did for color.
So I can say the opacity for this equals .2, enter semicolon, and go Edit. Now let's see what the opacity for these where they were, like that. When I do a new render now, and look, they are barely visible. The opacity is way down on these particles because I have made the opacity at .2. I can also randomize the opacity here as well. I can just go = rand (.1, let's do it all the way up to a full opaqueness, .1, 1. And I am going to go Edit.
I am changing that. And let's do another render and you will see it's randomized the opacity of these different particles right here. And I can do the same thing I have done with the rgbPP, per particle, I can randomize some of them and not randomize other ones of them too as well, because opacity will also have an rgbPP. So let's do that. I am going to take this almost the same way and just take this.
I am going to edit that, so my opacity is also been randomizing according to the Red, Green, and Blue channels of the particle. And I am going to push that down, hit that and do a Quick Render. And they are different than they were in the last one. The three channels have individually been changed, the Red channel has this opacity, the Green one has this opacity, and the Blue one has a randomized opacity of the different channels in these particles.
And so you can see how if you follow this basic template you can have fun playing with and tweaking the parameters for the color and the opacity.
Get unlimited access to all courses for just $25/month.Become a member
107 Video lessons · 34200 Viewers
94 Video lessons · 23866 Viewers
100 Video lessons · 4394 Viewers
83 Video lessons · 9388 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.