♪♪♪
Zak Parrish: Greetings and welcome back. In the last video,
we created a basic sprite emitter which you can see here.
It put some multicolored sparks into the scene.
Now we are going to create a
GPU sprite emitter. To save us
a little bit of time, we are going to
start by converting this sprite emitter into
a GPU sprite emitter and show you why
that is a good thing to do. I will show you some of the
things to consider. I won't call
them pitfalls, but I will show you some things to keep in mind
when working with GPU sprites.
For starters, let's
create a new folder inside
of our MyParticleSystems folder.
Click New and select New Folder.
Call this "GPUSprite".
That will work. Open up the Sprite folder first.
I will select that same particle system (P_Sparks)
we created in the last video. Drag-and-drop P_Sparks
into the GPUSprite folder. Select Copy Here so
we have our own custom version of the sprite emitter that we can adjust.
Rename this particle,
so we can keep track later. Call this
"P_Sparks_GPU".
Now, here is why we want to do that.
First, here is our GPU sprite area.
Drag-and-drop P_Sparks_GPU into the scene right here.
Obviously at the moment, this is the same thing as our sprite emitter.
What happens if we want this to have a
whole lot more sparks than it does right now?
Double-click to open up the Template to open the particle system in Cascade.
If we were to currently take the number of sparks
and increase the Constant from 50.0 to
500.0, we get
a whole lot of sparks. Of course, that is great.
You can see it is certainly trying to make
those sparks for us and the color is getting very intense because
of that, which is awesome. We will probably tweak the colors to make up for
the sheer volume that we have. But what if we want to go higher than that?
Let's increase the Constant to 2000.0.
We quickly run into a problem right here
inside the Particle Count. You might not be able
to see the Particle Count very well right now because it is blue on black.
We can change that. Click on this tiny
color bar for this emitter on the left-hand side.
We can change the color to something a bit more visible. I will change it
to yellow. You will notice right now I have a
1000.0 particle cap on this
emitter. If I needed to change that
for some reason, I could.
I don't really want to do that. Select the Required module.
At the bottom in the Details panel, there is a Max Draw Count
that I can change. I can start working with
that value. Really, this is basically the system
saying that is too many particles for a CPU emitter.
At this point, we want to convert it over to a GPU emitter.
That is easily done. Right-click
in this blank spot in the Emitter List.
Go to TypeData and select New GPU Sprites
type data module. Now, there is a problem with doing this.
Actually, there are a few problems. Maximize Cascade.
First and foremost, we don't see anything and
we have some red Xs on a couple of our modules.
Not every module available in
Cascade will work with GPU particle systems.
It is a trade off. You get more particles,
but you get fewer features.
You also get some new features that aren't available anywhere else.
Like all things in life, it is a trade off.
Select the Collision module and press Delete. Select the Light module
and press Delete. Suddenly, everything starts working.
The particle effect is working in our level too. In fact, it is working
a little bit too well. Let's change the color
to make the effect a little less
assaulting on the old eyeballs.
Go to the Out Val for Point 0, which is the color when spawned.
Let's do something in the green spectrum this time. Leave X at 1.0.
Set Y to 7.0. Leave X at 1.0 so you start to push
towards white, which is a lot more realistic.
Let's set the Distribution to a constant. We will say I don't want this one
to change color. Right now the Distribution is set to a curve. Click the drop down menu and
select DistributionVectorConstant. We can set that to a constant value and that means
these particles will always have the same color.
Set X to 1.0 for red. Set Y to 10.0
for green. Set Z to 1.0 for blue.
You get a nice brilliant emerald green.
Even 10.0 might be a little high.
Set Y to 5.0.
Click the Lit menu and go down to Exposure. It is a good idea to double check
and make sure your Exposure controls are working
or make sure they are off. Turning the Exposure controls
off will often make things like this look a little better.
This is because your virtual eye in game
will quit adjusting with you. That can really
help with your effects. It is good test in both directions. For now,
I think we are going to turn off the Exposure controls. Under Constant, X is set to 1.0,
Y is set to 10.0, and Z is set to 1.0.
Now, we are pouring a lot of green into the scene.
I want to do a couple of things. Select the Initial Location module and press Delete.
Now the sparks are pumping out from a singular point. I like that a little
bit better. We are also no longer
colliding the way we were before. Go underneath the floor.
Did you see that? The creepiest thing just happened. Watch this.
Right as we start to rotate out of the view, do you see what is happening?
Our particles disappear.
This allows me to talk about that other problem that we
saw a little while ago. We cleaned up our extra modules, but
we are getting a warning. "This particle system has
no fixed bounding box and contains a GPU emitter."
That is a problem, and the reason why may not be readily apparent
until you rotate the camera away. As soon as the
emitter leaves the view frustum, this
particle system will stop rendering. That is the nature of
GPU particles. What is the solution?
The solution is to create a fixed bounds or an area
around this particle system. This is where we say
the bounds are in view, so you can go ahead and
calculate the particle system. It is easily done. All we do
is click Bounds if we want to see them.
Click on the drop down arrow next to Bounds and select
Set Fixed Bounds. Once we have done that,
it is still going to blink if you immediately test in the view.
Make sure to click Restart Level in Cascade.
Now, check it out. We can rotate
completely out of the view and the particles remain.
We can see the bounding box inside of Cascade because we
turned on Bounds. As long as the bounding box remains in the
view frustum or what the camera can see, then these will continue
to evaluate. This is definitely worth being aware of.
The next thing I want to do is deal with collision. If I go out of the view,
you will notice these particles are falling down through the floor.
Collision with GPU particles is really easy to set up. Right-click and go to Collision.
Select Collision (Scene Depth).
This is actually using the depth buffer off the graphics card. We get
bouncing particles. Select the Collision (Scene Depth) module,
and go to the Resilience property in the Details panel. Resilience is how
bouncy the particles are. Under Resilience, set the Constant to 0.1.
Friction is set to 0.0, so the particles will hit
and then they will slide a little bit.
Select the Lifetime module.
In the Details panel, set the Min to 1.5 seconds. Now you can see
the particles start to slide across the surface like some sort of fluid.
Set Resilience to 0.3.
They will get a little bit of a bounce and then they will slide some more.
The neat thing about using the depth buffer for this sort of thing is
that any objects we want to collide with this basically work for free.
Let's say I have a chair. Drag-and-drop SM_Chair into the scene.
Watch this. As I slide it through the particles,
they bounce of the chair.
You just get that.
It is definitely cool and fun to play with.
There is another feature that GPU particles can do that
nothing else can do that is definitely worth checking out, which is
vector fields. Vector fields are a 3D representation
of vectors that you can use to push particles around
within the volume of the vector field.
Currently here at Epic, we are creating vector fields
by taking a fluid simulation from Maya and taking a single
snapshot of that fluid simulation in time, storing the vector data
of how that fluid was moving at that moment in time and, saving that.
We are using some of our own tools for that.
I don't want to say whether or not those tools are
available right now to everybody because they may or may not be.
You do have access to a couple of vector fields,
if you want to play with them. There are some already in the
Elemental project, which we released. You can play with those.
In Elemental when the big lava knight guy stands up,
his eyes spit out some particles that swirl around
in a really interesting way. That is because of a vector field. You can actually
get into that project and dig out those vector fields. However, I am in the
Content Examples project. Select Filters.
I am going to reset Filters.
Go to Content Browser > Filters >
Miscellaneous > Vector Field.
There are a couple vector fields included here.
Select vel_219, which is apparently the frame number
that Maya was on when it stored that information. Let's use that.
Right-click in the Emitter List,
go to Vector Fields, and select Local Vector Field.
Local Vector Field means it is a part of this particle system.
It is going to ask for the Vector Field in the properties. I can drag-and-drop vel_219
right inside the Details panel. You may not be able to
see your vector field at first. Click Bounds so the bounds are not as distracting.
Click the View menu and select Vector Field.
You can turn Vector Field on an off. Currently, that vector field is pretty small.
Let's change the size of this. Set Relative Scale 3D
to 20.0 for the X, Y, and Z values.
Set all three (3) axes to 20.0.
You can move the field around relative to the location of the emitter.
Currently, it doesn't look like it is doing much and that is only
because it is not. Select the Vector Field. I can increase its Intensity.
Intensity is how much those vectors
are going to push the particles around. Then, we have Tightness.
Tightness is how much influence the vector field is going to have.
A value of 0.0 would mean no influence. A value of 0.5 means it is starting to push
the particles around. A value of 1.0 means it is totally taking
over control of where the particles are going.
The particles are only going to go where the vector field tells them to go.
If I position this the right way and then
increase Lifetime
to 5.0 seconds for the Min and 7.0 seconds for the Max,
the particles live a lot longer. Now, they are starting
to move through the scene a little bit. I am going to select the Size By Speed
module. Set the Speed Scale Y value to 3.0. Set the
Max Scale X and Y values to 3.0. There we go.
That gets rid of some of that flicker. The particles were stretching out a little bit too much.
Select the Local Vector Field module. Increase the Intensity
way up. There you go. Now it is starting to whip
the particles around into this sort of spiral line.
Notice as soon they leave the bounds of the vector field, the particles
kind of fall off. The acceleration kicks the particles up and they just drop.
Select the Vector Field and set Relative Scale 3D X, Y, and Z values to 30.0.
Now we are getting a really cool spiral effect.
When we leave the bounds, the particles still kind of fall down.
That is okay. Let's make things a little more interesting. Let's take
our vector field and spin it around. Right-click, go down to Vector Field and select
VF Rotation Rate.
We can add that and then we can determine how fast we want the vector field
to spin around on all three (3) axes. Set X to 0.1, set Y to 0.15, and
set Z to 0.07. Now, we are spinning on all three (3) axes.
Let's take a look and see what that looks like in the level.
It is just really spinning the particles around
and doing really cool and interesting swirly designs.
Now, we can start to customize a little bit. Set Tightness to 0.4,
so we are only influencing the particles a little bit.
Now the particles are going to splash around a lot on their own.
Pull the particle system back towards the center of our area here.
Click the Bounds options menu and select
Set Fixed Bounds. We want to reset the bounds because they are bigger and our
particles are moving in a lot of different directions at this point.
There you go. There are some GPU particles doing some
madness. Definitely play with that and you can get all
kinds of wicked and neat effects. I am going to
decrease the Intensity to about 80.
Decrease Tightness to about 0.2. Let's see what that starts to do.
I like the higher Intensity. Set Intensity back to 100.0.
Yes. It is almost like some strange
spooky fluid effect.
It still has the collision, which is a really awesome touch.
We have now created a GPU sprite emitter.
We noticed a few important things. First, a GPU system
will not draw if the emitter is not on the screen
and it doesn't have a fixed set of bounds. Make sure you always
use some fixed bounds when you create a GPU emitter.
Also on that note, I should point this out.
It might be on the entire particle system.
Click on the empty space
outside the Emitter List. You will notice there is a Bounds group
and there is the Fixed Relative Bounding Box.
You can change that. Earlier, we clicked on the Bounds options and selected
Fix Relative Bounds. If you want to modify that on your own
and make some changes, you can set the Min and Max sizes
for those Bounds under Fixed Relative Bounding Box. If you click Bounds to show
those first, then you can tweak those values
here and make your bounds bigger or smaller.
That is how that works. We noticed some other very important things.
Not every module you may have added to a particle system is going to be
compatible with GPU sprites. At the same time, you get
some benefits that aren't compatible with anything else either.
Vector fields don't work with CPU particles. Vector fields are for GPU particles only.
Collision (Scene Depth) is only on GPU particles.
It is a trade off. You lose some things, you gain some other things.
GPU particles cannot emit light because there is no location
that is handed back off to the CPU for the light to follow.
That option is not available. If you wanted this particle system to look like
it was emitting light, you would need to create another emitter
inside your particle system that is rendered
out invisible particles which just had a Light module.
You would have some particles where you wouldn't see the sprite itself. You would
only see the results of a Light module. Essentially, you would fake it.
That is going to wrap things up for this video. Thank you very much.
♪♪♪