天天看點

Scriptable Render Pipeline 可程式設計渲染管線Scriptable Render Pipeline 可程式設計渲染管線

Scriptable Render Pipeline 可程式設計渲染管線

  • 概述
    • 可以使用c#腳本定制渲染管線
    • 内置渲染和SRP不相容
      • shader不共用,因為shader lib不同

Pre-built SRPs

  • 概述
    • HDRP,LWRP
    • 可以和Shader Graph、Post-processing一起使用
    • HDRP和LWRP不相容,并且同時和built-in Render Pipeline不相容
  • High Definition Render Pipeline 高清渲染管線
    • 需要高端硬體支援,如主機、pc。可用來做高真實度渲染
    • 使用compute shader技術,故需要gpu支援
    • 案例:AAA遊戲、自動駕駛、建築等
    • 使用基于實體的渲染,支援前向渲染和延遲渲染
    • 最新文檔:https://docs.unity3d.com/Packages/[email protected]/index.html?preview=1
  • Lightweight Render Pipeline 輕量渲染管線
    • 對硬體要求不高,可以用在移動平台,并且渲染品質高
    • 使用簡化的基于實體的渲染
    • 使用單向前向渲染
    • 可以使用LWRP-VR來做VR功能,LWRP-VR和LWRP在預先做的設定上不同
    • 和内置shader不相容,需要更新工程
    • 最新文檔:https://docs.unity3d.com/Packages/[email protected]/index.html

Setting up a Scriptable Render Pipeline

  • Using a pre-built SRP with a new Project
    • 如果不需要定制,使用模闆建立新工程
  • Installing the latest SRP into an existing Project
    • 在已有工程裡使用SRP
    • 使用Package Manager system下載下傳資源,然後選擇安裝需要的資源
    • 轉換成SRP耗時,手動設定的地方多
  • Configuring and using a pre-built render pipeline 配置使用内置渲染管線
    • 使用内置渲染管線需要建立 Render Pipeline Asset
    • Creating Scriptable Render Pipeline Assets
      • Pipeline Assets中包含設定項,用于控制渲染品質
      • 建立渲染管線執行個體對象
        • 中間件資源
        • 渲染管線實作
      • 可以為不同平台和不同的測試環境建立不同的Pipline Assets
      • 因為使用不同的光照模型,HDRP和LWRP不相容
      • Create>Render Pipeline
    • Configuring and using HDRP
      • Edit>Project Settings - Player - Linear Color Space
        • not support gamma lighting
      • 建立Render Pipeline後 在Edit > Project Settings > Graphics
      • 把建立的Pipeline Asset拖上去
      • 在Scriptable Render Pipeline folder之外存儲建立的Pipeline Asset,保證HDRP settings和git上可以同步
    • Configuring and using LWRP
      • 類似上面的過程,換個名字
  • Creating a custom SRP
    • clone github上的,然後直接使用
    • 建立新工程或者加到已有的工程
      • 把github的資源放到Assets根目錄
      • 切換到相容目前所用的Unity版本的分支
      • 使用指令"git submodule update --init",為SRP添加子子產品
      • 更新Project manifest/dependencies,例如:
        {
          "dependencies": {
              "com.unity.postprocessing": "file:../ScriptableRenderPipeline/com.unity.postprocessing",
            
              "com.unity.render-pipelines.core": "file:../ScriptableRenderPipeline/com.unity.render-pipelines.core",
            
              "com.unity.shadergraph": "file:../ScriptableRenderPipeline/com.unity.shadergraph",
            
              "com.unity.render-pipelines.lightweight": "file:../ScriptableRenderPipeline/com.unity.render-pipelines.lightweight"
            
          }
        }
                   
      • 打開unity,可以開始debug和更改了