Shader Graph Tutorial for Unity HDRP & URP | 2022 LTS (2024)

The Shader Graph team is excited to announce the release of our newest set of samples, available to import now in 2022 LTS and the upcoming Unity 6 release. This set of samples contains more than 25 Shader Graph assets and dozens of subgraphs that are ready to be used directly in your projects. The sample shaders work in both HDRP and URP.

We have two main objectives with this sample set:

  1. Give our users a jump start in shader creation by providing a set of shaders that are ready to use.
  2. Provide examples that users can build on or modify to suit their needs.

This sample set will help you achieve the shader results you want more quickly without starting from scratch.We also include a step-by-step tutorial that shows how to combine the assets to create realistic environments. With the tutorial you can see how the shaders work together in context.

Sample content

Here’s a breakdown of the content available in the Production Ready Shaders pack:

HDRP and URP Lit Shaders

Shader Graph Tutorial for Unity HDRP & URP | 2022 LTS (1)

Both URP and HDRP come with code-based shaders. The most commonly used shader for each of the SRPs is called Lit. For projects that use it, it’s often applied to just about every mesh in the game. Both the HDRP and URP versions of the Lit shader are full-featured. However, sometimes users want to add additional features to achieve a specific look, or remove unused features to optimize performance. For users who aren’t familiar with shader code, this can be very difficult.

For that reason, we’ve included Shader Graph versions of the Lit shader for both URP and HDRP in this sample pack. Users can make a copy of the appropriate Shader Graph Lit shader, then change any material that’s currently referencing the code version of the Lit shader to the Shader Graph version. All material settings will correctly be applied and continue to work. They’ll then be able to make changes to the Shader Graph version as needed.

Decals

Shader Graph Tutorial for Unity HDRP & URP | 2022 LTS (2)

Decals allow you to apply local material modifications to specific locations in your scene. Think of things like applying graffiti tags to a wall or scattering fallen leaves below a tree. But decals can be used for a lot more. In these examples we see decals making things look wet, making surfaces appear to have flowing water across them, projecting water caustics, and blending specific materials onto other objects.

Terrain details

Shader Graph Tutorial for Unity HDRP & URP | 2022 LTS (3)

This set of shaders is made for meshes applied to terrain – such as grass, weeds, undergrowth, pebbles, etc. To learn more, read the terrain documentation on details. Detail meshes have some specific requirements for shaders. First, because of the high number of these meshes used on the terrain, their shaders must be as fast and efficient as possible. That mainly means keeping the number of texture samples low and doing more work in the vertex shader instead of the pixel shader. Second, because these meshes stop rendering and pop out at a specific distance, we use a method to dissolve them to prevent a harsh pop, making it less obvious that they’re being removed. In each shader, you’ll see a Distance Mask used to dissolve the mesh at a distance before the mesh stops rendering.

Rock shader

Shader Graph Tutorial for Unity HDRP & URP | 2022 LTS (4)

This is a full-featured, modular rock shader that can be used for everything from small pebbles, to boulders, to large cliff faces. It has features that can be turned on and off depending on the application. Each is encapsulated in a subgraph so it’s easy to remove unneeded features. You can also add new features in the chain of modules.

Water shaders

Shader Graph Tutorial for Unity HDRP & URP | 2022 LTS (5)

The sample set comes with four different water shaders – lake water, animated pond water, stream water, and stream waterfall. Each one uses reflection, refraction, surface ripples using scrolling normal maps, and depth fog. They also provide additional features unique to each water type.

Weather effects

Shader Graph Tutorial for Unity HDRP & URP | 2022 LTS (6)

This sample comes with a full set of weather-related subgraphs (rain and snow) that can be mixed and matched depending on the requirements of the object type. Rain effects include rain drops on top of objects, rain drips trickling down the sides, and puddles that can dynamically accumulate on flat surfaces, including rain and wind ripples.

Forest stream tutorial

Shader Graph Tutorial for Unity HDRP & URP | 2022 LTS (7)

The sample set also includes a step-by-step tutorial showing how to combine the water shaders, decals, rocks, and terrain detail meshes, along with several other Unity features to create a forest stream environment. The tutorial shows how everything is put together, and how the sample pack assets can be used together to create an environment.

Install the new sample assets using the Package Manager.

  1. In the Editor, open Package Manager.

Shader Graph Tutorial for Unity HDRP & URP | 2022 LTS (8)

2. In the Package Manager window, select the Shader Graph package.

Shader Graph Tutorial for Unity HDRP & URP | 2022 LTS (9)

3. Select the Samples tab.

Shader Graph Tutorial for Unity HDRP & URP | 2022 LTS (10)

4. Finally, select the Production Ready Import button to bring the new Production Ready sample set into your project.

With these steps completed, the node reference assets will show up in your project under Assets/Samples/Shader Graph/<your version>/Production Ready Shaders.

Shader Graph Tutorial for Unity HDRP & URP | 2022 LTS (11)

After importing the samples, get started by opening the scene that corresponds to the render pipeline you’re using (High Definition Render Pipeline,(HDRP), or Universal Render Pipeline (URP):

  • Assets/Samples/Shader Graph/<your version>/Production Ready Shaders/Scenes/URPProductionReadyShaders
  • Assets/Samples/Shader Graph/<your version>/Production Ready Shaders/Scenes/HDRPProductionReadyShaders

Shader Graph Tutorial for Unity HDRP & URP | 2022 LTS (12)

Once the scene is open, select the Shader Graph Feature Samples Showcase asset at the top of the Hierarchy panel, then follow the guided tour in the Inspector.

Shader Graph Tutorial for Unity HDRP & URP | 2022 LTS (13)

You can use the Samples dropdown box to select a sample and jump to that location in the scene.

Shader Graph Tutorial for Unity HDRP & URP | 2022 LTS (14)

Unity continues to add more samples to Shader Graph, with several more sample packs coming in the months ahead. These will help you learn Shader Graph more quickly, understand how to set up specific functionality, and create new shaders faster with premade subgraphs and templates. We hope you’ll enjoy using them.

This is a deep and rich sample set. We hope you have fun exploring it and use it to speed up your own shader creation process.

We’d love to hear your thoughts and impressions on these samples – tell us what you think in the Shader Graph forum.

Shader Graph Tutorial for Unity HDRP & URP | 2022 LTS (2024)

References

Top Articles
Latest Posts
Article information

Author: Wyatt Volkman LLD

Last Updated:

Views: 5917

Rating: 4.6 / 5 (66 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Wyatt Volkman LLD

Birthday: 1992-02-16

Address: Suite 851 78549 Lubowitz Well, Wardside, TX 98080-8615

Phone: +67618977178100

Job: Manufacturing Director

Hobby: Running, Mountaineering, Inline skating, Writing, Baton twirling, Computer programming, Stone skipping

Introduction: My name is Wyatt Volkman LLD, I am a handsome, rich, comfortable, lively, zealous, graceful, gifted person who loves writing and wants to share my knowledge and understanding with you.