Unity 6.3
0 онлайн 34 гостей 3 в системе
Вход

ScriptableRenderContext.ExecuteCommandBuffer

Declaration

public void ExecuteCommandBuffer(Rendering.CommandBuffer commandBuffer);

Параметры

Параметр Описание
commandBuffer Указывает Буфер Команд для выполнения.

Описание

Расписывает выполнение пользовательского графического командного буфера.

В ходе вызова ScriptableRenderContext.ExecuteCommandBuffer, ScriptableRenderContext регистрирует параметр commandBuffer в собственном внутреннем списке команд на выполнение. Фактическое выполнение этих команд (включая команды из вашего commandBuffer) происходит во время ScriptableRenderContext.Submit.

Обязательно вызывайте ExecuteCommandBuffer до других методов ScriptableRenderContext (таких как DrawRenderers, DrawShadows), если ваши вызовы отрисовки зависят от состояния конвейера, которое вы задаёте в CommandBuffer. В примере кода ниже сначала показан случай, когда команды переданы в неправильном порядке, а затем — случай, который работает ожидаемо:

using UnityEngine;
using UnityEngine.Rendering;

internal class ExecuteCommandBufferExample { // TODO: replace with actual settings ScriptableRenderContext scriptableRenderContext; DrawingSettings drawingSettings; CullingResults cullingResults = new CullingResults(); FilteringSettings filteringSettings = new FilteringSettings();

Matrix4x4 myViewMatrix = Matrix4x4.Scale(new Vector3(2f, 2f, 2f));

public void DrawRenderersExampleIncorrect() { CommandBuffer myCommandBuffer = new CommandBuffer();

myCommandBuffer.SetViewMatrix(myViewMatrix);

scriptableRenderContext.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings); // NO! When scriptableRenderContext submits the DrawRenderers command, it will not know about myViewMatrix :(

scriptableRenderContext.ExecuteCommandBuffer(myCommandBuffer); myCommandBuffer.Clear(); }

public void DrawRenderersExampleBetter() { CommandBuffer myCommandBuffer = new CommandBuffer();

myCommandBuffer.SetViewMatrix(myViewMatrix);

scriptableRenderContext.ExecuteCommandBuffer(myCommandBuffer); myCommandBuffer.Clear();

scriptableRenderContext.DrawRenderers(cullingResults, ref drawingSettings, ref filteringSettings); // OK! During next scriptableRenderContext.Submit() call, scriptableRenderContext will set myViewMatrix *before* drawing the renderers. } }

Дополнительные ресурсы: ,CommandBuffer,.