{"action":"opened","issue":{"url":"https://api.github.com/repos/NaClYen/blog/issues/8","repository_url":"https://api.github.com/repos/NaClYen/blog","labels_url":"https://api.github.com/repos/NaClYen/blog/issues/8/labels{/name}","comments_url":"https://api.github.com/repos/NaClYen/blog/issues/8/comments","events_url":"https://api.github.com/repos/NaClYen/blog/issues/8/events","html_url":"https://github.com/NaClYen/blog/issues/8","id":355899855,"node_id":"MDU6SXNzdWUzNTU4OTk4NTU=","number":8,"title":"Unity - The Lightweight Render Pipeline: Optimizing Real Time Performance","user":{"login":"NaClYen","id":10209536,"node_id":"MDQ6VXNlcjEwMjA5NTM2","avatar_url":"https://avatars0.githubusercontent.com/u/10209536?v=4","gravatar_id":"","url":"https://api.github.com/users/NaClYen","html_url":"https://github.com/NaClYen","followers_url":"https://api.github.com/users/NaClYen/followers","following_url":"https://api.github.com/users/NaClYen/following{/other_user}","gists_url":"https://api.github.com/users/NaClYen/gists{/gist_id}","starred_url":"https://api.github.com/users/NaClYen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NaClYen/subscriptions","organizations_url":"https://api.github.com/users/NaClYen/orgs","repos_url":"https://api.github.com/users/NaClYen/repos","events_url":"https://api.github.com/users/NaClYen/events{/privacy}","received_events_url":"https://api.github.com/users/NaClYen/received_events","type":"User","site_admin":false},"labels":[{"id":944302598,"node_id":"MDU6TGFiZWw5NDQzMDI1OTg=","url":"https://api.github.com/repos/NaClYen/blog/labels/done","name":"done","color":"7bf299","default":false}],"state":"open","locked":false,"assignee":{"login":"NaClYen","id":10209536,"node_id":"MDQ6VXNlcjEwMjA5NTM2","avatar_url":"https://avatars0.githubusercontent.com/u/10209536?v=4","gravatar_id":"","url":"https://api.github.com/users/NaClYen","html_url":"https://github.com/NaClYen","followers_url":"https://api.github.com/users/NaClYen/followers","following_url":"https://api.github.com/users/NaClYen/following{/other_user}","gists_url":"https://api.github.com/users/NaClYen/gists{/gist_id}","starred_url":"https://api.github.com/users/NaClYen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NaClYen/subscriptions","organizations_url":"https://api.github.com/users/NaClYen/orgs","repos_url":"https://api.github.com/users/NaClYen/repos","events_url":"https://api.github.com/users/NaClYen/events{/privacy}","received_events_url":"https://api.github.com/users/NaClYen/received_events","type":"User","site_admin":false},"assignees":[{"login":"NaClYen","id":10209536,"node_id":"MDQ6VXNlcjEwMjA5NTM2","avatar_url":"https://avatars0.githubusercontent.com/u/10209536?v=4","gravatar_id":"","url":"https://api.github.com/users/NaClYen","html_url":"https://github.com/NaClYen","followers_url":"https://api.github.com/users/NaClYen/followers","following_url":"https://api.github.com/users/NaClYen/following{/other_user}","gists_url":"https://api.github.com/users/NaClYen/gists{/gist_id}","starred_url":"https://api.github.com/users/NaClYen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NaClYen/subscriptions","organizations_url":"https://api.github.com/users/NaClYen/orgs","repos_url":"https://api.github.com/users/NaClYen/repos","events_url":"https://api.github.com/users/NaClYen/events{/privacy}","received_events_url":"https://api.github.com/users/NaClYen/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2018-08-31T09:08:20Z","updated_at":"2018-08-31T09:08:20Z","closed_at":null,"author_association":"OWNER","body":"#### [原始文章](https://blogs.unity3d.com/2018/02/21/the-lightweight-render-pipeline-optimizing-real-time-performance/) by Tim Cooper, February 21, 2018\r\n\r\n> [在上一篇文章](https://blogs.unity3d.com/2018/01/31/srp-overview/)中, 我們介紹了`Scriptable Render Pipelines`. 簡單來說, SRP可以讓使用者用C#腳本, 去控制Unity如何繪製一個畫面. 我們將會隨著 2018.1 釋出兩內建的渲染管道(render pipelines): `Lightweight Pipeline`和`HD Pipeline`. 在這篇文章中, 我們將重點放在`Lightweight Pipeline`或稱`LW RP`.\r\n\r\n透過將渲染管道曝露給C#, 用來達到減少Unity中的渲染的黑盒作業的目標, 讓使用者可以明確地控制渲染的過程. 開發者可以使用我們提供的內建渲染管道 or 全部自己來 or 從修改內建管道開始.\r\n\r\n我們發布了一個影片, 簡述 `Scriptable Render Pipeline` 的概念, 包含一些使用到不同管道的專案的鏡頭:\r\n{%youtube 2wUPgl7upnU %}\r\n\r\nLWRP的目標是透過在光照和著色上權衡, 提供性能受限的平台最佳化的實時效能.\r\n\r\nLWRP的目標族群是開發大眾移動裝置(相對於限定高階機種) or VR or 開發需限制實時光照遊戲的開發者們. LWRP使用單一pass的`forward rendering`, 他只有一個實時陰影光照(realtime shadow light)和逐物件的光照剔除, 帶來所有燈光可以在一個pass中計算完成的優點. 與傳統的管道會為範圍內的 pixel light 增加額外的 pass 相比, 因此LW管道最終會使用較少的 draw calls. 這是以犧牲一些會處理更多光源的著色複雜度換來的. 我們的 Shader Graph 工具也又支援 LWRP, 這將會為編輯著色器的流程帶來一些額外的好處.\r\n\r\n![](https://blogs.unity3d.com/wp-content/uploads/2018/02/image3-2.png)\r\n\r\n## Lightweight Shaders\r\n\r\nLWRP 有自己的處理渲染的過程, 因此在編輯 shader 時要銘記在心. 我們開發了新的一組 Standard Shaders 被放在 material 下拉選單中的 `Lightweight Pipelin` 群組內. 他們包含了 `Standard PBR shader` & `搭配簡易光照模組的 non PBR Standard shader` & `Standard Terrain shader` & `Standard Unlit shader`. 值得注意的是, 所有 Unity 內建 unlit shaders 都已經是搭配 LWRP 的方式在運作. 這包含傳統的粒子特效, UI, skybox  以及 sprite shader.\r\n\r\n![](https://blogs.unity3d.com/wp-content/uploads/2018/02/image1-5.png)\r\n\r\nLWRP 也提供升級工具來自動轉換使用 Unity 內建 shader 的 material, 轉用相容的 LWRP shaders. 如要升級 material, 執行 `Edit -> Render Pipeline -> Upgrade -> Lightweight`. 你可以選擇升級整個專案或是被選到的 materials.\r\n\r\n![](https://blogs.unity3d.com/wp-content/uploads/2018/02/image4-3.png \"Material Upgraders\")\r\n\r\n## The Render Pipeline Asset\r\n\r\n若要設定目前使用的渲染管道, 可到 `Graphics Settings` 中 `Scriptable Render Pipeline Settings` 配置管道資源(pipeline asset). 它也可以透過腳本 `GraphicsSettings.renderPipelineAsset` 配置.\r\n\r\n除了在一開始就選定整體的渲染方式之外, 也可以在相同類型的渲染管道但不同實例(instance)之中, 儲存多個品質設定(quality settings). 管道資源控制全域的渲染品質設定, 並負責產生管道實例. 管道實例涵蓋中介資源以及渲染的實作.\r\n\r\n![](https://blogs.unity3d.com/wp-content/uploads/2018/02/image5.jpg)\r\n\r\n## Lightweight Rendering\r\n\r\nLWRP 的渲染功能主要是內建渲染的子集合. 為了在性能受限的平台提高性能, 替除了某些功能. Unity 為開發人員提供了廣泛的工具和技術, 用以應用在他們的遊戲之中. 這樣做的風險是有時候會將錯誤的技術套用在沒有相應資源的遊戲內而無法支援. 提供專用的渲染管道模板的目的是為了減輕使用者犯下某些代價高昂錯誤的可能性. 例如, 為目標平台部屬不適當的後處理特效(post processing effects)可能會導致遊戲在某些設備卡頓, 即使這些特效是 Unity 所支援並且可以在正確的平台上執行的.\r\n\r\n實時全域照明(realtime global illumination)是另一個在效能受限的平台較為少用的功能, 因此也被移除. 唯一支援的渲染途徑(rendering path)是 `single-pass forward`, 這是另一個效能重於複雜度的決定. 下面這張表格提供了那些技術是被內建管道支援, 哪些是被LWRP支援的細節.\r\n\r\n!!!\r\n[原始表格的格式在這裡無法重現, 請至原網址觀看](https://blogs.unity3d.com/2018/02/21/the-lightweight-render-pipeline-optimizing-real-time-performance/)\r\n!!!\r\n\r\n## Customizing The Lightweight Pipeline\r\nSRP 架構難以置信的潛力在於它比 Unity 以前的作法帶來更開放更可自訂性的渲染流程. 如果要查看 LWRP 的原始碼, 可至 SRP 的 [github](https://github.com/Unity-Technologies/ScriptableRenderPipeline/issues) 頁面. 在那裏可以取得 LWRP 的C#原始碼, 並開始修改以創建一個適合你的專案的管道(pipeline). 如果你遇到任何問題, 我們很樂意透過 github 了解它們, 也期待從 [beta forum](https://forum.unity.com/threads/feedback-wanted-lightweight-render-pipeline.518267/) 得知.\r\n\r\n##### translate by NaCl at 2018/08/31\r\n\r\n最近在嘗試一個共筆系統[HackMD](https://hackmd.io/), 和這裡的相容性很高, 編輯器做得很不錯, 可以試試~\r\n[本篇的 HackMD版](https://hackmd.io/s/BJk79LIwm)"}}
{"actor":{"display_login":"NaClYen"}}