High Quality Line Rendering
Rendering line topology via traditional hardware rasterization, for example to represent hair or fur, can easily suffer from image quality problems.
Use the High Quality Line Rendering override to draw line geometry with analytic anti-aliasing and transparent sorting.
An example of hardware lines.
An example of high quality lines.
How High Quality Line Rendering works
The High Quality Line Renderer is a line segment software rasterizer designed for fast, high quality transparency and anti-aliasing.
Outlined below are the general steps of this raster algorithm.
- The camera's view frustum is divided into many clusters. A single cluster is 8 pixels wide by 8 pixels high. The length is derived from the Cluster Count.
- Each cluster computes a list of the visible line segments that intersect with it.
- Clusters are processed in front-to-back order. For each cluster, the segment list is unpacked and sorted from front-to-back, and the Sorting Quality determines the maximum amount of segments sorted in a single cluster.
- The sorted segment list is processed. For each segment pixel, HDRP computes the shading contribution, computes the analytically anti-aliased coverage mask, and blends the fragment behind the final tile result.
- HDRP computes the average opacity of the tile. If the average opacity is greater than the Tile Opacity Threshold, the tile is complete. A threshold lower than 1.0 can greatly improve performance.
- HDRP repeats steps 3 to 5 until all tiles have been processed.
Enable High Quality Line Rendering
To use this feature in your Scene, you must first enable it for your project and then enable it for your Cameras. To enable features in your project, you use the HDRP Asset and to enable features for your Cameras, you use Frame Settings. You can enable features either for all Cameras, using the Default Frame Settings, or for specific Cameras, by overriding each Camera's individual Frame Settings.
- To enable High Quality Line Rendering in your HDRP Asset go to Rendering > High Quality Line Rendering.
- To enable High Quality Line Rendering in your Frame Settings go to Edit > Project Settings > Graphics > HDRP Global Settings > Frame Settings (Default Values) > Camera > Rendering > High Quality Line Rendering.
Using High Quality Line Rendering
Once you've enabled High Quality Line Rendering in your project, follow these steps to render high quality lines in your scene:
- In the Scene or Hierarchy window, select a GameObject that contains a Volume component to view it in the Inspector.
- In the Inspector, navigate to Add Override > Rendering and select High Quality Lines. HDRP now applies High Quality Line Rendering to any Camera this Volume affects.
- In the Scene or Hierarchy view, select a GameObject that contains a Mesh Renderer component.
- In the Inspector, navigate to Add Component, then find and add the Mesh Renderer Extension component.
Unity warns you if there is any configuration issue with your GameObject that prevents High Quality Line Rendering:
- If you're warned about the Topology, ensure that the mesh connected to your MeshFilter component is composed of LineTopology.
- If you're warned about the Material, open your Material's shader graph and enable Support High Quality Line Rendering in the Master Stack.
You can use the Rendering Debugger to visualize the underlying data used to calculate the high quality lines.
Properties
Property | Description | |
---|---|---|
Composition Mode | Determine when in the render pipeline lines are rendered into the main frame. | |
Before Color Pyramid | Use this setting if you want lines to appear in transparency effects. | |
After Temporal Anti-Aliasing | Use this setting if you use Temporal Anti-Aliasing, so HDRP uses a stable depth buffer. | |
After Depth Of Field | Use this setting if the lines will be in focus against a blurrier scene. | |
Cluster Count | Set the number of clusters in a tile, between the camera's near and far plane. | |
Sorting Quality | Set the quality of the line rendering, which affects the maximum number of segments HDRP can sort within a cluster. The options are Low, Medium, High and Ultra. The higher the quality, the more memory high quality line rendering uses. | |
Tile Opacity Threshold | Set the opacity value that qualifies as an opaque tile. A threshold lower than 1.0 can greatly improve performance. |