【Unity6URP】Camera.Render()ではなくRender Requestを使う

これまで独自のタイミングでレンダリングする必要が出てきたときにCamera.Render()を呼んでたけど、
Unity6URPでは「RenderRequest」という機構が用意されていてこちらを使うのが推奨されているようだ。

  • RenderPipeline.SubmitRenderRequestでレンダリングしてみる
    • RenderPipeline.StandardRequestを使った場合
    • Baseカメラの描画だけレンダリングする
    • Overlayカメラの描画だけレンダリングできる?
      • おまけ:じゃあどうする?
続きを読む

【URP】In the render graph API, the output Render Texture must have a depth buffer.

起きた事象

unity6のURPへアップデートした直後、以下の警告が出るようになった。

In the render graph API, the output Render Texture must have a depth buffer. When you select a Render Texture in any camera's Output Texture property, the Depth Stencil Format property of the texture must be set to a value other than None.
UnityEngine.Rendering.RenderPipelineManager:DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset,intptr,UnityEngine.Object,Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle)

環境

unity6.0(6000.0.63f1) URP17.0.4

対処法

レンダラーテクスチャの深度バッファのbit数を0に指定している箇所があるはず。

コードからだとこういうもの。

RenderTexture tex = new RenderTexture(textureSize.w, textureSize.h, 0);
RenderTexture tex2 = RenderTexture.GetTemporary(textureSize.w, textureSize.h, 0); //Temporary使ってるならこんな感じ


深度バッファのbit数を指定する。
深度バッファのbit数は16,24,32のいずれかで指定する*1今迄0で問題なかったものは16が良いと思う。
(深度バッファに使われるメモリ使用量が一番小さいから)

RenderTexture tex = new RenderTexture(textureSize.w, textureSize.h, 16);
RenderTexture tex2 = RenderTexture.GetTemporary(textureSize.w, textureSize.h, 16); //Temporary使ってるならこんな感じ

なぜ?

これまで深度バッファを使わないレンダラーテクスチャでは、0を指定する方がメモリ使用量の削減になると考えていた。
しかし、Unity 6 のURPでは「Render Graph」*2という新しいレンダリングシステムに完全移行したらしく、
このシステムでは深度バッファが必ず使われる設計になっているため深度バッファのbit数の指定が必須となった。

これだけ見ると、メモリ使用量が増えてよくないように見えるが、それ以上のメリットがRender Graphにはあるらしい。→TODO

RenderGraphは無効にもできる。

都合が悪い人はProject Settingsの以下をチェックすると無効にすることもできる。

Graphics → Pipeline Specific Settings → URPタブ → Render Graph → Compatibility Mode (Render Graph Disabled)

【Unity最適化】Static BatchingでDraw Callsを減らせ!FPSあげよう!٩( ''ω'' )و

インスペクタの「Static」にチェックいれると…? (‘ω‘ )?

そのゲームオブジェクトは「Static Batching」の対象になります。
「Static Batching」にするとDraw Callsを減らすことができ、CPUへの負荷や間接的にはGPUへの負荷が減らせます。
今日はこのあたりのことをまとめるよー。


  • そもそもDraw Callsってなんだっけ
  • Static Batching ?
    • Batching(バッチング)?
    • Dynamic Batching と Static Batching
      • Dynamic Batchingを試してみよう
      • Static Batchingを試してみよう
    • どういうときに使える?
    • メモリ占有量は増える
  • まとめ
続きを読む