Hey
welcome back! So we're going to talk about Exporting Models with Materials now!
We think we've nearly got our pin finished, and in this used case,
it's going into a game engine. So let's carry on the process, let's get it finished!
Let's talk about how a .blend file may appear elsewhere, in this case,
in Unity, how to export as an .fbx file
with materials attached, why using a .blend file is
leaner if your target program will support it, briefly talk about smooth shading
and normals, you may have noticed that the pin is a little bit kind of blocky,
and then, I'll explain why we may want multiple levels of detail.
So let's just have a look! What's this about work
flow and leanness? Well the leanest thing we can possibly hope
for is that our target package live reads .blend
files. So Unity, for example, if you put the .blend file in the Unity assets,
it will read it live, and you change the Blender file and it changes immediately in Unity.
You may have a 3D printing software that does the same, you may have a different game engine,
whatever, so that's the ideal. The next best thing, if you can't do that,
is to save as a .blend file but just import into your target package.
So at least you've only got one thing to do every time you make a change to your model,
and then, you go to your target package and you do another import. And the trickiest thing,
that you may need to do, is to export from Blender every time you make a change,
as a .fbx, .stl, or whatever and then, import into your program. So
you've got lean, medium, and hard, it's a bit like burgers. OK, so let's take
a look at all this in practice! Here's our nice stripey, pinie, thingy, widget!
So what I'm going to do is, I'm going to crack open Unity for
you, which is a very popular game engine. Now it's free! If you want to go and download
it, from Unity's website, you're very welcome to, and you can
play with it. But this is a Blender course, so the purpose of me putting
Unity up here is, I want to show you the livest
and leanest possible way of dealing with a .blend file in another program.
So if we don't export, rather, but save a copy
of the bowling pin, right into the
Unity or your target program's appropriate
folder... Now, in the case of Unity, that is
the Assets folder. So I've put it in my target program's folder.
Now, Unity's very well behaved with this! What it does is, it notices something appeared
in this Asset folder, and I can just put it straight into Unity. Here it is,
there is your bowling pin in a game engine! Isn't that pretty cool! I'm going to move this
light out of the way, because it's very distracting. And there we go, congratulations we have
something in a different program! Now, the cool thing about working with a
program that works in my leanest paradigm, remember the top one here
the target package live reads the .blend file, is this. Look if I
go into Blender and I say go into Edit Mode and I go
grab maybe one of these faces and kind of yank it out like that, if I save
the .blend file, watch Unity! See it's immediately
changed in Unity! There it is, you see the pin has the thing in it, which I
think is very cool! Now I can undo that and resave, and Unity will
immediately noticed the difference. So that's the best possible workflow!
The next best workflow is that you need to kind of import into your target package but
it's still a .blend file. And the trickiest workflow is where you
need to go Export, as say an FBX.
Let's try that from Blender, go ahead and try exporting your pin as a .fbx, by the way.
And you could, say, stick it in your Downloads and call it BowlingPin. You can leave all the
settings default and then you have a .fbx file. Then, you have to go
over to your target package and let's delete everything that's here,
for now, and then, you go in your target package and you Import a New
Asset and you go find it [Laughs] and then you Import it, and eventually,
you end up in a very similar place. Now notice, when you import a .fbx it also
has a Materials folder, the Pin and the Stripe are preserved, and if I open
up this thing, it has the Camera, the Lamp, the Pin, the Pin mesh,
etc. And I can still pop this pin in my scene and it still behaves!
So either way is good, but of course, now if I make a change in Blender... Ooh, I want that
pin to look more like this! Saving it's no good! I have to Export it
as a .fbx again and then reimport it. You see how much more of a hassle
that is, than just actually saving the .blend file? Yep, much
more of a hassle! So I am going to work with the .blend file, because
it's a lot easier for me, over here in Unity. So
I save my .blend file, look at Unity, and it updates immediately.
Lovely! OK fantastic! So let's go back to the slides and talk about the other things!
So you've seen how a .blend file may appear elsewhere, you've seen
how to export as a .fbx, with materials it all just kind of happens, and you've seen that
using a .blend file is a much leaner way of doing things. Now, I want to talk about
smoothing and normals and then multiple levels of detail.
So here is our bowling pin in Blender! And
if we're in Edit Mode, remember that you can go down here in the Properties
Panel, and you can go somewhere and you can say, show me the normals. And
their Vertex Normals in Unity, so I'll show the Vertex Normals. There they are, they're little
hairs, and they are one per face. Another way to show it is sticking out
of the faces instead of the vertices, the same number of normals roughly.
So the problem with this pin is, both in Blender and over in Unity, it's
pretty rough, you see you can see every single cell. Now you may say, ooh I should turn the poly count
up, but hang on hold your horses, it's already got a lot of pollies. It's already got
what 1,680 triangles, which is plenty!
What we need is something called Smooth Shading, and back
in Object Mode, in Blender here,
you can go down under Tools and you can click on Shading, Smooth.
Look at that! It's really looking pretty smooth now!
And if you do that and you re-save it, re-save
the BowlingPin, the great thing is that those extra normals, which you'll
learn later help determine how the thing draws, they come into Unity
as well. The same number of polygons! It's amazing! If you don't believe me,
then look here in Unity. It tells you 1,680, or
look back in Blender, 1,680. But it's a trick of lighting
that's making this look smooth. In fact, I would even go as far as to say that Unity
is doing a better job of shading that than Blender. Maybe when we go to
the Rendered Mode in Blender... There you go, Blender's doing a pretty good job in Rendered Mode.
But Blender's preview, it's solid preview, is not quite as
good as Unity's rendering. But anyway, there you go! So
we don't need to up the poly count crazily. What
a lower poly model like this will not do for us is hide the fact that the
edges are still a bit like Max Headroom. [Laughs] You can still see the geometry
on the edges there, and that, of course, is exactly the same
deal in Blender. It doesn't matter how much smoothing you put on, you're going to see the
geometry at the top of the pin,
whether it's Flat or Shaded. You see the edge, the outline, the
occlusion of the background is going to be the same, but going from Smooth to Flat
really makes a difference to the visual appearance, especially with a good shader like the one
here in Unity, or when you actually render later in Blender. Cool!
So the final thing I want to talk about now is, how about I'm
in a game engine, I may want this pin to do something, right? We presumably would have a bowling
pin, because we want to make maybe a bowling game and we want to do
something with it. So I'm just going to make a floor, really quickly here
and just put it below the pin.
So I'm just giving the pin some physics now,
and if we play the game, the pin falls straight through the floor. That's no good!
So what I want to do is add something called a collider! Now, the purpose of
this is that you, as a designer, are going to have to help with this, because watch what happens!
If I now try and add something called a Mesh Collider to this and I
say, well what's the mesh, and I go and say well it's the pin, look what happens in
Unity when I try and run this! It's going to complain!
None-convex mesh colliders are not allowed! Now Mikey's going to talk to you
about what a convex-mesh is, but it basically means that none of it sticks inwards. The neck
of this pin is concave, and this game engine will not allow
concave, so Mikey's going to be showing you how to make convex meshes. So say I
say to Unity, OK make it convex, it will go I can't, because it's got more than
256 vertices, my brain hurts! It's got far too many vertices!
Look in Blender, the vertices are 870! So it just doesn't
work, it can't work, I can't make this work, I cannot make my pin collide with the floor, and I'm
now an irritated game designer. So I'm going to go back to Mikey and say,
Mikey, I want a lower poly, a less than 255
vertex collider, and the end
effect of that is going to be something like this. He's going to provide me with a different mesh.
I'm then going to bring that mesh in here and it is going to be
a green outline like this and it'll be kind of something like
that but it'll be more pin shaped, and when we've finished, what'll happen
is my pin will actually, if it starts with some Rotation,
it will actually land
and fall over but properly. You see that's just dodgy,
because whatever I do with just a cylinder, i.e. this part of the pin here
hits the ground properly or the neck does but not both. You see if I thin it down, it'll
go through the floor, etc. So our mission now, with Mikey,
is to make a mesh that is 255 vertices or
less, representing the same shape and scale as the pin,
but is also convex. It must
be a convex mesh, so from this tip of the pin to here it's going to have to be a
straight line, nothing going in. So that's what comes next, and I hope that was helpful,
as you can see the fate of your models when they arrive in things like Unity!
See you soon!