docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Image capture reference

    Find the classes, channels, and formats the capture subsystem provides.

    The capture subsystem (Runtime/Capture/) provides asynchronous GPU readback of camera render targets. The sensor pipeline uses it internally, and you can also use it directly to record simulation data. For a step-by-step guide, refer to Capture synthetic images.

    Camera capture

    CaptureCamera is a static utility class for capturing color, depth, normal, and motion-vector channels from a Camera.

    Channels

    CaptureCamera supports the following channels:

    Channel value Description
    Color RGB color render output.
    Depth Per-pixel depth values.
    Normal Surface normal vectors.
    Motion Per-pixel motion vectors.

    Capture request

    A capture request issues asynchronous GPU readback for one or more channels. When all requested channels have completed readback, the capture request invokes a completion callback.

    [!NOTE] The source defines the exact overloads and per-channel callback signatures of CaptureCamera.Capture. Refer to CaptureCamera.ReadbackCompletionDelegate and CaptureCamera.RequestCompletionDelegate for delegate signatures.

    ForceFlip

    Some platforms or render pipelines produce vertically flipped images. Use the ForceFlip flags to override the automatic flip detection on a per-channel basis:

    [Flags]
    public enum ForceFlip
    {
        None,
        Color  = (1 << 0),
        Depth  = (1 << 1),
        Normal = (1 << 2),
        Motion = (1 << 3),
        All    = Color | Depth | Normal | Motion,
    }
    

    Single render target capture

    CaptureRenderTexture provides a simpler single-texture asynchronous readback. It falls back to synchronous readback on platforms that do not support asynchronous GPU readback.

    Async request modes

    All capture operations return AsyncRequest<T>. The system can operate in three modes:

    Mode Behavior
    Immediate Reads back data synchronously on the calling thread.
    Background Queues readback and fires callbacks on the main thread.
    Batch Groups multiple requests into a BatchReadback flush.

    Enable batch readback globally:

    CaptureOptions.useBatchReadback = true;
    

    Image encoding

    CaptureImageEncoder converts raw readback byte arrays to common image formats:

    ImageFormat Description
    Jpg JPEG lossy compression (uses libturbojpeg natively when available).
    Png PNG lossless compression (uses pngslz natively when available).
    Exr OpenEXR for high-dynamic-range data.
    Tga Targa format.
    Raw Writes unencoded raw bytes; applies no transformation.

    Convenience MonoBehaviours

    The capture subsystem includes the following MonoBehaviour components for common capture scenarios:

    Component Description
    CameraGrab Captures color from a Camera on each frame into a persistent buffer.
    ChannelGrab Captures an arbitrary channel from a Camera.
    DepthGrab Captures the depth channel.
    ScreenCapture Captures the full-screen render output.

    These are primarily development and debugging helpers.

    SRP integration

    The capture subsystem integrates with both URP and HDRP via custom render passes:

    Render Pipeline Class
    URP URPCaptureRendererFeature + URPCallbackPass
    HDRP HDRPCallbackPass

    For URP: add URPCaptureRendererFeature to the active URP renderer asset. The feature automatically enqueues registered capture passes.

    For HDRP: add an HDRPCallbackPass to the active Custom Pass volume.

    Note

    Sensors handle SRP integration automatically via SRPSupport. You do not need to configure render passes manually when using sensor components.

    Headless rendering

    On headless Linux builds, HeadlessCustomPlayerLoop drives capture readback instead of the normal frame presentation path. Refer to Run simulations headlessly for details.

    Performance profiling

    The capture subsystem includes a profiling pipeline for monitoring encoding and I/O throughput:

    // Access the active PerfStatsManager:
    PerfStatsManager.instance.AddCollector(new CaptureCollector());
    

    CaptureCollector tracks image encoding time and file write timing, and dispatches aggregated stats as ProfilerReport objects to any registered IGlobalProfilerDataDispatcher.

    Additional resources

    • Capture synthetic images
    • Run simulations headlessly
    • Generate sensor data
    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)