>> My name is Marcus White,
and I am a principal technical artist at Unit 2 Games.
Unit 2 Games was founded about a year and a half ago,
and I joined shortly after that.
We are kind of working on our first game, called Crayta.
Crayta is a collaborative game development platform,
so the idea is that you can build things with your friend,
and we do stuff like Voxels and Lua, and all that fun stuff.
The important things that I will refer back to later
is that we will also look into allowing users
to import their own Meshes,
which kind of dictates our pipeline a bit.
Today, I am going to take a look at Python,
and basically how we used it in our studio.
Unit 2 Games has only got about 30 employees,
so we are actually quite a small studio.
We have got quite high goals
in what we want to do to accomplish the game.
Today we are going to take a look at
why you use Python in Unreal.
The options you have got,
if you want to use Python in Unreal,
a couple of examples of how we actually used it
within our company to try and streamline our workflow,
any future work that we wanted to take on,
and finally some takeaways.
Why use Python?
I am going to compare quite a lot to C++ here,
because that is kind of the main alternative for all this.
But obviously, in comparison to C++,
you have got very quick iteration.
You do not need compile times, which is a plus and minus,
because it means you get less coffee breaks.
Python is quite an old language.
You have got a vast library of libraries that you can use.
It is very easy to distribute throughout your teams,
so you do not need to send out a new build;
you can just commit your one file to Perforce,
wherever your source control is,
and then they can just pull, and they get your scripts.
You do not need to involve programmers.
This is actually quite a big win for a team of our size,
so with our small team, we have only got
kind of limiting engineering bandwidth available.
Whatever we can take care of within the art team internally,
we will not hassle the programmers
and the engineering team. It is quite a big win.
It is also, in comparison to something like C++,
it is quite easy to learn,
so if you have never touched coding or scripting before,
but you are interested in kind of automated pipelines
with Unreal, it is a great place to start.
Also, if you are using something like Max or Maya,
then using Python within that, you can extend your workflow
all the way up to the Engine.
Also, I just like Python. It is a good language.
What are the options if you want to use Python in Unreal?
Currently there are two options available,
but with really confusing names; very similar names.
You have got the Unreal Python implementation,
which is the official Epic one that came in 4.19.
This is just a plugin you can turn on,
I believe it is still in the experimental stage,
experimental phase. That supports Python 2.7.
But if you are able to build the Engine yourself,
then you can put in whatever version of Python you need,
whatever suits your project.
You have the official implementation and
something that we ended up using,
was UnrealEnginePython, which is a third party plugin
that is freely available in GitHub.
It grants you full access to the Unreal Reflection system,
as well as the internal API,
and it has nice APIs within it for working with Python.
It supports Python 2.7, 3.5 and 3.6.
The reason that we ended up using it was
because our project starts on 4.18,
I believe, so the official Epic
implementation was not available to us.
As I said, the Unreal Engine Python,
you have got full access to all the internal API
and Reflection system,
but you also get some nice editing tools
within Unreal itself, so you have got access to --
it has its own console, Python console,
as well as its own -- I will not say robust IDE,
but it has got its own editor within that that you can use.
The great thing about it is that you have got lots of options
for extending the Editor as well,
so if you want us to add your own windows, tools,
manual entries, etc., and so forth,
you can add those really easily.
How easy is it to actually add a window?
If you are a programmer, you have dealt with C++ before;
a lot of this code might look familiar to you.
But basically, everything is contained
within this Unreal Engine module,
which comes with the Unreal Engine Python implementation,
and for the rest of it, it is very similar
to what you will be doing in C++,
just a bit of slightly different syntax to it.
In Slate UI,
you can create your window, create your text block,
and then create a very basic dialog.
The great thing about this is,
I said there are no compile times,
and it means you can iterate really quickly,
so it allows for trial and error workflow, which is really nice.
We are going to look at a couple of examples
of how we use the Python at Unit 2;
the first one being how we ended up
getting our Asset ingestion in.
I am trying to read this without my glasses on --
but I am sure many of you
have dealt with Asset ingestion scripts before,
and generally speaking, what you want to do is import
and set up as many props in as little time as possible,
with as little human error as possible, which is -- yeah.
We have only got 30 people at Unit 2.
We have got six artists, and two of those artists
are dedicated to props full time,
and one of them is sat there.
What we need to be able to do is, support our very small team.
But we always have aspirations
for a very large amount of Assets in our game.
We do not have the internal bandwidth for this,
so naturally we are relying quite heavily on outsourcing.
As many of you have worked with outsources before,
it does not come free of charge,
you still need to be able to process the Assets
internally when they come in.
What we need to be able to solve is,
supporting our small team.
We need to be able to cope with a large amount of Assets
that we want to bring through.
We need to be able to iterate on those Assets.
But also something that is a little bit unique to our game
is that we need to maintain a consistent art style
of whatever came in.
That would also include user-generated content.
We want to make sure that the workflow that we use internally
would support whatever came in from players.
In order to support that kind of workflow,
we opt to use a Substance-based workflow,
not Substance Painter, but Substance Designer.
The idea is that we will create a set of Materials internally,
which we can then allow the outsources,
but also players, to use.
This allows us to maintain our consistent art style,
and also prevents stuff like inappropriate imagery.
You can imagine if you give free will to all the players,
the first thing that they are going to create
is something quite inappropriate.
We have solved the first two problems.
But how do we solve the rest of them?
How do we make this quick and easy, and not error-prone?
This is kind of where Python steps in.
This is our pre-Python workflow;
so we would get our Asset from the outsourcers,
then we would go and bake our control Textures
that will be used by Substance.
We would then import all of these Assets into Unreal,
and set up our Substance Materials
in their user Substance plugin, and then review in game.
As you can see, it is quite a lot.
We might get into a situation
where the Asset might not be perfect after review,
so we need to go around and do the entire loop again.
As a technical artist,
my first instinct for this is to write a tool.
The way we did this is that we asked the outsourcers
to prepare their Assets a certain way in Maya.
We asked them to create Materials
that matched our Material library names,
and then assign those to the triangles of the Mesh.
That, alongside with a normal map,
was all they needed to provide us.
Next, we took the normal map and our prepared Asset,
and then we ran that through SBSbaker,
which is part of the Substance automation toolkit,
and if you have used Substance Designer or Substance Painter
to bake out your Textures,
this is basically what it is doing at its lowest Level;
it is just running this SBSbaker command line tool.
Out of that we get a curvature and an ambient occlusion map.
Then we also use a PIL,
which is the Python Image Library,
in order to convert our Texture associations in Maya
into a single trial ID map. We then used PIL, yes, again,
in order to combine those into a final Texture,
putting each component into a red, green,
and blue Texture.
There is quite a lot going on under the hood
in terms of the Texture work. It is also doing stuff
like maintaining the naming conventions
as we go through the entire pipeline,
putting stuff in the right directories,
etc., and so forth. But the nice thing is,
it all comes down to a very easy-to-use interface.
There you can see, the artist can just select a directory.
We have a selection of Assets that we got from the latest
Asset dump from the outsourcers,
and click one button, and off it goes.
It is easy to use, there is no room for error,
it avoids repetition,
and it allows for a very quick turnaround.
Through that workflow, it means we can go
from this Asset from Maya, from the outsourcers,
but it is also, from the outsourcer's point of view,
this is very quick for them to set up;
they do not need to actually go through and
manually create Textures.
The script basically converts from this format here
to what we see in the game of our final Materials.
Using this workflow, we have gone from our old
pre-script workflow
on the top to a much shorter one on the bottom,
which obviously allows for a much quicker turnaround.
Now we have got the Assets in game,
and we bring in quite a few Assets.
We need a way to keep an eye on them,
and see their current state of production.
Then we move onto the Asset overview.
The intent of this is that at any given time,
we can keep a view of a current state of production
with all of our Assets coming in from the outsourcers,
if they are in the white box state,
if they have the Materials assigned correctly,
if there are any problems, or if they are just done.
But also, we wanted to make sure
that this is useful outside the art team.
We wanted to be able to give a way for our Level designers
to quickly see what is available for them to use.
We also want to make it visual, because artists like pictures.
What we opted to do is, actually leverage
Trello in order to do this.
In order to interact with Trello,
we use the py-Trello API wrapper,
which just basically gives you a Python route
to the Trello web API.
In addition to this, we also included the Perforce history,
so we can see if an Asset breaks,
who broke it, when they broke it,
and who to blame.
On top of this, we also export out the thumbnails,
and some additional Material metadata,
which then gets read by the Python scripts,
and also populates this table.
You can see, if you are familiar with Trello,
you can see there is a card up there,
and it says, completed,
so we go through and we check, okay,
has it got the correct Materials on it?
Does it have any Materials on it?
We can kind of trace through using the metadata,
the kind of state of things.
That is one of our Trello boards
that we set up, which is quite a variety.
I do not know why it is pink, I will blame the art director.
But if we take a look at an example there,
like the Jeep in the middle, we can see it is completed.
We can actually see what the Asset looks like.
Also, if you were to click on it,
it would have all of the history behind it.
But if you were to compare that with the crate,
just top right over there,
obviously that is during the white box state.
But it allows us to have a very quick overview about everything
that is available in the game, and the current state.
That is kind of what we have done internally using Python,
but obviously, Python is a very flexible language,
there is a lot more that we can actually do with it.
Some things we are actually looking to do is,
automate this as part of our Jenkins build process,
try and get more automation out of this,
so there is less manual work.
Also, the great thing about Python
is that it is great for incidental fix-up work.
I am sure some of you might have been in a situation
where a bunch of your Assets,
either the date has changed, or the data format has changed,
or you need to run through all of your Assets
and fix them all up.
This Python is a great way of doing this.
Also, we are looking to do some extra Editor alterations,
so we can kind of streamline some work
for our Character artist -- singular --
but also try and just, generally speaking,
just tame the art process
to try and streamline as much as possible.
General takeaways from this is,
computers are great at doing the heavy lifting --
let them do it.
If you are working with a very small team,
you cannot afford to spend time doing repetitive tasks,
or just doing very menial work.
You need to make sure that you automate your pipeline
as much as possible.
Also, Python is a great entry point into scripting
and just kind of understanding how Unreal works under the hood,
so I highly encourage you to have a play about with it.
Yeah, I will wait for that very quickly.
Yeah, we are hiring.
If you want to make our team a little less small,
then check out our website. Thank you very much!
[Applause]
♫ Unreal logo music ♫