Version: 2017.3 (switch to 2017.4)
LanguageEnglish
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

CommandBuffer

class in UnityEngine.Rendering

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

List of graphics commands to execute.

Command buffers hold list of rendering commands ("set render target, draw mesh, ..."). They can be set to execute at various points during camera rendering (see Camera.AddCommandBuffer), light rendering (see Light.AddCommandBuffer) or be executed immediately (see Graphics.ExecuteCommandBuffer).

Typically they would be used to extend Unity's rendering pipeline in some custom ways. For example, you could render some additional objects into deferred rendering g-buffer after all regular objects are done, or do custom processing of light shadow maps. See command buffers overview page for more details.

Command buffers can be created and then executed many times if needed.

See Also: Camera.AddCommandBuffer, Light.AddCommandBuffer, CameraEvent, LightEvent, Graphics.ExecuteCommandBuffer, command buffers overview.

Properties

nameName of this command buffer.
sizeInBytesSize of this command buffer in bytes (Read Only).

Constructors

CommandBufferCreate a new empty command buffer.

Public Methods

BeginSampleAdds a command to begin profile sampling.
BlitAdd a "blit into a render texture" command.
ClearClear all commands in the buffer.
ClearRandomWriteTargetsClear random write targets for Shader Model 4.5 level pixel shaders.
ClearRenderTargetAdds a "clear render target" command.
CopyCounterValueAdds a command to copy ComputeBuffer counter value.
CopyTextureAdds a command to copy a texture into another texture.
CreateGPUFenceCreates a GPUFence which will be passed after the last Blit, Clear, Draw, Dispatch or Texture Copy command prior to this call has been completed on the GPU.
DisableShaderKeywordAdds a command to disable global shader keyword.
DispatchComputeAdd a command to execute a ComputeShader.
DrawMeshAdd a "draw mesh" command.
DrawMeshInstancedAdd a "draw mesh with instancing" command.The command will not immediately fail and throw an exception if Material.enableInstancing is false, but it will log an error and skips rendering each time the command is being executed if such a condition is detected.InvalidOperationException will be thrown if the current platform doesn't support this API (i.e. if GPU instancing is not available). See SystemInfo.supportsInstancing.
DrawMeshInstancedIndirectAdd a "draw mesh with indirect instancing" command.
DrawProceduralAdd a "draw procedural geometry" command.
DrawProceduralIndirectAdd a "draw procedural geometry" command.
DrawRendererAdd a "draw renderer" command.
EnableShaderKeywordAdds a command to enable global shader keyword.
EndSampleAdds a command to begin profile sampling.
GenerateMipsGenerate mipmap levels of a render texture.
GetTemporaryRTAdd a "get a temporary render texture" command.
GetTemporaryRTArrayAdd a "get a temporary render texture array" command.
IssuePluginCustomBlitSend a user-defined blit event to a native code plugin.
IssuePluginCustomTextureUpdateSend a texture update event to a native code plugin.
IssuePluginEventSend a user-defined event to a native code plugin.
IssuePluginEventAndDataSend a user-defined event to a native code plugin with custom data.
ReleaseTemporaryRTAdd a "release a temporary render texture" command.
SetComputeBufferParamAdds a command to set an input or output buffer parameter on a ComputeShader.
SetComputeFloatParamAdds a command to set a float parameter on a ComputeShader.
SetComputeFloatParamsAdds a command to set multiple consecutive float parameters on a ComputeShader.
SetComputeIntParamAdds a command to set an integer parameter on a ComputeShader.
SetComputeIntParamsAdds a command to set multiple consecutive integer parameters on a ComputeShader.
SetComputeMatrixArrayParamAdds a command to set a matrix array parameter on a ComputeShader.
SetComputeMatrixParamAdds a command to set a matrix parameter on a ComputeShader.
SetComputeTextureParamAdds a command to set a texture parameter on a ComputeShader.
SetComputeVectorArrayParamAdds a command to set a vector array parameter on a ComputeShader.
SetComputeVectorParamAdds a command to set a vector parameter on a ComputeShader.
SetGlobalBufferAdd a "set global shader buffer property" command.
SetGlobalColorAdd a "set global shader color property" command.
SetGlobalDepthBiasAdd a command to set global depth bias.
SetGlobalFloatAdd a "set global shader float property" command.
SetGlobalFloatArrayAdd a "set global shader float array property" command.
SetGlobalMatrixAdd a "set global shader matrix property" command.
SetGlobalMatrixArrayAdd a "set global shader matrix array property" command.
SetGlobalTextureAdd a "set global shader texture property" command, referencing a RenderTexture.
SetGlobalVectorAdd a "set global shader vector property" command.
SetGlobalVectorArrayAdd a "set global shader vector array property" command.
SetProjectionMatrixAdd a command to set the projection matrix.
SetRandomWriteTargetSet random write target for Shader Model 4.5 level pixel shaders.
SetRenderTargetAdd a "set active render target" command.
SetShadowSamplingModeAdd a "set shadow sampling mode" command.
SetViewMatrixAdd a command to set the view matrix.
SetViewportAdd a command to set the rendering viewport.
SetViewProjectionMatricesAdd a command to set the view and projection matrices.
WaitOnGPUFenceInstructs the GPU to wait until the given GPUFence is passed.
对文档有任何疑问,请移步至开发者社区提问,我们将尽快为您解答