KlakSpout Documentation

repository·main·Indexed 21 days ago

https://github.com/keijiro/klakspout

A Unity plugin for high-performance, interprocess GPU memory sharing using the Spout system on Windows. Version 2.0.6 supports sending and receiving video streams via Spout Sender and Spout Receiver components. Requires Unity 2022.3 or later and Direct3D 11 or 12. Provides a scripting interface via SpoutManager and supports specific pixel formats including R8G8B8A8 UNorm.

Tokens
620
Snippets
0
Records
6
Agent score
24%

What's inside KlakSpout

  1. Pixel Format Compatibility for Spout

    main

    KlakSpout has specific requirements for pixel formats depending on whether you are sending or receiving streams.

    Sending

    When sending video from Unity, only the following format is supported:

    • R8G8B8A8 UNorm

    Receiving

    KlakSpout can receive the following formats:

    • R8G8B8A8 UNorm (sRGB/linear)
    • B8G8R8A8 UNorm (sRGB/linear)
    • R16G16B16A16 Half Float
    • R32G32B32A32 Float

    If you are using TouchDesigner as a sender, ensure you select one of the supported receiving formats in the Spout Out TOP.

  2. Use the Spout Sender Component

    main

    The Spout Sender component allows Unity to broadcast a video stream to other applications. You can choose from three capture methods:

    • Game View: Captures the Unity Game View window.
    • Camera: Captures a specific camera. Note: This is only available for URP and HDRP; it is not supported on the Built-in Render Pipeline.
    • Texture: Captures a 2D texture or a Render Texture.

    Alpha Channel Handling

    • KeepAlpha: A property that controls whether the alpha channel is preserved or cleared.
    • HDRP: Enable [alpha output] in your HDRP settings to preserve alpha.
    • URP: Use the Texture capture method to output alpha.
  3. System Requirements for KlakSpout

    main

    To use KlakSpout, ensure your environment meets the following requirements:

    • Unity Version: 2022.3 or later.
    • OS: Windows.
    • Graphics API: Direct3D 11 or Direct3D 12 support.

    Note: Other graphics APIs like OpenGL or Vulkan are not supported.

  4. Use the Spout Receiver Component

    main

    The Spout Receiver component allows Unity to ingest video streams from other Spout-enabled applications.

    Functionality

    • It stores incoming frames in a designated Target Texture.
    • It automatically overrides the material property set in the Target Renderer to display the stream.
    • You can access the incoming stream programmatically via the SpoutReceiver.receivedTexture property.
  5. Install KlakSpout via Package Manager

    main
    Install the KlakSpout package (jp.keijiro.klak.spout) using the Unity Package Manager. You must first add the "Keijiro" scoped registry to your project settings before the package will appear in the registry list.
  6. Scripting Interface for KlakSpout

    main

    KlakSpout provides several ways to interact with Spout via code:

    • Enumerating Senders: Use the SpoutManager class to find and list available Spout senders.
    • Runtime Instantiation: You can create Spout senders or receivers at runtime. However, if you instantiate them via script, you must manually assign the SpoutResources asset to the instance to ensure it has references to the necessary package assets.