Search Unity

Feature Request Add support for byte type for Sample Buffer

Discussion in 'Visual Effect Graph' started by Zarbuz, Apr 7, 2022.

  1. Zarbuz

    Zarbuz

    Joined:
    Oct 13, 2015
    Posts:
    43
    In the official documentation, we can see the list of types compatible for sampling structured buffers. upload_2022-4-7_9-2-47.png

    Do you think it is possible to add support type byte ? I would like to minimize the RAM usage in my data, data that can be encoded in 8 bits and not 32. I work a lot with the new [VFXType] attribute, I would like this to be possible with custom types as well.
     
    Qriva and mgear like this.
  2. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    326
    Hi! This is a relevant request. We may add some types in the future to allow this.
    In the meantime, you can probably pack/unpack your data manually by using bitwise operators in the graph.
     
    Zarbuz likes this.
  3. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    VFX graph generates compute shaders, and the byte type doesn't actually exist in shaders. If you check HLSL and GLSL docs, you'll see the smallest type is 32-bit float/integer, with some GPUs supporting 16-bit floats (but not 16-bit int).

    But you can use bytes in the GPU, just not directly. In RGBA8 textures, for example, each channel is stored using just one byte, but when you load/sample from it in a shader the GPU converts it into a 0-1 float. If you want to use structured buffers, however, the only choice is to manually pack/unpack bits using bitwise operations.
     
  4. Zarbuz

    Zarbuz

    Joined:
    Oct 13, 2015
    Posts:
    43
    I will use bitwise operations for the moment. Thank you for your feedback