Convert URP template project to Hybrid Renderer V2 Tutorial

⚠️Hybrid Renderer is still a preview package – means it’s not stable, not production ready!

This tutorial goes through the process of converting the UniversalRP template project to use Hybrid Renderer V2. If you don’t know what Hybrid Renderer is, please visit official documentation.

This tutorial is using Unity 2020.2.3f1 + URP 10.2.2 + Hybrid Renderer 0.11.0-preview.42

Setup

Create New UniversalRP (URP) Project

  1. Download Unity 2020.2.3f1 or newer
  2. Create a new project with UniversalRP template
  1. You should see this

Install Hybrid Renderer Package

  1. TopMenu > Edit > ProjectSettings > Package Manager > Enable Preview Packages > Click “I understand”
  1. TopMenu >Window > Package Manager > Click the “+” icon > Add package from git URL >
    paste “com.unity.rendering.hybrid” > click Add
Installing this package will automatically install all the required DOTS packages e.g. Entities, Burst, Jobs, Collections
  1. Everything in project should still look the same. Console should have no errors.
    Some warnings are expected but can be ignored and cleared.

Hybrid Renderer V2

  1. TopMenu > Edit > ProjectSettings > Player > Scripting Define Symbols >
    put “ENABLE_HYBRID_RENDERER_V2” > click Apply
  1. Everything in project should still look the same at this stage!
  2. Close Unity
  3. On File Explorer, go to the Project Folder of your UniversalRP project > Delete Library folder
Library folder contains caches for shaders and other things that are loaded with Hybrid Renderer V1, as the project was created without the ENABLE_HYBRID_RENDERER_V2 define. So we want to make sure things are clean.
  1. Reopen the project, open SampleScene
  2. Everything in project should still look the same,
    but if you see this, close Unity and reopen project again
This is caused by a racing condition that Async Shader Compilation is still compiling shader (which uses a cyan shader as a temporary shader) while the scene has started re-baking lighting (Auto Lighting Generation is ON).

Convert Objects to Entities

Static batching

Static batching is not supported for hybrid rendering,
so we want to disable it on objects that we want to convert to entities.

You can turn off Static batching globally in ProjectSettings > Player > Static Batching checkbox, and skip the following steps.
The steps below allow us to only disable “Batching Static” flag without affecting other flags on the objects.

  1. On Hierarchy > “Example Assets” > select “Props
  2. On top right > Enable “Static” checkbox > Click “No, this object only”
  3. Click the little triangle > uncheck “Batching Static” > Click “Yes, change children”
  1. Disable “Static” checkbox on top right > Click “No, this object only”
    do it again to make sure the checkbox is disabled
  1. To verify if you’ve done this correctly,
    select Workbench_LOD0 and see if “Batching Static” is OFF for it
  1. On Hierarchy > “Example Assets” > select “Workshop Set
  2. Click the little triangle > uncheck “Batching Static” > Click “Yes, change children”
  3. Save the scene

ConvertToEntity component

  1. On Hierarchy > “Example Assets” > select “Props” > Add ConvertToEntity component
This component will convert GameObjects to Entities in runtime, useful when you are instantiating objects. Here we just want to experience the workflow.

Subscene

  1. On Hierarchy > “Example Assets” > select “Workshop Set”
  2. Right click > New Sub Scene > From Selection >Save it somewhere
“Workshop Set” will becomes a subscene object, and you are able to edit the contents by expanding it on Hierarchy
  1. Top Menu > Window > Rendering > Lighting > uncheck Auto Generate and click Generate Lighting
While subscene is opened, Generate Lighting will be able to generate lighting data to entities
  1. Ctrl + S to save the subscene and the SampleScene
  2. Click close on the Subscene object or disable the checkbox on the hierarchy
  1. Click close on the Subscene object or disable the checkbox on the hierarchy
Notice that you can no longer see the Workshop Set objects on Hierarchy. This is because closing Subscene will immediately convert GameObjects to Entities. Useful when you have existing scene objects like this.

Visual Check

  1. Save the scene
  2. Hit play
  3. It looks like this.
    It doesn’t look exactly the same before converting GameObjects to Entities because
    URP + HybridV2 only supports 1 realtime directional light in this version.
  1. Notice that on Hierarchy the Props objects are also disappeared and you can’t select them on scene. Because they are entities rendered with Hybrid Renderer now
  1. Check Console, there is a message saying “Hybrid Renderer V2 active”
  1. Exit play

Building Player

Install platform packages

  1. TopMenu >Window > Package Manager > Click the “+” icon > Add package from git URL >
    paste “com.unity.platforms.windows” > click Add
  2. If you need other platforms, add these packages
    • com.unity.platforms.macos
    • com.unity.platforms.ios
    • com.unity.platforms.android
      • For Android, make sure ProjectSettings > Player > set Graphics API to Vulkan only

Build Configuration

  1. On ProjectView > Right click > Create > Build > Windows Classic Build Configuration
  2. Select the configuration asset
  3. Add SampleScene to Scene List, click Apply, click Build and Run
Instead of using Edit > BuildSettings, we need this new Build Configuration asset because this will build Subscene entity caches into player. So that player build renders our Subscene objects correctly.
  1. Player should render the same as in the Editor
The errors in this pic come from the missing small paint bucket.
This is known issue in this version.

Live Link Mode

If you notice SceneView and GameView renders differently, it’s probably because of this setting.
See Entities documentation for details.

Want to learn more?

Feature support table – Check out Hybrid Renderer documentation.
Feature examples – Check out HybridHDRPSamples or HybridURPSamples.

⚠️Hybrid Renderer is still a preview package – means it’s not stable, not production ready!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s