Unity Products:Amplify Shader Editor/Scriptable Rendering Pipeline

From Amplify Creations Wiki
Jump to: navigation, search

Product Page - Included Shaders - Manual - Shader Functions - Tutorials - API - Shader Templates - Scriptable Rendering Pipeline - Nodes - Community Nodes

Scriptable Rendering Pipeline

The Scriptable Rendering Pipeline is a new feature introduced in the 2018.1 beta and allows the configuring and performing rendering in Unity. For more information on the subject, please take a look at both the official blog post and forum thread.

Amplify Shader Editor is already supporting SRP through the usage of specific templates, but as it is still in beta, much can change and as such our approach may also need to change as well.

Available SRPs


Lightweight is a built-in Scriptable Rendering Pipeline aimed on optimized real time performance. Please check the official post for additional information.
This SRP can be used in Amplify Shader Editor through the LightweightSRP template.
NOTE: Current supported version Render-pipeline.lightweight v1.1.5.

Install Lightweight SRP into project

By default, no SRP is included when creating a new project.
In order to have Lightweight installed on the project, please go the Unity Package Manager and install it from there.

Now a Lightweight asset needs to be created on the project folder

The final step is to assign the newly created asset into the Scriptable Rendering Pipeline Settings over at the Project's Graphics Settings.

Importing Template

In order to avoid compilation issues with versions prior to 2018, the template is supplied in form of a Unity package located at the AmplifyShaderEditor > Plugins > EditorResources > Templates > SRP folder.

After extracting the template, ASE will automatically register it and make it available. It usually only takes a couple of seconds for the Unity Asset Database to kick and import the new shader into the project.
Now, this template will be among all other ones via the Create > Amplify Shader >SRP > Lightweight menu or changing your current shader directly on ASE through the Shader Type dropdown over the output node properties.

Please notice that when using a Lightweight shader, the Lightweight rendering pipeline must be correctly configured on the project.

Another important thing to consider is the template is built on top of a specific Lightweight SRP version which might not work with its previous versions. Current templates supports Render-pipeline.lightweight v1.1.5.

Output node

The shader, after created, will have the following layout containing a Lightweight output node:

Available Properties

Both the SubShader and Pass have their own properties that can be changed via the output node properties.

Common Properties
  • Shader Name: Editable text box, defines the name and path of the shader. Use a forward slash "/" to define its category and name; e.g. UserSamples/EnvironmentGradient. Note that the name displayed in this box is not the same as the filename, they have to be set individually.
  • Shader Type: This area displays the current shader type used. These include all the template currently available have in the project.
  • Shader Precision: Defines the precision of internal calculations, using lower types offers an added performance boost in exchange for some accuracy; set to Float by default.
  • SubShader: Non-editable field which species which SubShader this output belongs to
  • Pass: Non-editable field which species which Pass this output represents
  • Cull Mode: Front - Cull front-facing geometry, Back - Cull back-facing geometry, Off - Disables culling (double-side material); set to Back by default.
  • SubShader Tags: Allows the manipulation of subshader tags for shader rendering control. The pair RenderPipeline/LightweightPipeline is mandatory to be maintained as it tells Unity which SRP to use.
  • Name: Allows modification of current Pass name
  • Shader Model: Define current shader model. Higher shader compilation targets allow using more modern GPU functionality, but might make the shader not work on older GPUs or platforms.
  • Depth: Depth testing related properties
    • ZWrite Mode: Controls whether pixels from this object are written to the depth buffer (default is On). If you’re drawing solid objects, leave this on. If you’re drawing semitransparent effects, switch to ZWrite Off. For more details read below.
    • ZTest Mode: How should depth testing be performed. Default is LEqual (draw objects in from or at the distance as existing objects; hide objects behind them). ASE provides ZTest Less, Greater, LEqual, GEqual, Equal, NotEqual and Always.
  • Blend: Blend Operations related properties.
    • Blend RGB and Blend Alpha: When graphics are rendered, after all Shaders have executed and all Textures have been applied, the pixels are written to the screen. How they are combined with what is already there is controlled by the Blend command. ASE currently provides a Custom, Alpha Blend, Premultiplied, Additive, Soft Additive, Multiplicative and a 2x Multiplicative mode.
      • One: The value of one - use this to let either the source or the destination color come through fully.
      • Zero: The value zero - use this to remove either the source or the destination values.
      • SrcColor: The value of this stage is multiplied by the source color value.
      • SrcAlpha: The value of this stage is multiplied by the source alpha value.
      • DstColor: The value of this stage is multiplied by frame buffer source color value.
      • DstAlpha: The value of this stage is multiplied by frame buffer source alpha value.
      • OneMinusSrcColor: The value of this stage is multiplied by (1 - source color).
      • OneMinusSrcAlpha: The value of this stage is multiplied by (1 - source alpha).
      • OneMinusDstColor: The value of this stage is multiplied by (1 - destination color).
      • OneMinusDstAlpha: The value of this stage is multiplied by (1 - destination alpha).
  • SubShader Tags: Additional SubShader tags to be added on the current selected pass
  • Additional Defines: Additional #define instructions to be added to the current selected pass
  • Additional Includes: Additional #include instructions to be added to the current selected pass
  • Additional Pragmas: Additional #pragma instructions to be added to the current selected pass
Input Ports

Here's a brief description on each of its input ports:

  • Albedo: The Albedo parameter controls the base color of the shader surface, accepting either color values or texture maps.
  • Normal: Normal maps are a special kind of texture that allow the addition of surface details, such as shading information transferred from highpoly meshes, bumps, grooves and scratches. You may connect normal maps or custom normal vectors here.
  • Emission: Emission controls the color and intensity of light emitted from the surface, regardless of the lighting conditions; accepts full RGB values.
  • Metallic: Reflectivity and light response of the surface are modified by both Metallic and Smoothness levels; both grayscale inputs. You may use a range of values from 0 to 1, affecting the whole surface, or even connect a texture, which will control the Metallic values while providing different values for different areas of the surface; 0 being dielectric ( non-metallic ) and 1 full Metal.
  • Smoothness: A completely smooth surface at value 1 provides clear reflections, while a rough surface set to 0 creates a diffuse color with no clear reflections; It's also referred to as "Roughness" in some engines.
  • Occlusion: The Occlusion input accepts an occlusion texture map, or custom value, that's used to provide information about which areas of the model should display high or low indirect lighting, which comes from ambient lighting and reflections. The occlusion map is a grayscale image where white indicates areas that should receive full indirect lighting, while black indicates no indirect lighting.
  • Alpha: The Alpha input is responsible for setting the transparency of a surface as a whole, using a range of values between 0 and 1, from completely transparent to fully opaque respectively; accepts full RGB inputs.
  • Alpha Clip Threshold: Defines the threshold value to used on alpha clipping

Currently, two samples are also available on the package to exemplify the template's usage. Please notice that the Lightweight template shader must be unpacked before opening the samples graph. Like the template, both samples are also supplied through a Unity package called SRP Samples located at the AmplifyShaderEditor > Examples folder.

SRP Lightweight Coverage

SRP Lightweight GlintSparkle