BIRPからURPへ ― 移行に必要な情報をまとめて解説

2.7K Views

November 16, 26

スライド概要

profile-image

リアルタイム3Dコンテンツを制作・運用するための世界的にリードするプラットフォームである「Unity」の日本国内における販売、サポート、コミュニティ活動、研究開発、教育支援を行っています。ゲーム開発者からアーティスト、建築家、自動車デザイナー、映画製作者など、さまざまなクリエイターがUnityを使い想像力を発揮しています。

Docswellを使いましょう

(ダウンロード不可)

関連スライド

各ページのテキスト
2.

本資料に関する注意事項 本資料は、⼀般的な情報提供⽬的で作成されたものであり、本資料に記載したいかな る内容も、契約内容を構成するものではありません。 いかなる購買決定も、本資料に基づいてされることのないようにご注意ください。 本資料に記載したいかなる機能、コード、サービス内容についても、提供をお約束す るものではありません。 本資料に記載した製品、サービス、機能の開発およびリリース時期については、Unity の判断により決定され、変更の可能性があります。

3.

BIRPからURPへ ― 移行に必要な情報を まとめて解説

4.

Presentation Title ブーシェ ロビン晃 パートナーエンジニア

5.

Render Pipelineの将来 Agenda BIRP  URP移行 1. 動くようにする 2. 見た目を合わせる 3. 速くする

6.

Render Pipelineの将来

7.

URP → 今後の唯一の Render Pipelineに → ハイエンド向け機能の充実 ⎯ Screen Space Reflection ⎯ Surface Cache GI ⎯ Ground Truth AO ⎯ Auto Exposure ⎯ Volumetrics

8.

HDRP → Unity 7.0でDeprecate → 最初のUnity 7.x LTSまでサポート ⎯ 2027年末リリース予定 ⎯ 2029年までサポート ⎯ xLTSで2030年まで → 後のバージョンで完全削除

9.

BIRP → Unity 6.5でDeprecate → Unity 6.7 LTSまでサポート ⎯ 2026年末リリース ⎯ 2028年までサポート ⎯ xLTSで2029年まで → Unity 7で完全削除

10.

タイムラインまとめ 2026 2027 6.7 LTS リリース BIRP 最終バージョン 2028 7.x LTS リリース 7.0 BIRP削除 HDRP 最終バージョン 2029 2030 6.7 LTS xLTS終了 7.x LTS xLTS終了 BIRP サポート終了 HDRP サポート終了

11.

BIRPプロジェクトは早めに URPに移行しましょう!

12.

でも情報が散らかってて 何から始めればいいかわからない・・・

13.

BIRP  URP移行

14.

このセッションの目的 1. 移行のフローを解説 2. 資料がどこにあるか明確にする 3. 資料がない場合はサンプル提供

15.

まずはここから↓ BIRP  URP移行マニュアル Migrating from the Built-In Render Pipeline to URP

16.

移行の考え方 1. Make it work → 動くようにする 2. Make it look the same → 見た目を合わせる 3. Make it fast → 速くする

17.

1. 動くようにする 2. 見た目を合わせる 3. 速くする

18.

Render Pipeline Converter → BIRP標準シェーダーを URPシェーダーに差し替える → Post Processing V2エフェクトを URPのPost Processに差し替える → Quality Settingsレベルを 個別のURPアセットに変換する Render Pipeline Converter window for URP reference

19.

シェーダー変換 (一部) BIRPシェーダー URPシェーダー Standard Lit Legacy Shaders/... Particles以外) Mobile/... SimpleLit Particles/Standard Surface Particles/Lit Particles/Standard Unlit Particles/Unlit Sprites/... 2DRendererDataに設定されたシェーダー Unlitは変換されません。 手動で差し替えが必要

20.

Project Auditor → Migrate to URP項目を追加 → Render Pipeline Converterで 対応できないものなど、 問題点を洗い出してくれる Project Auditor 6.7

21.

migrate-birp-to-urp → BIRP  URP移行用の公式 AIエージェントスキル → URPプロジェクトセットアップ、標準シェーダー・ Post Processの変換、 ある程度の見た目合わせをやってくれる → カスタムシェーダー・ C#カスタムレンダリングコードは自動的に実行せず、洗い出しのみ https://github.com/Unity-Technologies/skills/blob/main/skills/migrate-birp-to-urp/SKILL.md

22.

カスタムシェーダー

23.

