(03) Unity HTC VRTK development record based on URP

Table of contents

1 Introduction

2. Use VRTK and URP in the project

    1) Create URP rendering pipeline

    2) Use URP rendering pipeline

    3) Upgrade project material

    4) Handle settings

    5) Use Volume post-processing

    6) Camera settings

 3. Other questions


1 Introduction

       The main content of this article is: how to combine URP with VRTK, what needs to be paid attention to in URP, and the functions of VRTK.

       Because the project itself requires rendering with better image quality, Unity's default rendering pipeline Built-in is abandoned and URP is used for rendering. Of course, HDRP can also be selected, but considering that the later project may be released in OpenGL rendering mode, Finally decided to use URP just in case. This article does not introduce separately VRTK and URP. You can refer to Baidu for their specific functions.

Version Information:

  • Unity 2019.4.10
  • Kindergarten 3.3
  • SteamVR 1.2.3
  • URP 7.3.1

2. Use VRTK and URP in the project

       Personally, it is recommended to import the VRTK and SteamVR packages first, and then import the URP package, because importing VRTK and SteamVR itself together may cause bugs, and importing URP separately may also cause some problems. It is also good to make sure that the VR plug-in is OK before importing the URP package. Where is the positioning problem?

       After all imports are completed, some URP settings need to be made. If you create a URP project directly in Unity Hub, you can ignore this step.

    1) Create URP rendering pipeline

        Right-click on Assets—Create—Rendering—Universal Render Pipeline—Pipeline Asset (Forward Renderer). After clicking, two URP rendering pipeline resources are automatically generated in Assets.

    2) Use URP rendering pipeline

        Add the new URP pipeline resource in Editor—Project Settings—Graphics.

    3) Upgrade project material

        The last step is to upgrade all materials in the project to URP materials in Edit-Render Pipeline-Universal Render Pipeline-Upgrade Project Mat....

    4) Handle settings

       In the previous step, all the materials of the project have been upgraded. There is no problem in observing in the Scene view. However, after running the helmet, it is found that the handle material is still unrecognizable.

       This is because the handle model is dynamically loaded after the project is run, so you need to set the handle's Shader to URP/Lit in the non-running state, or you can write a delay method to dynamically set the handle material after running. (All basic materials of projects involving URP will be replaced from Standard to Lit)

    5) Use Volume post-processing

       Right-click in the Scene view—Volume—Global Volume to create a Volume.

After the creation is completed, you can add various post-processing effects under the Volume script. Please refer to Volume for details        on what effects these options can produce. Although it is HDRP, the post-processing effect options HDRP and URP are almost the same.

     6) Camera settings

       At this step, I found that after adding the post-processing component, I can observe the changes in the Scene view, but the helmet still runs as if it has not been adjusted. This is because the Camera component will be rewritten after the URP is imported, and you need to select URP rendering in the Renderer in the Camera. and check Post Processing.

 3. Other questions

       I need to use the highlighting effect in my project. I found a problem with the HighlightingSystem I had been using before. It should be that it does not support URP. I didn’t find out the specific reason, so I just changed to a highlighting plug-in that supports URP: Highlight Plus 9.1.1. After the free resource links are imported, some settings still need to be made.

       1. After importing the plug-in, you need to run HighlightPlus_URP_Pipeline.unitypackage to import the URP package.

       2. After the import is completed, the code reports an error. You need to modify the code of the HighlightPlusRenderPassFeature.cs script.

       3. Add the Highlight Profile to the function list of Forward Renderer in the Universal Render Pipeline Asset. At this URP, you can use the Highlight Plus highlight plug-in normally.

       If you need to add an effect plug-in later, you must add the plug-in's corresponding configuration file to the URP's forward renderer (Forward Renderer). This plug-in description is used as a case reference.

Guess you like

Origin blog.csdn.net/qq_42047805/article/details/132110370