Feedback Wanted: Shader Graph

Archived thread: please continue discussion here: Unity Engine - Unity Discussions

With Unity 2018.1, the graphics team is bringing you all new levels of control and flexibility. Whether you’re a beginner or a pro, we’re empowering you to create amazing projects that look fantastic!

One of the coolest features coming in 2018.1 is Shader Graph. Freeing you to create a range of shaders; flowing lava, gooey slime mound, beautiful lakes, flashing LEDs, and more!

Designed to work with the Scriptable Render Pipeline (SRP) out of the box, with support for:

  • The HD Render Pipeline (Coming soon)
  • The Lightweight Render Pipeline
  • And the ability to extend the system to export shaders for any custom SRP you write

What is a Shader Graph?

A Shader Graph enables you to build your shaders visually. Instead of hand writing code you create and connect nodes in a graph network. You can do things like:

  • Procedurally alter your surface appearance
  • Warp and animate UVs
  • Modify the look of your objects using familiar image adjustment operations
  • Change your object’s surface based on useful information about it, its world location, normals, distance from camera, etc.
  • Expose to the material inspector what you think is important to edit for your shader
  • Share node networks between multiple graphs and users by creating subgraphs
  • Create your own custom shader graph nodes through C# and HLSL

The graph framework gives instant feedback on the changes, and it’s simple enough that new users can become involved in shader creation.

How do you create Shader Graphs?

In Unity a Shader Graph appears as a normal shader. To create a Shader Graph you click the create menu and select ‘Shader graph’ from the dropdown. This will create a Shader graph asset in the project. You can double click on the asset or select the Open Graph button to bring up the Shader Graph Edit window.

When you open the shader graph you start with the ‘Master Node’. You connect nodes into the master node to create the look of your surface. To learn more about the underlying material models check out the existing Unity standard shader documentation.

You can quickly edit your surface by changing the default values!

But, you know what’s even more exciting? Adding textures and other complex interactions. To add a node simply right click and select ‘Create Node’.

Each included shader graph node has a number of inputs, we’ve included default values that you can customize however you like!

Adding in a texture (or other assets) is also really easy, just create a node of that asset type and connect it!

Your shader graph shader is just like a normal shader in Unity. Right click create material to create a new material you can use on any object in your game. You can create multiple materials from the same shader.

You can expose parameters in your shader so they can be overwritten in each material you create from your shader. This is easy. In the shader graph right click on any variable node and select ‘Convert to property node’. These exposed parameters appear in the material inspector for each material you create from your shader.

To see your new shader graph changes affect your in game materials click the save button.

How do I get access to the Shader Graph?

In the next iterations of the beta, we will integrate these elements in a friendly user workflow for creating and using projects. But if you can’t wait to try them out, we made a simple sample that uses SRP, built on the Lightweight pipeline, and also includes the Shader Graph tool.

To get started, download the sample project, open it with Unity 2018.1 beta, and start exploring!

What are the requirements to try this out?

This is a feature for the new scriptable render pipeline, available in 2018.1. It will not work out of the box without a SRP.

We won’t be supporting this feature for the legacy renderer.

I want more tutorials!

More will be coming (including more examples!) over the coming months. We have an end to end shader creation video here as a starter point.

I have questions!

Excellent! We are happy to answer them. Please reply to this thread and we will try to help you out.

What is the current status?

We’re targeting shipping the Shader Graph for 2018.1. In the future it will be included in your project automatically when using an SRP. This is the first version of the Shader Graph and there are already future updates planned. Give the current iteration a spin and send us your feedback and info on any issues you run into. We want your help to make this feature as amazing as possible and are excited to be able to add awesome updates for future Unity releases based on the ideas you send us. We are so excited to be introducing this feature! (It is about time :))!

Give it a try and write your thoughts in this thread.

25 Likes

Very nice tool!

One question, is tesselation supported ?

Thanks

3 Likes

Hi, thanks :slight_smile:

Tessellation is something that needs to be implemented differently per Render Pipeline. As such we do not currently support it in the Shader Graph. Expect to see more in that area in the future.

Thanks for asking!

3 Likes

Thanks for the update, another question :
vertex animation? for making water waves for example.
using textures to offset vertices?

2 Likes

This is similar (albeit slightly less complicated). We are currently working on supporting vertex animation. Expect to see it in a future beta release.

14 Likes

Can the UI widgets in the graph view be exposed so they can be used for other purposes? We have a combinatorial system for generating terrain maps on the fly (heightmaps, splats, scenery placement) - basically a very similar problem, and this front end would be absolutely perfect.

5 Likes

I’m kinda new to shaders, and haven’t worked with Geometry shaders (Only simple vertex offset ones, aside from Fragment and Surface ones, of course).
As such, I’d like to ask, will we have some kind of Geometry shader support in the near future? I’m planning on learning to write them, but I keep hearing about how difficult it is.

This is great to see. Obviously it’s not a complete replacement for writing shaders in code right now (see features like tessellation and vertex animation that you already mentioned), are you able to say if the intention is that this will be a full featured replacement for tools like Amplify/Shaderforge and writing shaders by hand?

4 Likes

Haven’t touched it yet but I’m really looking forward to it tonight.
Off the bat, I see xyz instead of rgb. Either way works but it may confuse some people.
Also, I see the material starts as what seems to be a flat grey at .5 .5 .5 but then the number is cranked above 1 to make a red. Assuming the max value is 2.55, why wouldn’t it start at 1.28?

