Version: 2018.3 (switch to 2019.1 )
Compute shaders
GPU instancing
Other Versions

Graphics Command Buffers

Command Buffers allow you to extend Unity’s built-in render pipeline. A Command Buffer holds a list of renderingThe process of drawing graphics to the screen (or to a render texture). By default, the main camera in Unity renders its view to the screen. More info
See in Glossary
commands which execute at various points during cameraA component which creates an image of a particular viewpoint in your scene. The output is either drawn to the screen or captured as a texture. More info
See in Glossary
rendering. To specify a position in Unity’s built-in render pipeline for a Command Buffer to execute, use the CameraEvent enum.

For example, you can use a Command Buffer with the AfterGBuffer CameraEvent to render additional GameObjectsThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary
into the Deferred pipeline, after the pipeline processes all opaque GameObjects.

Below is a high-level overview of how Cameras use the Forward or Deferred pipeline to render a SceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
See in Glossary
in Unity.

  • Black boxes represent an internal Unity process.
  • Blue boxes represent a CameraEvent where you can add Command Buffers.

See the CommandBuffer Class and the CameraEvent Enum for more information. You can also use Command buffers in conjunction with, or as a replacement for, image effects.

Example code

Here is a sample Unity Project which demonstrates some of the effects you can create with Command Buffers: RenderingCommandBuffers.zip.

Blurry refractions

This Scene demonstrates a technique you can use to create blurry refraction. After Unity renders opaque objects and the skyboxA special type of Material used to represent skies. Usually six-sided. More info
See in Glossary
, this technique copies the current image into a temporary render target and blurs it. The glass ShaderA small script that contains the mathematical calculations and algorithms for calculating the Color of each pixel rendered, based on the lighting input and the Material configuration. More info
See in Glossary
then samples this blurred image and uses a normal map to offset the UV coordinates to simulate refraction. This technique is similar to a Shader GrabPass.

Custom area lights in the deferred pipeline

This Scene shows a technique you can use to create custom deferred sphere-shaped and tube-shaped lights. After Unity processes the regular deferred light pass, this technique draws a sphere for each custom light. Each sphere then uses a Shader to compute the illumination and add it to the lighting buffer.

Decals in the deferred pipeline

This Scene shows a basic technique for processing deferred decals. After Unity processes the G-buffer, this technique draws each decal and modifies the G-buffer contents. This technique works in a similar way to how Unity processes lights in the deferred pipeline, except this technique modifies the G-buffer textures rather than accumulate lighting. This technique processes each decal as a box, and only affects geometry inside the volume of the box.

Did you find this page useful? Please give it a rating:

Compute shaders
GPU instancing