このページでは、ビルトインレンダーパイプラインのコマンドバッファの使用に関して説明します。スクリプタブルレンダーパイプライン (SRP) に基づくレンダーパイプラインのコマンドバッファの使用については、スクリプタブルレンダーパイプラインのレンダリングコマンドのスケジュールと実行 を参照してください。
コマンドバッファ には、レンダリングコマンド (レンダーターゲットの設定や、指定したメッシュの描画など) のリストが格納されています。Unity に指示して、これらのコマンドをビルトインレンダーパイプラインの様々な時点でスケジュールして実行するように Unity のレンダリング機能をカスタマイズして拡張することができます。
Graphics.ExecuteCommandBuffer API を使ってコマンドバッファをすぐに実行することができます。または、レンダーパイプラインの特定の時点で発生するようにスケジュールすることもできます。それらをスケジュールするには、Camera.AddCommandBuffer API をCameraEvent enum と共に使う、あるいは Light.AddCommandBuffer API を LightEvent enum と共に使用します。このようにしてスケジュールしたコマンドバッファを Unity がいつ実行するかは、CameraEvent と LightEvent の実行順序 を参照してください。
コマンドバッファを使用して実行できるコマンドの完全なリストは、スクリプトリファレンスの CommandBuffer を参照してください。一部のコマンドは特定のハードウェアでのみサポートされていることに注意してください。例えば、レイトレーシングに関するコマンドは DX12 でのみサポートされています。
Unity のブログポストExtending Unity 5 rendering pipeline:Command Buffers は、ビルトインレンダーパイプラインのコマンドバッファを紹介しています。この記事では、コマンドバッファを使っていくつかの異なるエフェクトを実現する方法が説明されており、サンプルプロジェクトとサンプルコードが含まれています。このプロジェクトは古いバージョンの Unity 用に作成されたものですが、原理は同じです。
CameraEvent の実行順序は、プロジェクトが使用する レンダリングパス によって異なります。
ディファードレンダリングパス
フォワードレンダリングパス
影のレンダリングの段階で、影を投影する各ライトに対して Unity は以下を実行します。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.