♪ [MUSIC] ♪
[ALEX] Hello, everyone. I'm Alex Lindman.
I am a technical artist at Unity Technologies,
working primarily on Shader Graph.
In this session, I'm going to be covering the new features
available in Shader Graph for Unity 2020.
The new features include the Master Stacks and the Graph Inspector,
and we'll review how to use both of these to create a shader
for both Universal Render Pipeline
and High Definition Render Pipeline.
Let's go ahead and get started.
Initially, I'm going to go over the agenda for today.
I'll do a brief introduction of what Shader Graph is.
I'm going to do a brief feature overview of the two new features
that I'm reviewing today. Then I'm going to follow it up
with a live demo in the Editor with a working project
so that you can see how to use these tools directly in the Editor.
And then I'll close it off with a couple of remarks and notes
about what to do for further reading.
In case you're not familiar of what Shader Graph is,
it is a node-based shader editor.
This means you can use it to create shaders and materials
for your Scenes that look awesome without needing to write
any code whatsoever.
Alright. First, I'm going to review
the Master Node to Master Stack conversion.
Previously, Shader Graph used a single Master Node
as the output for the whole graph.
Now we are using a new Master Stack.
This Master Stack contains all the same outputs
as the previous Master Nodes that you're used to,
so you're not losing any data whatsoever
as you upgrade into this new process.
Everything should hopefully be pretty familiar.
The new Master Stack also splits
the Vertex and the Fragment outputs.
Previously, the Master Node had per-vertex calculations
and per-pixel calculations all together in the same chunk,
and it can be kind of difficult to tell which is which.
With the new Master Stack, we've split those up
so it's really clear which specific outputs
are being calculated, per vertex or per pixel,
which is really important if you need to optimize your shader.
The Master Stack also provides a new modular output.
This is super helpful because individual outputs
are now dynamic based on the graph settings.
We also have new visual feedback for the compatibility here.
You can see in the supporting image right now that you have
both active nodes, which are super bright,
and then inactive nodes, which have been dimmed back.
This is how we communicate that certain parts of your output
are not compatible with the currently selected settings
and shows you which parts of your Shader Graph
are not being calculated in your final shader output.
The Master Stack also allows a single graph to compile
for multiple render pipelines at the same time.
It also makes it a lot easier to change your shading models
without having to redirect any of your hooks.
The other new feature we have right now is the Graph Inspector.
This is a new sub-window that we've added
into the Graph window.
It collects all the graph settings into a centralized location,
as you can see in my supporting image here.
It is a context- and selection-specific settings window,
so this will only ever be settings for what you have selected
in your active Shader Graph window.
It will never be overridden by any other selections you make
outside of your Shader Graph Editor
and has no interactions with the normal Unity Inspector.
This makes it pretty nice because now you can preview
all node- and property-specific settings across different graphs
at the same time using the Node Settings tab.
You can see in my supporting image here,
and I'll show you this again later so don't feel too worried
if you can't see it, but if you use the Node Settings tab,
you can see all of your selected node and property settings
in this window. If you use the Graph Settings tab,
you can see all of the settings that are specific
to the graph Asset that you're working inside of.
This is going to be all of the Material type,
the Workflow type settings that you can see in this image here.
Alright, with that quick overview, now we're going to go ahead
and hop into a live demo inside of the Editor.
Alright. You can probably tell,
I have a project already finished and ready to go.
This is just so that we can make this a little faster
and hopefully not stick around with you guys watching me
just populate things into a Scene.
Currently, this project is set up
to work on the Universal Render Pipeline,
and this Scene is rendering using the Universal Render Pipeline.
If I pop over into the Game view for a second, you can see
we have several different objects visible inside of the Scene.
All of the objects you can see here are using Shader Graph shaders.
Alright. I'm going to go ahead and open up one of the shaders
that we're using in this Scene so you can take a look.
This is our super-simple color masking Shader Graph.
This is what we're using to apply to the spaceships
so that we can very easily make multiple spaceships
using different colors using the same shader.
You can see that I've already upgraded my file
into the new Master Stack's format.
This is an automatic process.
If you have any Shader Graphs that are in older versions
using Master Nodes, you can expect your Shader Graphs
to automatically upgrade into the Master Stacks
and have it maintain all of your existing connections.
You shouldn't see any breakages when upgrading,
and if you do, please file a bug report with us
so we can help you fix it.
Now, in the upgrade process, it's important to note one thing.
If you are using multiple Master Nodes
inside of the same Shader Graph file,
only the currently active Master Node
will be upgraded into a Master Stack.
Because we can only have one Master Stack per file right now,
there is not going to be any compatibility
with multiple Master Nodes.
If you are using multiple Master Nodes
in your graphs for any reason, I recommend opening up your graphs
and identifying any of the differences
between your currently used Master Nodes,
writing them down somewhere so that you don't lose
any of that data, and make sure you have all of that documented
before you do your upgrade process.
Now that we have our Master Stack ready to go,
I'm going to give you a tour of the Graph Inspector,
and how it relates to the rest of our Master Stack and our graph.
In our Graph Inspector, I'm currently on
the Graph Settings tab.
Under the Graph Settings, you can see we have a new section
called Target Settings,
and a section under that for our Active Targets.
Targets just means the output that you're trying to generate
from your Shader Graph.
You can see here, I've already selected the HDRP target
and the Universal target, which means that I'm compiling
this Shader Graph to work with both HDRP and Universal Render Pipeline.
If I wanted to add more targets, I could use this plus sign (+)
and look at the list and see what is available.
Right now, I could add a Visual Effect target,
but I don't need my shader to work with the VFX graph,
so I don't need to worry about this right now.
If I wanted to remove a target from this,
I would just need to select my item in the list
and hit this negative sign (-) here.
Now, my shader will only work in HDRP,
it is not compiling for Universal anymore.
But that's OK. If I wanted to get it back,
it's as simple as pressing the add button (+)
and hitting my Universal object again.
You can see underneath the Active settings
that we also have foldouts that are specific
to each active target.
Right now, we have HDRP and Universal.
These can be collapsed in case you don't need to view
any of these settings at all, or you can open only one or the other
if you're only interested in one target at a time.
Each target will have its own specific settings,
so I highly recommend checking out the documentation
if you want more details about each of these specific settings.
However, if you've ever used the Settings menu
on a Master Node before, hopefully a lot of these options
are going to be familiar.
We've tried to make sure that all of the previous
configuration settings available on every Master Node
have also been ported into these settings
in the Graph Settings.
Everything should be one-to-one and any settings
that you had previously set in your Master Node
should also be represented in these new settings in the Inspector.
You shouldn't be losing any data, so if you are,
please file a bug with us.
If you wanted to change your Material type,
it's as easy as just selecting this drop-down
and selecting a different option.
Here, I'm going to make my HDRP Unlit.
You can see that changes the amount of settings that are available
for my Unlit shading model, and you'll also notice
that one of my blocks went dim, as well as the nodes
that are connected to it.
This is to showcase that there is currently a block
that is populated with data, but that is not being used
by any of the outputs right now.
If I switched it back to my Lit model,
it would then become active again.
You can also notice that any of the settings I had for my Lit model
are maintaining whenever I switch back to them.
Another feature to note is when changing
any of the settings inside of the graph
that might affect the Fragment stack,
you might see blocks being automatically added and removed.
This is a default setting that we provide
so that it's easier to know what outputs are required
for each shading model.
I'm going to show you an example of this.
If I go to my Material drop-down and select Hair,
you'll notice that a lot of new blocks have been added
to my Fragment stack. These are all things
that are specific to the Hair lighting model,
and they are specific to HDRP.
If I wanted to remove them, it's as easy as just changing over
into my Lit option.
What happens here is that any of the blocks
that are already connected either by connecting to a port of a node
or by having their default values inside of the flags here change,
they will maintain.
You will not lose anything with custom user data inside of it.
If you wanted to remove anything specifically,
you can select the block and press the Delete key
or you can right-click and Delete.
If you wanted to add a specific block,
you can right-click inside of the block context and Create Node
to see a menu of the available blocks that can be added.
Double-click that to add a new block to your stack.
You can also highlight this and press the Space Bar
to invoke this node menu as well.
If you don't like your blocks being automatically added and removed
based on the changing of the settings,
that can also be modified.
If you go to your Preferences, you'll see a Shader Graph tab.
In the Shader Graph tab, we have
an Automatically Add and Remove Block Nodes checkbox.
If you disable this, and then go back to your graph,
you'll notice that none of your blocks are being
automatically added or removed based on changing your settings.
I'm going to go ahead and re-enable that setting
because I personally find it pretty useful
not to get my stack too cluttered with things I'm not using.
You'll notice that some of my blocks haven't disappeared
because the data has been modified from default.
I'm going to go ahead and just manually delete these
because I don't really need them.
Now that we've reviewed some of the Graph Settings that are available,
and how to work with the new Master Stack,
I'll shift over to the Node Settings tab so that you can see
where some of our context-specific settings have moved.
Inside of the Node Settings, you will see a display
for any of the settings related to objects you have selected.
Right now, I have nothing selected, so there is nothing
inside of the Inspector.
If I start selecting nodes on my graph,
you'll notice that the settings associated with that node
populate in the Inspector.
I can also Shift+Click or drag to select multiple options
inside of the graph and see the settings for everything
that I have selected.
In the Blackboard, previously we had some settings
directly available in a foldout under each property.
In order to make these a bit easier to work with,
we've put a lot of the advanced settings into the Graph Inspector
so that your Blackboard is not cluttered,
and you can easily see all of the properties you have available.
If you select your property from the Blackboard,
you will see all of the options show up in the Inspector,
and again, if I control to select multiples,
I can see multiple options available.
These are all the same settings that used to be accessible
through the Blackboard. There shouldn't be anything
new or confusing. If you find anything missing,
please let us know.
If I wanted to select things in the Blackboard and on the graph,
that is also totally possible and it also gives me all of the settings
for everything I've selected, regardless of where
I'm selecting them.
Now that I've done an overview of the actual Master Stacks
and the Graph Inspector, I'm going to go ahead
and show you how easy it is to use this graph
in both Universal and HD.
And remember, all I've done to this graph
is just set up a couple of color masks
and plugged things into the appropriate outputs on the stack.
I've made sure my Active Targets contain both the HDRP
and Universal target selections,
and I've made sure that both of them are rendering
in the way that I want them to.
I'm going to go ahead and quickly save my Asset just to be sure
that everything is exactly how I want it,
and hop back over to my Scene.
My Scene view here is in Universal, and it looks pretty good,
and it can probably run on a wide variety of platforms,
which is awesome, but I think I want to go ahead
and punch this Scene up a lot, and make this something
to really run on higher-end PCs.
To do this, I'm going to go ahead and move my project
into the High Definition Render Pipeline.
To move my project into the High Definition Render Pipeline,
I'm going to use the HD Render Pipeline Wizard.
This is nice because it gives me just a single button to reconfigure
all of the settings in my project to be compatible
with the High Definition Render Pipeline.
Great. Now that I've reconfigured my project
to be rendering for the HDRP,
I'm going to go ahead and open my HDRP-specific Scene.
Now, remember, Universal and High Definition Render Pipeline
have much different rendering requirements
and Scene setup requirements.
If you want to know more about how to set up Scenes for both
the Universal and the High Definition Render Pipeline,
I highly recommend checking out other tutorials
or other pieces of documentation.
I've got everything set up today just so we can take a look
at that end result.
Alright. I've loaded up my HDRP-specific Scene now.
These are all objects using that same Shader Graph shader
just like we had in the Universal Render Pipeline Scene.
I've added a couple of post-processing effects,
there's a couple of extra pieces of lighting responses,
there's a bit more detail in the Normals,
it's kind of just punched up to 11.
But as you can see, all of the shaders in the Scene
are still working exactly as we expect.
I didn't have to do anything special to the Shader Graph,
I didn't have to reimport any Assets
in order to make it work inside of the Scene.
I'll pop over to the Game view just so you can get a closer look
at how all of these pieces are working together.
You can see all the objects are rendering super nicely,
and we've got all of our extra little effects
for viewing inside of HDRP instead of URP.
And it is simply that easy to create a single Shader Graph
that will render for both render pipelines
almost instantaneously.
One thing that you'll notice if you're using
the 2020.2 beta right now,
is that the Material Inspector for your Shader Graphs
might not work immediately when you change render pipelines.
As part of your render pipeline configuration,
make sure to reimport any Materials that you might have shared
between the two.
Alright. To end this out, I'm just calling out
some important resources that you can refer back to.
We have our package documentation and that is honestly
one of the best resources available.
Inside of our package documentation,
we have a written Upgrade Guide reference,
which has more specific details and notes about what to expect
when upgrading older versions of Shader Graph
into the newer Master Stack framework.
We also have written reference for the Master Stack
and written reference for the Graph Inspector,
both of which are easy to reference later
in case you need any of this information again.
Thank you.
♪ [MUSIC] ♪