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

Give my mesh an additional Vector3 per vertex

Discussion in 'General Graphics' started by csantos, Jan 18, 2015.

  1. csantos

    csantos

    Joined:
    Dec 20, 2013
    Posts:
    7
    I'm creating a procedural mesh that currently only has vertices (which are bound to the POSITION vertex shader input semantic). Today I realized that I needed an additional 3-dimensional vertex per vertex. It's not a normal, not a tangent, not even a color. It has a meaning that's very specific to my application (basically I'm doing some real time GPU raymarching), and thus, I can't use the available Mesh fields:
    • uv/uv1/uv2: Because they are 2-dimensional
    • normal/tangent/colors: I might need them in the future. Also I don't know if unity normalizes or clamps the values in these buffers to [-1,1] (and I wouldn't be surprised if they did without any notice, after I found out vertices are scaled on CPU before being sent to GPU).
    • position: Because they are in a different space than the space of the vertices that I need; a transform may be applied to them but that would be a stupid way to waste GPU cycles.
    So, are there any alternatives here? Is there a more advanced Mesh class that gives me more control over the VBO? Or, even better, is there a way for me to create my own VBO and populate it with my custom data?
     
  2. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Use uv1 and uv2 - four floats?