Class CaptureCamera
Capture class for cameras. Supports Color, Depth, MotionVectors. Captures supported channels to file system and notifies Manager.
Namespace: Unity.Simulation
Syntax
public static class CaptureCamera
Fields
SRPSupport
Support for Scriptable Render Pipeline. SRP works a little differently, this abstraction allows for custom capture options when using SRP. The default implementation queues camera captures, and dispatches on RenderPipelineManager.endFrameRendering. You can provide your own implementation of QueueCameraRequest, and dispatch that when appropriate.
Declaration
public static SRPSupport SRPSupport
Field Value
Type | Description |
---|---|
SRPSupport |
Properties
scriptableRenderPipeline
Property for determining whether or not a scriptable render pipeline is enabled or not. Will only ever return true on Unity versions 2019.3 or later.
Declaration
public static bool scriptableRenderPipeline { get; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
Capture(Camera, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result>, GraphicsFormat, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result>, GraphicsFormat, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result>, GraphicsFormat, Boolean)
Main Capture entrypoint.
Declaration
[Obsolete("Capture with boolean flipY has been deprecated. Use the version with ForceFlipY instead.")]
public static AsyncRequest<CaptureCamera.CaptureState> Capture(Camera camera, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> colorFunctor = null, GraphicsFormat colorFormat = GraphicsFormat.R8G8B8A8_UNorm, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> depthFunctor = null, GraphicsFormat depthFormat = GraphicsFormat.R16_UNorm, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> motionFunctor = null, GraphicsFormat motionFormat = GraphicsFormat.R16_UNorm, bool flipY = false)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The Camera to capture data from. |
Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> | colorFunctor | Completion functor for the color channel. |
GraphicsFormat | colorFormat | The pixel format to capture in. |
Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> | depthFunctor | Completion functor for the depth channel. |
GraphicsFormat | depthFormat | The pixel format to capture in. |
Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> | motionFunctor | Completion functor for the motion vectors channel. |
GraphicsFormat | motionFormat | The pixel format to capture in. |
Boolean | flipY | Whether or not to flip the image vertically. |
Returns
Type | Description |
---|---|
AsyncRequest<CaptureCamera.CaptureState> | AsyncRequest<CaptureState> |
Capture(Camera, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result>, GraphicsFormat, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result>, GraphicsFormat, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result>, GraphicsFormat, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result>, GraphicsFormat, ForceFlip, RenderTextureReadWrite)
Main Capture entrypoint.
Declaration
public static AsyncRequest<CaptureCamera.CaptureState> Capture(Camera camera, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> colorFunctor = null, GraphicsFormat colorFormat = GraphicsFormat.R8G8B8A8_UNorm, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> depthFunctor = null, GraphicsFormat depthFormat = GraphicsFormat.R8G8B8A8_UNorm, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> normalFunctor = null, GraphicsFormat normalFormat = GraphicsFormat.R8G8B8A8_UNorm, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> motionFunctor = null, GraphicsFormat motionFormat = GraphicsFormat.R8G8B8A8_UNorm, ForceFlip forceFlip = ForceFlip.None, RenderTextureReadWrite readWrite = RenderTextureReadWrite.Default)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The Camera to capture data from. |
Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> | colorFunctor | Completion functor for the color channel. |
GraphicsFormat | colorFormat | The pixel format to capture in. |
Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> | depthFunctor | Completion functor for the depth channel. |
GraphicsFormat | depthFormat | The pixel format to capture in. |
Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> | normalFunctor | |
GraphicsFormat | normalFormat | |
Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> | motionFunctor | Completion functor for the motion vectors channel. |
GraphicsFormat | motionFormat | The pixel format to capture in. |
ForceFlip | forceFlip | |
RenderTextureReadWrite | readWrite | Specify the desired color space conversion. If Default, then will be set to sRGB for SRP Color channel. |
Returns
Type | Description |
---|---|
AsyncRequest<CaptureCamera.CaptureState> | AsyncRequest<CaptureState> |
CaptureColorAndDepthToFile(Camera, GraphicsFormat, String, CaptureImageEncoder.ImageFormat, GraphicsFormat, String, CaptureImageEncoder.ImageFormat)
Captures a camera render and writes out the color and depth channels to a file.
Declaration
public static AsyncRequest<CaptureCamera.CaptureState> CaptureColorAndDepthToFile(Camera camera, GraphicsFormat colorFormat = GraphicsFormat.R8G8B8A8_UNorm, string colorPath = null, CaptureImageEncoder.ImageFormat colorImageFormat = CaptureImageEncoder.ImageFormat.Jpg, GraphicsFormat depthFormat = GraphicsFormat.R16_UNorm, string depthPath = null, CaptureImageEncoder.ImageFormat depthImageFormat = CaptureImageEncoder.ImageFormat.Raw)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The Camera to capture data from. |
GraphicsFormat | colorFormat | The pixel format to capture in. |
String | colorPath | The location of the file to write out. |
CaptureImageEncoder.ImageFormat | colorImageFormat | The image format to write the data out in. |
GraphicsFormat | depthFormat | The pixel format to capture in. |
String | depthPath | The location of the file to write out. |
CaptureImageEncoder.ImageFormat | depthImageFormat | The image format to write the data out in. |
Returns
Type | Description |
---|---|
AsyncRequest<CaptureCamera.CaptureState> | AsyncRequest<CaptureState> |
CaptureColorToFile(Camera, GraphicsFormat, String, CaptureImageEncoder.ImageFormat)
Captures a camera render and writes out the color channel to a file.
Declaration
public static AsyncRequest<CaptureCamera.CaptureState> CaptureColorToFile(Camera camera, GraphicsFormat colorFormat, string colorPath, CaptureImageEncoder.ImageFormat colorImageFormat = CaptureImageEncoder.ImageFormat.Jpg)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The Camera to capture data from. |
GraphicsFormat | colorFormat | The color pixel format to capture in. |
String | colorPath | The location of the file to write out. |
CaptureImageEncoder.ImageFormat | colorImageFormat | The image format to write the data out in. |
Returns
Type | Description |
---|---|
AsyncRequest<CaptureCamera.CaptureState> | AsyncRequest<CaptureState> |
CaptureDepthToFile(Camera, GraphicsFormat, String, CaptureImageEncoder.ImageFormat)
Captures a camera render and writes out the depth channel to a file.
Declaration
public static AsyncRequest<CaptureCamera.CaptureState> CaptureDepthToFile(Camera camera, GraphicsFormat depthFormat, string depthPath, CaptureImageEncoder.ImageFormat depthImageFormat = CaptureImageEncoder.ImageFormat.Raw)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The Camera to capture data from. |
GraphicsFormat | depthFormat | The pixel format to capture in. |
String | depthPath | The location of the file to write out. |
CaptureImageEncoder.ImageFormat | depthImageFormat | The image format to write the data out in. |
Returns
Type | Description |
---|---|
AsyncRequest<CaptureCamera.CaptureState> | AsyncRequest<CaptureState> |
SelectShaderVariantForChannel(CaptureCamera.Channel, GraphicsFormat)
Declaration
public static Material SelectShaderVariantForChannel(CaptureCamera.Channel channel, GraphicsFormat format)
Parameters
Type | Name | Description |
---|---|---|
CaptureCamera.Channel | channel | |
GraphicsFormat | format |
Returns
Type | Description |
---|---|
Material |
SetupCaptureRequest(AsyncRequest<CaptureCamera.CaptureState>, CaptureCamera.Channel, Camera, GraphicsFormat, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result>, ForceFlip, RenderTextureReadWrite)
Setup a capture request for a channel. Once completed, the functor will be called with the channel data, in the format requested.
Declaration
public static void SetupCaptureRequest(AsyncRequest<CaptureCamera.CaptureState> request, CaptureCamera.Channel channel, Camera camera, GraphicsFormat format, Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> functor, ForceFlip forceFlipY, RenderTextureReadWrite readWrite = RenderTextureReadWrite.Default)
Parameters
Type | Name | Description |
---|---|---|
AsyncRequest<CaptureCamera.CaptureState> | request | AsyncRequest to enqueue readbacks to. When all are completed, the request is marked completed. |
CaptureCamera.Channel | channel | The channel to capture data from (color, depth etc.) |
Camera | camera | The Camera to capture data from. |
GraphicsFormat | format | The graphics format you want the data to be in. |
Func<AsyncRequest<CaptureCamera.CaptureState>, AsyncRequest.Result> | functor | The completion functor to call with the data. |
ForceFlip | forceFlipY | Flags allowing you to force flipY for arbitrary channels. |
RenderTextureReadWrite | readWrite | Specify the desired color space conversion. If Default, then will be set to sRGB for SRP Color channel. |
SetupCaptureRequestCommandBufferForChannel(AsyncRequest<CaptureCamera.CaptureState>, CaptureCamera.Channel, Camera, CommandBuffer, RenderTargetIdentifier, Material, GraphicsFormat, ForceFlip, RenderTextureReadWrite, CaptureCamera.ReadbackCompletionDelegate)
Setup a CommandBuffer for capturing from a channel.
Declaration
public static void SetupCaptureRequestCommandBufferForChannel(AsyncRequest<CaptureCamera.CaptureState> request, CaptureCamera.Channel channel, Camera camera, CommandBuffer commandBuffer, RenderTargetIdentifier rtid, Material material, GraphicsFormat format, ForceFlip forceFlipY, RenderTextureReadWrite readWrite, CaptureCamera.ReadbackCompletionDelegate completion)
Parameters
Type | Name | Description |
---|---|---|
AsyncRequest<CaptureCamera.CaptureState> | request | AsyncRequest to enqueue readbacks to. When all are completed, the request is marked completed. |
CaptureCamera.Channel | channel | The channel to capture data from (color, depth etc.) |
Camera | camera | The Camera to capture data from. |
CommandBuffer | commandBuffer | The command buffer to populate. If null, a command buffer will be allocated from a pool. |
RenderTargetIdentifier | rtid | The render target identifier to capture. If default(RenderTargetIdentifier) then readback will occur from either the Camera.targetTexture or the back buffer. |
Material | material | Material to use when blitting. If null, then no blit will occur. Use by depth to copy from depth buffer to color buffer, but could be useful elsewhere as well. |
GraphicsFormat | format | The graphics format you want the data to be in. |
ForceFlip | forceFlipY | Flags allowing you to force flipY for arbitrary channels. |
RenderTextureReadWrite | readWrite | Specify the desired color space conversion. If Default, then will be set to sRGB for SRP Color channel. |
CaptureCamera.ReadbackCompletionDelegate | completion | The completion functor to call with the data. |
ShouldFlipY(Camera, CaptureCamera.Channel, ForceFlip, Boolean)
Check if for the given rendering pipeline there is a need to flip Y during readback.
Declaration
public static bool ShouldFlipY(Camera camera, CaptureCamera.Channel channel, ForceFlip forceFlipY, bool usePassedInRenderTargetId)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | Camera from which the readback is being performed. |
CaptureCamera.Channel | channel | Channel which the readback is being performed for. |
ForceFlip | forceFlipY | Override the default to either force flip or force not flip, or neither. |
Boolean | usePassedInRenderTargetId | When we are using a passed in rtid, then we don't need to flip. |
Returns
Type | Description |
---|---|
Boolean | A boolean indicating if the flip is required. |