Surface シェーダー → URPにSurfaceシェーダーはない。 Vertex/Fragment構成のみ → まずはBIRP環境下でVertex/Fragment構成に書き直し、 BIRPで動くのを確認してから URPに移植するのを推奨 BIRP Surface Shader URP Vertex/Fragment Shader BIRPのVertex/Fragmentシェーダーサンプルはこちら → HLSL shader examples in the Built-in Render Pipeline URP Shader

24.

Light Mode Tag 比較 URP → BIRP → BIRP URP ForwardBase ForwardAdd UniversalForward/UniversalForwardOnly Deferred UniversalGBuffer Always カスタムパス SRPDefaultUnlit ShaderLab Pass tags in URP reference ShaderLab pass tags in the Built-In Render Pipeline reference

25.

ライト取得 → BIRPはMain light ForwardBase) とAdditional light ForwardAdd) でパスを分ける → URPはUniversalForwardパスでMain light・Additional light両方を処理する。 Additional lightはループ // Main light Light mainLight = GetMainLight(); // Additional lights (loop) uint additionalLightCount = GetAdditionalLightsCount(); for (uint lightIndex = 0; lightIndex < lightCount; ++lightIndex) { Light additionalLight = GetAdditionalLight(lightIndex); }

26.

MainTexture ・MainColor プロパティ → BIRP _MainTexture・_Color → URP _BaseMap・_BaseColor → Material.mainTexture・Material.color APIを使用している場合、 [MainTexture] [MainColor] タグをつけるように // BIRP _Color("Main Color", Color) _MainTex("Main Texture", 2D) // URP [MainColor] _BaseColor("Base Color", Color) [MainTexture] _BaseMap("Base Map", 2D) 見逃しやすいバグの原因に...

27.

Deferred → UniversalMaterialタグでLit相当とSimpleLit相当のライティングモデルを選択できる → G-buffer書き込みはUniversalGBufferパスで実装 → URPのG-bufferレイアウトはこちらを参照 G-buffer layout in the Deferred and Deferred+ rendering paths in URP Tags { "UniversalMaterialType" = "Lit" } // Lit or SimpleLit Pass { Tags { "LightMode" = "UniversalGBuffer" } }

28.

URPシェーダーでできないこと GrabPass → Frame bufferをテクスチャに書き出し、 後のシェーダーで参照できる機能 → URPではOpaque Texture機能で、 Opaque描画後のテクスチャを保持できる → TransparentはRenderer Featureが必要 DiscussionsにGrabPass移行のサンプルあり → https://discussions.unity.com/t/grabpass-and-multi-pass-shaders-in-urp/895625/17

29.

URPシェーダーでできないこと マルチパスシェーダー → BIRPはカスタムパスを複数記述すれば自動的に実行され、 マルチパスシェーダーを実装できる → URPは各レンダリングフェーズで決められたパスしか実行しない。 カスタムパスは実行されない → BIRPのようなマルチパスシェーダーは実装できない → Renderer Featureによる実装が必要

30.

シェーダー参考資料 BIRP  URPシェーダー移行マニュアル Unlitのみ) → Convert custom shaders for URP compatibility URPカスタムシェーダーマニュアル → Writing custom shaders in URP 座標変換・ライト取得・カメラ情報取得などのよく使う APIのサンプル → Shader methods in URP 過去の講演 → https://learning.unity3d.jp/8396/ URPカスタムシェーダー実装の詳細な解説あり SimpleLitシェーダーソースを 見るのもおすすめ!

31.

カスタムレンダリング

32.

カスタムレンダリング → BIRPのレンダリング APIは大部分が使えなくなっている → Camera.AddCommandBuffer、OnRenderImageなど → カスタムレンダリングは URPのRenderer Featureに移植する API比較はこちらを参照 → Render pipeline feature comparison とにかく全部 Renderer Featureにする!

33.

BIRP の実行モデル Object A → → → オブジェクトごとに シェーダーのパスを順番に実行する Forward Custom Pass カスタムパスはシェーダーに 追加することで自動的に実行される Draw Opaque マルチパスシェーダーを実装可能 Draw Transparent Skybox Post Process Object B Forward Custom Pass

34.

URPの実行モデル Object A Forward → → → → 各レンダリングフェーズで 実行するパスが決められている Render Pass) カスタムパスはフェーズの前後に Render Passを挿入して実行する Renderer Featureとは、 Render Passを挿入する仕組みのこと マルチパスは Render Passを 複数作ることで再現する Draw Opaque Object A Custom Render Pass 1 Custom Pass Skybox Draw Transparent Object B Custom Render Pass 2 Forward Post Process Object B Custom Pass

