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 Unity 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

Lightweight is a built-in Scriptable Rendering Pipeline aimed on optimized real time performance. Please check the official blog post for additional information.
This SRP can be used in Amplify Shader Editor through both the Lightweight PBR and Lightweight Unlittemplates.
NOTE: Current supported version render-pipeline.lightweight v3.0.0.

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 Templates

In order to avoid compilation issues with versions prior to 2018, two templates are supplied in form of a Unity package located at the AmplifyShaderEditor > Plugins > EditorResources > Templates > SRP folder, more specifically the LWSRPTemplates package.


After extracting the templates, ASE will automatically register them if a canvas window is opened, otherwise it will only happens them as soon as the window opens. It usually only takes a couple of seconds for the Unity Asset Database to kick and import the new shader into the project.
Two templates will made available, Lightweight PBR and Lightweight Unlit, and can be accessed via the Create > Amplify Shader menu. You can also change on your current shader directly when opened 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 templates are built on top of a specific Lightweight SRP version which might not work with its previous versions. Current templates supports Render-pipeline.lightweight v3.0.0.

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
SubShader
  • Cull Mode: Sets up which faces are to cull.
    • Front: Cull front-facing geometry
    • Back(Default): Cull back-facing geometry
    • Off: Disables culling (double-side material)
  • 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.
Pass
  • 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 Directives: Allows adding additional directives into current pass. Please note that each item is draggable.
    • Dropdown: Select what type of directive
      • Include: Directive is an Include ( prepends #include to the given value )
      • Define: Directive is a define ( prepends #define to the given value )
      • Pragma: Directive is a pragma ( prepends #pragma to the given value )
      • Custom: Value placed directly on code without any prepends
    • Value: Value to be associated with selected directive
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
  • Vertex Offset: Define an offset to be added to the current vertex position
  • Vertex Normal: Define a new value for current vertex normal
Samples

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



HD

HD is a built-in Scriptable Rendering Pipeline aimed on high end graphics. Please check the official blog post for additional information.
This SRP can be used in Amplify Shader Editor through both the HD PBR and HD Unlit templates.
NOTE: Current supported version render-pipeline.high-definition v3.0.0.

Install HD SRP into project

Like Lightweight, by default HD is not included when creating

In order to have HD installed on the project, please go the Unity Package Manager and install it from there.

[GIF]

After the package is imported, an High Definition Render Pipeline asset needs to be created on the project folder.

[GIF]

A Diffusion Profile settings Asset should also be created an set into the HD pipeline asset. This will control how effects like Subsurface Scattering behave.

[GIF]

Importing Templates

In order to avoid compilation issues with versions prior to 2018, two templates are supplied in form of a Unity package located at the AmplifyShaderEditor > Plugins > EditorResources > Templates > SRP folder, more specifically the HDSRPTemplates package.

[GIF]

After extracting the templates, ASE will automatically register them if a canvas window is opened, otherwise it will only happens them as soon as the window opens. It usually only takes a couple of seconds for the Unity Asset Database to kick and import the new shader into the project.
Two templates will made available, HD PBR and HD Unlit, and can be accessed via the Create > Amplify Shader menu. You can also change on your current shader directly when opened on ASE through the Shader Type dropdown over the output node properties.

[GIF]

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

Another important thing to consider is the templates are built on top of a specific HD SRP version which might not work with its previous versions. Current templates supports render-pipeline.high-definition v3.0.0.

Output node

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

[IMG]

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.
  • Material Type: Sets the current material behavior. HD has specific behaviors for different types of materials.
    • Subsurface Scattering
    • Standard (Metallic)
    • Specular
    • Anisotropy
    • Iridescent
    • Translucent:
  • 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.
  • Fallback: Sets a fallback shader from the available shaders in the project which will be used whenever a certain pass is either missing or not supported by the main shader.
  • Custom Editor: Custom inspectors allows you to use a custom material inspector, by default uses ASE custom material inspector.
  • SubShader: Non-editable field which species which SubShader this output belongs to
  • Pass: Non-editable field which species which Pass this output represents
  • Dependencies: Allow specification of shader dependencies. Commonly used on terrain shader to specify base and add shaders.
    • Name: Dependency name
    • Value: Dependency value, in case of terrains, the full shader name
SubShader
  • 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. Please notice that HD makes use of DX11 so shader model should 4.0 or higher.
  • Cull Mode: Sets up which faces are to cull.
    • Front: Cull front-facing geometry
    • Back(Default): Cull back-facing geometry
    • Off: Disables culling (double-side material)
  • 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: Allows the manipulation of subshader tags for shader rendering control. The pair RenderPipeline/HDRenderPipeline is mandatory to be maintained as it tells Unity which SRP to use.
Pass
  • Name:Allows modification of current Pass name
  • Stencil Buffer: The stencil buffer can be used as a general purpose per pixel mask for saving or discarding pixels. It's usually an 8 bit integer per pixel. The value can be written to, increment or decremented. Subsequent draw calls can test against the value, to decide if a pixel should be discarded before running the pixel shader. When Cull mode is set to OFF this menu shows an extra set of comparison selections to use the buffer separately from front faces and back faces.
    • Reference: The value to be compared against (if Comp is anything else than always) and/or the value to be written to the buffer (if either Pass, Fail or ZFail is set to replace). 0–255 integer.
    • Read Mask: An 8 bit mask as an 0–255 integer, used when comparing the reference value with the contents of the buffer (referenceValue & readMask) comparisonFunction (stencilBufferValue & readMask). Default: 255.
    • Write Mask: An 8 bit mask as an 0–255 integer, used when writing to the buffer. Default: 255.
    • Comparison (front and back): The function used to compare the reference value to the current contents of the buffer. Default: always.
    • Pass (front and back): What to do with the contents of the buffer if the stencil test (and the depth test) passes. Default: keep.
    • Fail (front and back): What to do with the contents of the buffer if the stencil test fails. Default: keep.
    • ZFail (front and back): What to do with the contents of the buffer if the stencil test passes, but the depth test fails. Default: keep.
  • Additional Directives: Allows adding additional directives into current pass. Please note that each item is draggable.
    • Dropdown: Select what type of directive
      • Include: Directive is an Include ( prepends #include to the given value )
      • Define: Directive is a define ( prepends #define to the given value )
      • Pragma: Directive is a pragma ( prepends #pragma to the given value )
      • Custom: Value placed directly on code without any prepends
    • Value: Value to be associated with selected directive
Input Ports

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

Common 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.
  • 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
  • Coat Mask: Attenuate the coating effect
  • Vertex Offset: Define an offset to be added to the current vertex position
  • Vertex Normal: Define a new value for current vertex normal
Subsurface Scattering / Translucent
  • Diffusion Profile: Specify the index for of the Diffusion Profile to use. A Diffusion Profile Settings asset must be created on the project and assigned to the HD Render Pipeline asset.
  • Thickness: Specify how transmission behaves. Low values allows some light to be transmitted through the object
Standard
  • 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.
Specular
  • Specular: Controls the strength and color tint of the specular reflectivity. This includes shine from light sources and reflections from the environment.
Anisotropy
  • Anisotropy: Anisotropy scale factor
Iridescent
  • Iridescent Thickness: Iridescent layer thickness
  • Iridescent Mask: Control intensity of iridescent
Samples

Under construction