Shader Graph in Unity for Beginners
Learn how to create your first shader with Unity’s Shader Graph. By Wilmer Lin.
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress, bookmark, personalise your learner profile and more!
Create accountAlready a member of Kodeco? Sign in
Contents
Shader Graph in Unity for Beginners
30 mins
- Getting Started
- Checking Pipeline Settings For Shader Graph
- Creating a PBR Graph
- Creating a Color Node
- Navigating the Interface
- Adding a Glow Effect
- Making the Highlighter Script
- Adding Mouse Events
- Highlighting the Game Piece
- Using Texture Nodes
- Adding a Fresnel Effect
- Multiplying by Color
- Adding Blackboard Properites
- Adding Base Texture and Normal Map properties
- Adding Glow Size and Glow Color properties
- Where to Go From Here
Adding Glow Size and Glow Color properties
Now you’re going to expose other types of properties on the Blackboard as well. For example, it would be useful to allow the user to adjust the Fresnel Effect Power value.
Click the + icon in the Blackboard and create a Vector1 property. This represents a single float parameter.
Rename it GlowSize.
You can limit what values can be entered in this property by converting it to a slider. Switch the Mode to Slider, then set a Min of 0.05 and a Max of 6 to define the range. Set the Default value to 5.
Drag the GlowSize property into the workspace area. Plug the output port into the Fresnel Effect Power input.
Finally, allow the user to set the glow color through a property as well. Instead of creating the property from the Blackboard, you’ll convert an existing node in your graph.
Select the Color node, then right-click and select Convert to Property.
The Color node converts into a color property on the Blackboard that is no longer editable directly in the graph. Rename this property to GlowColor.
Click Save Asset, and return to the main Editor window.
Select the Glow_Mat material in the Project window. You should see a GlowSize slider and a GlowColor color chip available in the Inspector.
Edit your material values to your liking. Finally, enter Play mode to test your work.
You now have a customizable highlight that you can tweak to your heart’s content!
Where to Go From Here
Congratulations! You can now create your very own shaders with Shader Graph!
With some creativity, you might surprise yourself with what else you can create. Want to make a cool, sci-fi laser beam or forcefield? You could adapt what you’ve done here into just the right shader.
Though there are literally hundreds of nodes to explore, this tutorial should have helped you to get started using Shader Graph.
If you have an questions or comments, please join the forum discussion below.