Search Unity

Question How to attach a shader storage buffer object (SSBO) to a shader/material?

Discussion in 'General Graphics' started by KageKirin, Sep 16, 2021.

  1. KageKirin

    KageKirin

    Joined:
    Jan 22, 2014
    Posts:
    50
    Hi,

    slightly in parallel of my other question (https://forum.unity.com/threads/how...nning-in-a-vertex-or-fragment-shader.1159070/), I'd like to know if, and how, I can attach a shader storage buffer object (rwbuffer in D3D11) to a shader.
    Alternatively, what would I need to do for a Uniform Buffer Object (const buffer in D3D)?

    https://www.khronos.org/opengl/wiki/Shader_Storage_Buffer_Object
    https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/sm5-object-rwbuffer?redirectedfrom=MSDN)

    In the example of my previous question, I'd like to store e.g. bone positions in that buffer, to access later in the vefrtex shader and compute a spheroid normal.

    Thanks for any pointers.

    Cheers.
     
  2. KageKirin

    KageKirin

    Joined:
    Jan 22, 2014
    Posts:
    50
    Additional question: hardware or graphics API limitations.
    As of SM3, constant buffers (UBOs) are supported everywhere.
    rwbuffers are a SM5 addition, so I suspect that everything below DX11 baseline does not support them... which should be fine if I target Metal (macOS/iOS) and Vulkan (Android/Windows) or DX11 (Windows). Right?