35.

例: Toon Outline URP Object BIRP Forward Object Draw Opaque Forward Outline Pass Outline シェーダーに Outlineパスを追加すれば 自動的にForwardパスの後に実行される Object Outline Renderer Featureを実装し、Opaqueの後に Outlineを実行するRender Passを挿入

36.

Blit もRenderer Feature で URP BIRP Draw Transparent OnRenderImage Graphics.Blit OnRenderImageなどでBlitを実行 Blit Pass Execute Blit Post Process Renderer Featureを実装し、任意タイミングに Blitを実行するRender Passを挿入

37.

よく使う機能の移行 OnPreRender・OnPostRender → RenderPipelineManager.beginCameraRendering・endCameraRendering カメラのRender TargetにBlit (OnRenderImage) → Full Screen Pass Renderer Feature 任意のシェーダーパスでオブジェクトを描画 → Render Objects Renderer Feature CommandBufferを実行 (Camera.AddCommandBuffer) → Renderer Featureに記述する とにかく全部 Renderer Featureにする!(x2)

38.

カスタムレンダリング参考資料 URPカスタムレンダリングマニュアル → Custom rendering and post-processing in URP Renderer Feature実装サンプル → Package samples reference for URP GrabPass実装サンプル → https://discussions.unity.com/t/grabpass-and-multi-pass-shaders-in-urp/895625/17 → Renderer FeatureとOpaque Texture機能を使った実装

39.

✔ 1. 動くようにする 2. 見た目を合わせる 3. 速くする

40.

このセクションのトピックに関しては 下記にサンプルプロジェクトを公開しているのでご参照ください https://github.com/robin-boucher/BIRP2URPComparison

41.

ライティング

42.

BIRP Distance Attenuation → Point・Spot lightの Falloff (距離減衰) の計算方法が異なる → BIRP Quadratic falloff → URP Inverse squared falloff → 同じIntensity値で見た目が異なる URP

43.

BIRP Light Falloff Mode → URPアセットのLighting設定で Light Falloff Modeを選択できる → Quadraticに設定すると BIRPと同じになる → _LIGHT_FALLOFF_QUADRATIC キーワードをシェーダーに追加 6.7 URP Light Falloff Mode = Quadratic)

44.

BIRP Unity 6.6 以前では → URPパッケージ改造で対応 → ShaderLibrary → RealtimeLights.hlsl → DistanceAttenuation関数 → DistanceAttenuation計算を BIRP準拠に差し替える 改造マニュアル → Change how lights fade using light falloff in URP ※ サンプルプロジェクトを参照 URP (改造)

45.

ライトマップも同様 → Unity 6.7ではLight Falloff Modeがライトマップにも適用される → Unity 6.6以前はパッケージ改造が必要 → Runtime → UniversalRenderPipelineCore.cs → FalloffType.InverseSquared → FalloffType.Legacy (= Quadratic) に変更 // lightData.falloff = FalloffType.InverseSquared; lightData.falloff = FalloffType.Legacy;

46.

BIRP Angle Attenuation → Spot lightのAngle処理が異なる → BIRP Outer angleのみ → URP Inner angle・Outer angle → Inner angle初期値は inner = 2 * atan(tan(outer / 2) * 46 / 64) → Falloff計算も異なるため、 見た目が少し違う URP

47.

BIRP のSpot Cookie → BIRPのSpot lightはデフォルトで Cookieを使う → unity default resourcesにある → URPのSpot lightに同じCookieを 設定すれば見た目を合わせられる ※ サンプルプロジェクトを参照 直接参照できないので スクリプトで摘出が必要

48.

BIRP Cookie のFalloff を再現? → Cookie画像のFalloffは (およそ) smoothstep(0.66, 0.99, r) → URPのAngle Attenuation計算を 改造してCookieを再現 → ShaderLibrary → RealtimeLights.hlsl → AngleAttenuation関数 ※ サンプルプロジェクトを参照 r 0.99 0.66

49.

Diffuse Specular BIRP Standard DisneyDiffuse Standard GGX URP/Lit Lambert Custom GGX Standard → URP/Lit 変換 → PBRライティング計算が異なる → URPの方が軽量だが、 見た目が異なる

50.

