NovaShader

Multi-functional shader for the Particle System that supports Universal Render Pipeline (URP) of Unity.

MIT License

Stars
1.1K

NOVA Shader: Uber shader for Particle System

Docs (English, ) | Samples (English, ) | Demo (English, )

NOVA Shader is a multi-functional shader for the Particle System that supports Universal Render Pipeline (URP). General-purpose functions commonly used in visual effects are implemented so you can create high-quality effects efficiently.

It implements some distinctive features like Flow Map, Flip-Book (sequential texture animation), Dissolve, Fade, Rotation, Animated Tint Map, Emission, Distortion, and so on.

For more information, please refer to the following documents, Samples and Demo.

Table of Contents

Setup

Requirements

This library is compatible with the following environments.

  • Unity 2021.3 or higher
  • Universal Render Pipeline
  • Shader Model 3.5

Note that Shader Model 4.5 is required to use Mesh GPU Instancing. And also, if you want to use Mirror Sampling, your hardware needs to support Inline Sampler States. And if you are using 3D Texture or 2D Texture Array, the compression format must support them.

And this document assumes that you have already set up the Universal Render Pipeline. For more information about the Universal Render Pipeline, please refer to the Unity Manual

Install

To install the software, follow the steps below.

  1. Open the Package Manager from Window > Package Manager
  2. "+" button > Add package from git URL
  3. Enter the following

Or, open Packages/manifest.json and add the following to the dependencies block.

{
    "dependencies": {
        "jp.co.cyberagent.nova": "https://github.com/CyberAgentGameEntertainment/NovaShader.git?path=/Assets/Nova"
    }
}

If you want to set the target version, write as follows.

Note that if you get a message like No 'git' executable was found. Please install Git on your system and restart Unity, you will need to set up Git on your machine.

To update the version, rewrite the version as described above. If you don't want to specify a version, you can also update the version by editing the hash of this library in the package-lock.json file.

{
  "dependencies": {
      "jp.co.cyberagent.nova": {
      "version": "https://github.com/CyberAgentGameEntertainment/NovaShader.git?path=/Assets/Nova",
      "depth": 0,
      "source": "git",
      "dependencies": {},
      "hash": "..."
    }
  }
}

Usage

Add Renderer Feature

First, set up the Renderer Feature to apply Distortion. Click Add Renderer Feature > Screen Space Distortion from the bottom of the Inspector of the ForwardRendererData asset.

Confirm that Screen Space Distortion has been added as shown below.

Note This setting is not necessary if you do not use the Distortion Shader.

Activate Depth Texture

Next, activate Depth Texture to use the Soft Particles or Depth Fade features. Check Depth Texture in the UniversalRenderPipelineAsset Inspector.

Depth Texture setting is also found in each Camera, so set it as necessary.

Note This setting is not necessary if neither Soft Particles nor Depth Fade is used.

Create and assign the Material

Next, create a material with the Nova shader. Create a material and set the shader to Nova/Particles/UberUnlit and assign a texture to the Base Map.

After creating a Particle System and assigning this material, you will see particles with the specified texture.

For more information on each shader and each function, see the sections below.

Uber Unlit Shader

The Uber Unlit shader is a multifunctional shader with no lighting applied. Use this shader for particles that do not need lighting, such as glowing effects.

To use this shader, assign the Nova/Particles/UberUnlit shader to your material. The following is the description of each property that can be set from the Inspector.

Render Settings

The Render Settings control how the Material is rendered.

Vertex Deformation

With Vertex Deformation, you can control the deformation of vertices.

Base Map

Base Map controls the base color texture and its settings.

Tint Color

Tint Color controls the color to be multiplied.

Flow Map

You can use the Flow Map to distort the Base Map to the specified directions.

  • Base Map
  • Tint Map
  • Alpha Transition Map
  • Emission Map

Parallax Map

Parallax Map can create a parallax effect.

Color Correction

Color Correction correct the colors up to this point.

Alpha Transition

Alpha Transition controls the alpha value using a texture.

Emission

The Emission control how the particles are glowing.

Transparency