1 Like

How is extended support in the area of image effects going to look like?

Sounds good ! Can’t wait to see more !
Any idea about supporting UI shaders? Neither ShaderForge or Amplify Shader Editor support UI shaders.

1 Like

Hi,
Internally the shader graph has an abstraction it uses to compile shaders to multiple render loops. In theory, if I write a custom SRP that needs different inputs to the lighting equations, different pass semantics, etc, then I can modify this abstraction layer such that shaders produced in the graph tool are compiled with whatever passes and inputs I need.

It would be great if you could break this abstraction layer out of the shader graph tool and make it something hand written shaders can use as well. This could be a replacement for Surface Shaders, as they don’t work under SRP but the need of such an abstraction is still very great. Being able to write one shader, and have it just work across multiple SRPs, and have it not break every time Unity changes the UNITY_SHADOW_COORD macro or whatever, would be very useful. Preferably the graph could output this code instead of going directly to the assembly as it does now, which is not very useful.

I don’t want to be forced to use a graph to have such an abstraction. While graphs are fine for smaller shaders, they are ill-suited to complex shaders and shader frameworks like the ones I write. It is unlikely Unity’s graph will ever reach the point in which it would be possible to do many of the things I do, let alone do it in a way which isn’t a complete nightmare to work with. Supporting vertex/fragment shaders across multiple Unity versions and all the different lighting pathways is a nightmare, and almost every Unity release will break one of these. Having a common abstraction for these issues has and always will be the right thing to provide.

19 Likes

My current water requires tessellated vertex animation, so please consider the use case, thank you (for HD).

Also bonus for any kind of adaptive solution… : >

6 Likes

Hi,

a Graph UI framework will become available in a future Unity release as public API with a proper documentation of its own. You might stumble upon new Experimental API endpoints to support ShaderGraph but they aren’t ready to be used by Unity developers just yet.
Also it is built on top of UIElements which is still experimental as well and being actively worked on.

Regards,

8 Likes

We will look forward to that! Thanks for the response.

@clovergruff Pretty much the same answer as for Tessellation I’m afraid. I believe we will support it because we will be required to. However, this is Render Pipeline specific and as SRP pipelines have very well defined pass structures it is an architectural challenge to support these features in a way where the graph interactions themselves are render pipeline agnostic.

@Adam-Bailey Correct assumption. The version we released today is still very much beta and in very active development. But correct, the intention is to provide as much functionality as possible (within some SRP agnosticism limitations) and deliver a “complete” shader authoring solution.

@devon_j_hartman That gif is actually a bit out of date (oops). The default input to Albedo on the Master node is now a Color picker and all LDR color values operate within 0 - 1 as you’d expect.

@TechnicallyBeginner Good question! Were currently not targeting Post-processing as an output as we want to focus on surface definition first. However, I have made a proof of concept Master node which can export a Post-processing effect that plugs straight into Post-processing Stack V2 (with no C# needed!). We need to take a good look at what is the correct way to solve this. Don’t expect this anytime soon.

@cAyouMontreal Pretty much same as above. It can be done but is not currently planned out.

5 Likes

Since the ShaderGraph seems to be required to be pipeline-agnostic,

  • is the pipeline-agnosticism an actual technical limitation, or just a Unity policy?
  • Will users be able to relatively easily add new pipeline-specific “master node types” to the shader graph? Let’s say I want to make my custom PBR master node specifically for HD pipeline with tesselation, vertex offset, etc… Can I do it? What about a new master node that has custom lighting, such as a toon shader?
  • For even more advanced cases where the shader graph isn’t the best tool for the job, how will shader programming work in the SRPs? Is there any info on “C# shaders” somewhere?

I’m trying to access the z property of the Screen Position or Position nodes, how do I go about this?

I should be clear that we do intend to support all features (barring any unforeseen circumstances) of the HD render pipeline in Shader Graph out of the box. How exactly this works is still being worked out as work continues on the HD pipeline and Shader Graph.

Also you will be able to write just about any Master node you could want/need for any of the existing pipelines (within that pipelines limitations) or any custom render pipeline you might write. Documentation on how to do so is being worked on.

As for shader programming for SRP in general, you will still be able to hand write shaders for SRP pipelines (although you will have to learn how the SRP shader library and the pipeline itself work obviously). C# shaders is something else entirely, and not something we are ready to talk about.

2 Likes

The shaders for the LD pipeline are available on the BitBucket, but they don’t seem to compile under the 2018.1 beta- perhaps there’s a particular branch that works, but I have not found it.

Currently, from what I gather, if you don’t want to use the graph, and you want to support multiple render pipelines and put an asset on the asset store, you will have to:

  1. Write your shader once for each pipeline (like traditional vertex/frag shaders)
  2. Duplicate all materials, prefabs, scenes and objects which point to those shaders and make versions for each pipeline
  3. Ship to asset store
  4. Get 1 star’d by users because 2/3rds of the assets won’t compile in whatever SRP the user has installed. (Ie: I have LD, so surface shaders and HD won’t compile)
  5. Get 1 star’d by users because 2/3rds of the assets will look broken
  6. Test new Unity release where some low level shader macro has been changed in one of the pipelines and fix breakage.
  7. Make fixes, duplicate fix into 3 pipelines, test in multiple unity versions under multiple SRPs, go back to #3
  8. Leave the asset store forever because this is insane to expect for less than minimum wage
11 Likes