Vertex Buffers

Hey,

I’m generating a procedural landscape and noticed when playing with stats on in the editor that the vertex buffer uploads varies depending on, what seems to be, new landscape meshes coming into view.

When I do like mesh.vertices= in a script, would I be right in saying this only assigns the new vertices in main memory and does not get uploaded to the graphics card until the mesh is actually visible and needs to be drawn? So Unity has its own kind of per-mesh spooling of vertex data on an as needed basis, and it keeps track of which buffers need updating (ie mesh.vertices was called and the mesh wasn’t previously visible onscreen), rather than just immediately upload vertices when I set them (even if not visible)?

Yes, currently the actual GPU vertex buffer is created/filled “when needed” only.

Of course we might change that behavior if we find good reasons to do that, so don’t bet your family, house dog on it always staying the same :slight_smile:

1 Like

Ok, good, it seems pretty efficient, other than maybe for you guys to start proactively uploading small pieces of vbo’s, smoothed out over the course of a number of frames just prior to them becoming visible, or something like that. Or maybe having one big vbo or something.

But anyway I think that’s ok even if you change it, so long as I know that either setting vertices is going to require an immediate upload or an as-needed upload, it shouldn’t make much difference to me performance wise.

Sorry hijack this thread but this is similar / maybe related …

What if i already have a vertex buffer generated by a compute shader and I now want to tell unity to render that buffer?
I looks like everything I have read so far seems to suggest I have to pull that data from the gfx card ram and build mesh objects so that unity, in its own time will then recreate the buffer i already have … seems a bit odd … in other engines I can get a direct reference to the buffer object and use it with a shader …

I don’t suppose unity has anything that does this kind of thing does it?

1 Like