Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Can I use something like VBOs in Unity?

Discussion in 'Shaders' started by frankfringe, Sep 9, 2019.

  1. frankfringe

    frankfringe

    Joined:
    Feb 9, 2019
    Posts:
    105
    Hi,

    I want to translate this OpenGL tutorial to unity:


    The problem is that he has some custom vertex data (a VBO) for each vertex that describes the other two vertexes that share a triangle (this way he can calculate the triangle normal at each vertex).

    This custom vertex data can be created together with the mesh and then be send to the GPU - can I do something similar in unity?

    Many thanks
     
  2. frankfringe

    frankfringe

    Joined:
    Feb 9, 2019
    Posts:
    105
    Ok, so this thread https://forum.unity.com/threads/passing-extra-vertex-data-to-a-shader.190448/ makes it seem as if what I am planning is not possible.

    Do I understand it right, that all I can do in Unity is use the existing structures (for example Vertex UVs or Vertex Colors) to pass data to the vertices and if I run out of them I am basically out of luck?

    I also now read about ComputeBuffers. Are these supported on old hardware and do they have any drawbacks as opposed to missusing for example the Colors Array to pass my data?
     
  3. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,924
    As far as I can tell:

    1. You're right - Unity has decided that they still won't implement VBO's, some 15 years after they became industry standard (OpenGL made them official in 2003; Direct3D had them at least since Dx9, IIRC)
    2. You can (ab)use ComputeBuffers as a poor-man's version of VBO's (worse performance, many bugs even in latest Unity) but according to Unity docs only in shader model 5+.
    The one good part of using ComputeBuffer is that the code you write works almost exactly like a VBO - it's simple and it Just Works. The bad part is that Unity still hasn't fixed a lot of the bugs, and hasn't documented most of it.