-
-
Notifications
You must be signed in to change notification settings - Fork 28
Inverted Hull Outline
- In the project window, right click and select
Create/Toon RP/Extensions/Inverted Hull Outline
. - Go to your pipeline asset and add the newly created asset to the
Extensions
list.
Inverted hull outlines work by rendering the geometry a second time with geometry inflated along normals and front face culling. This is a very cheap effect suitable even for mobile devices.
A single asset of Inverted Hull Outline can render several passes with different parameters (color, thickness, layer mask, etc.).
The parameters of a pass are:
The name of the pass when displayed in Frame Debugger;
Outlines are rendered only for opaque objects. We can also specify a mask to limit the effect to particular objects only. For example, we can have layers like NoOutline
, RedOutline
, etc.
Sometimes it is not desirable to have outlines inside the geometry. To prevent drawing them inside geometry, we can enable a certain Stencil Layer
for the pass. We also have to set the same layer on the material used by geometry where we do not want inner outlines.
When rendering geometry itself, it will set a certain bit in the stencil bitmask. As a result, outlines are going to check for that bit and skip drawing pixels when it is is.
Because the outlines are rendered as any other geometry, their thickness is affected by perspective distortion. Fixed Screen Space Thickness
helps preventing that.
Fixed Screen Space Thickness Off | Fixed Screen Space Thickness On |
---|---|
For more stylization, we can add slight noise to the thickness of the outlines. Both amplitude and frequency need to be non-zero for this to work.
Noise Off | Noise On |
---|---|
If needed, provide a custom material here. Custom outline shaders can be creatd via Shader Graph or manually through code.
Selects where to get the normals for outlines from. See Normals Smoothing for more details.
📝 Note: this option was removed in favor of overriden materials. To vary thickness based on vertex color, create an Inverted Hull Outline shader graph and provide the necessary logic for the
Outline Thickness
vertex output.
This is useful when we want to vary the thickness inside a model, or completely prevent outlines on a particular piece of the model. This can be pained in any 3D modelling software or using the bundled Vertex Color Paint.
An additional depth bias, which can prevent unwanted outlines "leaking" through geometry.
Max Distance
control how far should the outlines be visible, Distance Fade
- how smoothly should they fade out.
Setting Max Distance
to 0 disables the distance limit.
By default, inverted hull outlines are also rendered during all pre-passes. If an outline pass needs to be excluded from some of them, it can be specified in this mask.
When enabled, you can specify a custom field of view for rendering the outlines. Used when there are geometries rendering with a custom field of view (e.g., weapons in first person view), and we want to have outlines for them too.
Here we have two passes:
- Thick, outer (stencil layer 7) and slightly noisy outlines;
- Thin, inner (no stencil layer) outlines.
Depending on the model's geometry, there can be discontinuities within outlines. This is especially a problem for flat shaded low-poly models.
Sometimes a solution might be as simple as smoothing normals in Unity: in import settings, change Normals
to Calculate
and set a high enough Smooting Angle
:
This, however, alters the lighting the model receives, which might not be acceptable. To solve this, we can write smoothed normals to a different vertex attribute (UV2 or Tangents). This way we get both the original lighting and perfectly smooth normals.
📝 Note: Tangents should be used for skinned meshes, since Unity computes them as well during skinning (thus, we will have correct normals even after applying bone animation). This, however, interferes with normal mapping since it also requires tangents. A more universal solution is to create a Shader Graph, which computes tangent vectors for normal mapping procedurally. However, it your game does not use normal maps, this is not necessary.
Toon RP provides two ways to do it:
- Add
=SmoothedNormals=
to the name of the model to mark it for smoothing; -
Optionally: add
=UV=
or=Tangents=
to specify the channel to write normals to;- By default, the channel is UV for usual meshes and Tangents for skinned meshes;
-
Optionally: specify a smoothing angle (e.g.,
=SmoothedNormals=90
for 90 degrees).
Example name:
Horse_=SmoothedNormals=Tangents=
.
A benefit of such approach is that if can change the model, new normals will be generated automatically on reimport.
This is an Editor window accessible via Window/Toon RP/Normals Smoothing Utility
.
Specify the mesh, smoothing angle, channel, click Compute Smoothed Normals
, and select a location to save a newly generated mesh.
📝 Note: the source model should have
Read/Write
enabled in the import settings.
To start painting vertex color:
- Create an asset:
Create/Toon RP/Vertex Color Paint
; - Specify the mesh;
- Click
Open Editor
.
This will open an Editor window with an ability to color, move, rotate, clear, and save the model.
Controls:
- Hold Right Mouse Button and move the mouse to rotate the camera;
- Hold Right Mouse Button and press W A S D to move the camera;
- Click the arrow buttons to rotate 90 degrees along different axes;
- Click Save to save and update to mesh asset.
Getting Started
Platform Support
Lighting and Shadows
- Global Ramp
- Shadows
- Variance Shadow Maps (VSM)
- Soft Shadows
- Additional Lights
- Additional Light Shadows
- Tiled Lighting (Forward+)
- Blob Shadows
- Fake Additional Lights
- Baked Lighting
Render Quality
Miscellaneous
Post-Processing
- Post-Processing Stack
- Bloom
- Inverted Hull Outline
- Screen-Space Outline
- SSAO
- Motion Blur
- Sharpen
- Light Scattering
Making Custom Shaders
Debugging