1. 程式人生 > >關於The Lab Render不能在Unity 2017版本中使用的解決辦法

關於The Lab Render不能在Unity 2017版本中使用的解決辦法

The Lab Render自2016年上線以來就沒有再進行更新,版本號仍停留在1.0,導致隨著Unity版本的升級,API的更新,使得這款渲染器在Unity後期版本中總會出現不能正常執行的問題。

對於Unity 2017,需要對The Lab Render做更多的修改,現整理如下:

  1. 匯入完畢以後,會報錯3處錯誤,只修改兩處即可,雙擊錯誤提示,定位到報錯的檔案ValveAutoUpdateSettings.cs,修改兩處程式碼,

    將
    var devices = UnityEditorInternal.VR.VREditor.GetVREnabledDevices(BuildTargetGroup.Standalone);
    
    改為
    var devices = UnityEditorInternal.VR.VREditor.GetVREnabledDevicesOnTargetGroup(BuildTargetGroup.Standalone);
    
    將
    UnityEditorInternal.VR.VREditor.SetVREnabledDevices(BuildTargetGroup.Standalone, newDevices);
    
    改為
    UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(BuildTargetGroup.Standalone, newDevices);
    
    

  2. 修改vr_lighting這個shader,此處也是2017版本之前遇到的問題,即陰影不顯示

    將
    float objDepth = ( vPositionTextureSpace.z );
    
    改為
    float objDepth = 1 - vPositionTextureSpace.z ;
    
  3. 儲存,嚴格按照文件中列出的五步進行設定,渲染器即可正常執行。

歡迎關注我的微信公眾號:XR技術研習社