Control the transparency in various ways.

Uber Lit Shader

The Uber Lit shader is a multifunctional shader with lighting applied. Use this shader for particles that need lighting, such as mesh effects. This shader reflects lighting compliant with Unity's PBR lighting specification.

To use this shader, assign the Nova/Particles/UberLit shader to your material. This shader is based on the Uber Unlit shader with additional processing and properties.

The description of the added properties is as follows.

Render Settings

The following red-framed properties have been added to Render Settings.

Surface Maps

Several surface properties have been added for lighting.

Set up the metallic map.The specifications of the metallic map are as follows.

Set up the specular map. The specifications of the specular map are as follows.

Distortion Shader

Using the Distortion shader, you can apply distortion effects to the screen, such as heat waves.

To use this shader, assign the Nova/Particles/Distortion shader to your material. The following is the descriptions of each property that can be set from the Inspector.

Render Settings

The Render Settings control how the Material is rendered.

Distortion

Distortion controls how it is distorted.

Flow Map

You can use the Flow Map to distort the Distortion Map to the specified directions.

Alpha Transition

Alpha Transition controls the alpha value using a texture.

Transparency

Control the transparency in various ways.

Abort Shadow Caster

Enabling the Shadow Caster feature will allow you to cast shadows from NovaShader.

Uber Unlit/Lit shaders( for uGUI )

Uber Unlit/Lit shaders are available for uGUI. if you want to play the effect on uGUI, use Nova/UIParticles/UberUnlit or Nova/UIParticles/UberLit.

The items that can be set in the material inspector are basically the same as for the regular UberUnlit and UberLit, but note that the z and w elements are not available when working with Custom Vertex Streams. This is because z and w data are discarded inside uGUI.

If z and w are used, an error will be displayed as shown in the following figure.

Use with the Custom Vertex Streams

Using the Particle System's Custom Vertex Streams, you can animate the properties of the Material. In the following example, we will use the Custom Vertex Streams to rotate the texture.

Set up the Custom Data

First, set up the Particle System's Custom Data. In this case, we have set a value that changes from 0 to 1 over time to Custom1.X.

Set up the Custom Vertex Streams

Next, set the Custom Vertex Streams as shown below to pass Custom1.x to TEXCOORD1.x.

Set up the Material Property

Next, select COORD 1X from the Rotation dropdown to use the value passed to TEXCOORD1.x as shown below.

The texture will now rotate.

Use Mesh GPU Instancing

You can use the Particle System Mesh GPU Instancing to draw particles efficiently. The following section describes how to use Mesh GPU Instancing for materials using this shader.

Note When displaying particles on the preview screen using PreviewRenderUtility, we have confirmed a bug on the Unity side that does not render correctly when Enable Mesh GPU Instancing is enabled.

Enable Mesh GPU Instancing

To use Mesh GPU Instancing, you need to set the Render Mode of the Renderer module to Mesh. Then, check the Enable Mesh GPU Instancing checkbox.

Set up the Custom Vertex Streams

Next, set up the Custom Vertex Streams as shown below.

The Custom Data section can be filled with values from other modules, such as Noise, but make sure that all of INSTANCED1.xyzw and INSTANCED2.xyzw are filled without excess or deficiency.

Now you can use Mesh GPU Instancing.

Automatic set up the Custom Vertex Streams.

We have seen several cases where Custom Vertex Streams are set up manually. In addition, the vertex streams required by the GPUs vary depending on their settings.

It has a feature that automatically set up the Custom vertex streams as Fix Now.

Fix Now

If vertex streams are different from what the CPUs require, Fix Now button and error will appear at bottom of the inspector.

At this time, pressing this button will automatically set the typical vertex stream needed.

If you are not familiar with setting up Custom Vertex Streams, It is recommended that you use Fix Now to correct errors to avoid unwanted errors.

Editor APIs Reference

Licenses

This software is released under the MIT license. You are free to use it within the scope of the license, but the following copyright and license notices are required.

In addition, the table of contents for this document has been created using the following software

See Third Party Notices.md for more information about the license of toc-generator.