Standard → URP/Lit 変換 → パッケージ改造で Standardシェーダーの BRDFを URPに移植できる → Built-in Shaders Unity Download Archive) → CGIncludes → UnityStandardBRDF.cginc → Default 改造 URP → ShaderLibrary → BRDF.hlsl ※ サンプルプロジェクトを参照 AIに移植してもらうと楽

51.

カラースペースの注意点 → BIRPのシェーダープロパティに [Gamma] attributeがついており、 URPの同プロパティにない場合がある → Linearカラースペースでも プロパティ値が SRGB扱いされる → Linear時に見た目が異なる → URPのシェーダーを改造して [Gamma] をつけると同じにできる Standard [Gamma] _Metallic("Metallic", Range(0.0, 1.0)) URP/Lit _Metallic("Metallic", Range(0.0, 1.0))

52.

Post Processing V2 PPV2

53.

BIRP Color Grading → LDRモード時、同じ設定値でも色が異なる → BIRPで行っているSRGB/Linear変換が URPに含まれていない。 パッケージ改造で対応 → Shaders → PostProcessing → Common.hlsl → ApplyColorGrading関数 ※ サンプルプロジェクトを参照

54.

PPV2 パラメーター移植 → URPパッケージ → Editor → Tools → Converters → PPV2  EffectConverters → Render Pipeline ConverterがPPV2のパラメーターを URPに移植する際に、 値をどのように変換しているか確認できる

55.

✔ 1. ✔ 2. 動くようにする 見た目を合わせる 3. 速くする

56.

SRP Batcher → 同じシェーダーバリアントの マテリアルのドローコールをバッチ → シェーダーで対応が必要 → Dynamic BatchingはUnity 6.6でDeprecate Scriptable Render Pipeline SRP Batcher in URP パフォーマンスを出すには SRP Batcher対応が必須!

57.

SRP Batcher: SpriteRenderer シェーダー struct Attributes { half4 color : COLOR; }; struct Varyings { half4 color : COLOR; }; Varyings Vert(Attributes input) { Varyings output; output.color = unity_SpriteColor; // input.color return output; } Spriteカラーは unity_SpriteColor で取得する

58.

GPU Resident Drawer → GPUで効率的にMesh Instancingを行う → BatchRendererGroup APIを使用 → 大量のMeshRenderer描画の負荷を軽減する → シェーダーで対応が必要 マニュアル → GPU Resident Drawer → Batch Renderer Group

59.

Forward+ Renderer → ライト数が多い場合に有効 → 画面内のライトを効率的に取得 → 通常Forward Rendererのライトは 8 per objectまで → Forward+で無制限※に Clustered Forward Rendering) ※256 per camera Forward and Forward+ rendering paths in URP ライトが少ない場合は Forwardの方が軽い

60.

マルチカメラ → BIRPのマルチカメラ構成は URPで複数のBaseカメラにしてOK → Opaque Texture・Depth Texture・Post Processingは不要なら カメラごとの設定で OFFにするとRender Passを減らし、オーバーヘッドを軽減できる

61.

Camera Stacking → Camera Stackingはカメラごとにパスが増え、オーバーヘッドあり。 Renderer Featureでの実装を推奨 → 例: Overlay CameraのCanvasなど Camera Stacking Renderer Feature

62.

2Dプロジェクトの Renderer 選び → 2D Rendererを推奨 → Universal Rendererは3D用の Culling・Shadowパスなどを実行するため、 不要なオーバーヘッドになる → 2D Lightingが不要な場合 ⎯ Default Material Type = Unlit ⎯ Graphics Settings → Strip 2D Unused Variants 2D game development in URP

63.

Tile-only Mode → Tile-based GPUに特化させるモード → On-tileで実行できず、 追加パスを発生させる Render Passを すべてブロックする → 使える機能が制限される ⎯ 対象項目にWarningを表示 → 制限内に収めることができれば、 対応デバイスで描画をかなり効率化できる Reduce GPU bandwidth with on-tile rendering

64.

パフォーマンス参考資料 URPパフォーマンス最適化マニュアル → Graphics performance and profiling in URP ドローコール削減マニュアル → Optimizing draw calls in URP BIRPのQuality SettingsをURPに移植するガイド → Match the quality level performance of the Built-In Render Pipeline in URP

65.

e-Book https://unity.com/resources/introduction-to-urp-advanced-creators-unity-6

66.

サンプルプロジェクト Thank you