SlideShare ist ein Scribd-Unternehmen logo
1 von 65
LWRPのパス拡張について
伊藤 和樹
プロフィール
 伊藤 和樹
 某スマホゲーム会社にて新規タイトルの開発中
 主な仕事は
LWRPの子守(verUP・保守・拡張)
シェーダをゴニョゴニョする
1
アジェンダ
 LWRPのパス拡張(v3.0.0~v3.2.0)
 LWRPのパス拡張(v3.3.0~)
 カメラスタッキングが使えない!?ならば改造すれば良いじゃない
2
みなさんご存知かとは思いますが、、
3
LWRPはフォワード1パスしか描けない
4
5
とはいえ、
v4番台までPreview版なので
文句は言えない、、
6
大人しく拡張していきましょう
7
今回の検証に使うシェーダ 8
検証には R -> G -> B の順で単色を表示するだけのシェーダを使用
91パス目
102パス目
113パス目
LWRPに手を加えずに表示 12
1パス目のRedのみ描画
LWRPのパス拡張(v3.0.0~v3.2.0)
 追加するパス
 セットアップクラス
13
必要なもの
追加するパス
 ScriptableRenderPassを継承したクラスを実装
 Runtime/Passes以下にあるクラスをみて参考にすると良い
14
15
16
ScriptableRenderPass を継承し、描画時に実行される Execute を実装する
※赤線が出てますがUnity上ではエラーは出ず問題なく動作します。
 MonoBehaviourを継承&IRendererSetupインターフェイスを
実装したクラスを用意する
17
セットアップクラス
18
Setupメソッドを実装
(LWRPのDefualtRendererSetupをコピー&ペーストしてSetupメソッド改造した方が良いです)
※Setupメソッドはカメラ毎に呼び出されます
19
カメラに作成したRendererSetupをアタッチ
拡張後の表示 20
3パス目のBlueまで描画
LWRPのパス拡張(v3.3.0~) 21
必要なもの
 追加するパス
 パスを差し込むコンポーネント
追加するパス 22
V3.0.0〜v3.2.0で紹介した内容と同じの為割愛します。
パスを差し込むコンポーネント
実装するインターフェイスによって差し込まれるタイミングが変わります
 IBeforeCameraRender
 IAfterDepthPrePass
 IAfterOpaquePass
 IAfterOpaquePostProcess
 IAfterSkyboxPass
 IAfterTransparentPass
 IAfterRender
23
24
Pipeline標準のRenderTexure設定情報と
描画内容を読み書き出来るハンドルがColorとDepthで引数に渡されます。
※IAfterRenderのみ引数は無く描画内容の取得・書き込みが出来ません
(CommandBufferの代わりくらいの感覚で大丈夫かと思います)
25
GetPassToEnqueueメソッド内で自作したパスのインスタンスの作成と初期化をし、
戻り値として返却。
26
カメラに作成したコンポーネントをアタッチ
拡張後の表示 27
3パス目のBlueまで描画
パスを追加する上での注意点
LWRPではサポートしているUnlitの旧シェーダ以外、
パスの記述順は考慮されません。
LWRP向けシェーダではLightModeで判別をしている為、
パスの描画順がランダムになったり
1シェーダ内に同一LightModeが複数ある場合描画を行わなかったりします。
(バージョンによってどちらかの挙動します)
28
ここからは
カメラスタッキング
についてお話しします
29
30ワールドカメラ + UIカメラ
UIにフグ・ワールドにCubeを置いています
カメラスタッキングが使えない!?
ならば改造すれば良いじゃない
31
32
33
とはいえ、
どうしても使いたい時ありますよね…?
34
35
まずクリアフラグを改造
クリアフラグの置換
36
カメラのクリア設定をLWRPのクリアフラグに変換するメソッド実装
37
実装したメソッドに差し替え
38Opaqueの最初のパスの改造
パスクラス内にあるExecuteメソッドで描画の対象のRenderTextureを設定してしる箇所がある
39
ClearFlagからColorのRenderTextureを返すメソッドを実装
40
ColorとDepthのRenderTextureの読み込みオプションを書き換え
RendererSetupを改造 41
DefualtRendererSetupをコピー&ペーストして適当なクラス名やネームスペースを切る
(既に独自のSetupクラスを実装済みの場合以外)
42
作成したパスに置き換え
43
ワールドカメラの内容も無事表示されました
これで終わり
44
…ではありません
45
カメラスタッキングを使う
すべてのカメラにSetupをアタッチするの
めんどくさくないですか?
46
(それに今回はMonoBehaviour継承してない)
すべてのカメラでスタッキングを有効化する為、
PipelineAssetも改造しましょう
47
PipelineAssetの改造 48
LightweightRenerPipelineAssetを継承したクラスを作成し、
InternalCreatePipelineメソッドをオーバーライド
49
PipelineAsset作成周りのメソッドを実装
50
Actionメソッドを改造したPipelineAssetを生成するように変更
51
CreateLightweightPipelineメソッドのMenuItemを適当なメニュー名に変更し、
生成するインスタンスを改造したAssetに変更
52
LoadResourceFileメソッドはLightweightRenderPipeAssetのものをコピー&ペースト
PipelineAssetEditor 53
LinghtweightRenderPipelineAssetEditorを継承し、
CustomEditorの対象を改造したAssetクラスに変更
54
標準のLightweightRenderPipelineAssetと同じ見た目になり設定しやすく
CameraEditor & LightEditor 55
PipelineAssetに設定したHDR・MSAA・Depth Texture・Opaque Textureの値が利用出来るように
56
PipelineAssetに設定したShadow Biasの値が利用出来るように
57
LightweightRenderPipelineCameraEditorと
LightweightRenderPipelineLightEditorをコピー&ペーストし、
CustomEditorForRenderPipelineの対象を改造したAssetに変更
おまけ
58
開発中プロジェクトのLWRP移行について 59
移行の際、既存のシェーダの対応作業が発生すると思いますが、
念の為既存のシェーダを残して
LWRP対応シェーダを作成する事をおすすめします
60
マテリアル数が多い場合シェーダ差し替えはツールを使うと楽です。
https://github.com/Itoen/ShaderReplacer
デザイナーがShade Forgeを使用している場合、
LWRP非対応のためAmplify Shader Editorに移行しましょう
61シェーダのビジュアルスクリプティングツールについて
Amplify Shaderの標準LWRPテンプレート 62
PBRとUnitのシェーダテンプレートが用意されてます
Amplify Shader軽量LWRP対応テンプレート 63
https://github.com/Itoen/ASE-LWRP
シャドウ以外のライティング処理を省いたテンプレートを用意してます
ご静聴ありがとうございました
64

Weitere ähnliche Inhalte

Empfohlen

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Empfohlen (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

LWRPのパス拡張について

Hinweis der Redaktion

  1. InternalCreatePipelineが呼ばれた直後にPipelineが生成されるのでs_DefaultRenderSetupをReflectionで書き換えておく
  2. LightweightRenderPipelineAssetのm_ResourcesAssetはprivateなのでReflectionで書き込みます
  3. ※ダイレクトマーケティングです
  4. ※こちらもダイレクトマーケティング