Getting into the details of how this works is beyond the scope of these tutorials, shader programming is a VAST subject and could fill many books. Now it’s mostly a matter of creating the appropriate input nodes, modifying them, and connecting them to the appropriate in pins on the PBR Master output node. So, that’s the basics of using Shader Graph.
The HLSL code of the shader will have just been copied to your clipboard. You can also easily see the source code generated by a shader by right clicking the output node and selecting Copy Shader. In the Inspector under the Material, you will now see a new parameter matching the name you just provided: Select the Sphere we created then applied our material too in the Hierarchy view. Now, this parameter can be defined in the editor. You can remove a node by left clicking it and hitting the delete key. Now let’s replace our hard coded texture with a parameter instead. Also optionally provide a default texture value using the example same process we just did above. Name it however you want, I called it SourceTexture in my case. In the Blackboard, click the + icon to the right side, then select Texture. Now, what if you wanted the texture to be defined as a parameter in the editor instead? This is where the Blackboard comes in. You shader preview should now show the updated texture: Pick a compatible texture from your project. Select Input->Sample Texture 2D, then connect the RGBA out pin to the Albedo in pin on the PBR node, like so:Īt this point, we have the equivalent of a diffuse texture defined in our shader, now head back to the Texture 2D Asset, click the little circle to the right of the texture field, and select a texture to apply. Now click on the red circle to the right of out and drag to an empty portion on the canvas.
Right click an empty point on the canvas, select Create Node->Input->Texture 2D Asset. Let’s show a simple example of connecting a texture map to the Albedo channel. The bottom right region is a preview of the shader, this window can be resized.Ĭreate a shader is now a matter of creating a network of nodes and connecting them together. The blackboard is the section to the top left and can be used to configure parameters as we will see in a moment. You have a choice between Metallic and Specular by dropping down the workflow tab. The PBR Master can be thought of as the ultimate output of the shader. You can zoom the design surface in and out using the mouse wheel, hold down the middle mouse button to pan the surface around. A new project should look something like this: Simply double click the shader and the Shader Graph editor will be create. Make sure your shader is selected and showing in Inspector, then simply drag and drop your newly created shader on it.įinally, drag your material to the Sphere you created earlier. I called mine MyMaterial, again, name yours whatever you want... even Dilbert. Right click the Materials folder and select Create->Material. One more small bit of setup before we start creating shaders! We need to create a material that we will attach our shader to and ultimately apply to our sphere mesh.
Except for Dilbert that’s a stupid name for a shader! I called mine MyShader, name yours whatever you want. Right click the newly created folder and select Create->Shader->PBR Graph.
In the Project panel, I created a new folder called Shaders. Now that Shadergraph is enabled, let’s create one. In the resulting window, select All, then Shadergraph, then Install. Click Window, then select Package Manager. Now we need to enable Shader Graph functionality in Unity. We need some kind of object to apply our shader to, simply right click the newly created scene in the Hierarchy view, select Create->Sphere. Once your project is loaded, go ahead, and create a new scene. There is no need to add any new packages… yet. For the record, Shader Graph does NOT work with the current HD pipeline, this feature is under development. Shader Graph is fully compatible with the new light weight render pipeline. Next, start Unity and create a new project. There is also a video of this tutorial available here or embedded below.įirst off, to get started using Shader Graph, be sure to be using Unity 2018.1 or later.
In this article, we are going to look at how to enable and use Shader Graph. Unity 2018.1 was just released and one of the major new features is Shader Graph, a new visual programming language for creating shaders.