Hello. Hoping an expert in the ‘advanced mesh api’ can offer me some advice.
My question relates to the use of two methods (click for the documentation):
The second of these takes a parameter ‘stream’ which apparently lets us set the vertex data for multiple streams.
I have a test rig working perfectly when just using the default stream (0) but I’m having trouble trying to introduce a second stream.
I assume that I need to set up two separate VertexBufferParams like so:
VertexAttributeDescriptor[] customVertexStream1 = new[] {
new VertexAttributeDescriptor(VertexAttribute.Position, VertexAttributeFormat.Float32, 3),
};
VertexAttributeDescriptor[] customVertexStream2 = new[] {
new VertexAttributeDescriptor(VertexAttribute.Normal, VertexAttributeFormat.Float32, 3),
new VertexAttributeDescriptor(VertexAttribute.TexCoord0, VertexAttributeFormat.Float32, 2),
};
But when I use Mesh.SetVertexBufferParams() there doesn’t appear to be a way to set it for a stream other than the default:
mesh.SetVertexBufferParams(vertexBuffer1.Count, customVertexStream1); // Where's the stream parameter?
There’s no parameter for the stream number like there is for SetVertexBufferData.
Whatever I try, I always get the same exception when trying to call SetVertexBufferData with stream = 1 rather than 0:
SetVertexData() with out-of-bounds arguments; would need to copy 810000 bytes at offset 0 into a 0 byte buffer
This is the same exception you get if you fail to call SetVertexBufferParams() before calling SetVertexBufferData with stream = 0, so I’m pretty sure the issue is the SetVertexBufferParams().
I’ve looked through all the documentation, even the Mesh.cs source code. My question is simple. How do you SetVertexBufferParams() for a stream other than 0?
Just to avoid the obvious questions: I know I can just combine all my data into a single stream. I’ve done that and everything works perfectly. However I would like to try the multiple stream approach because it will open up some potential optimisations with how I generate the vertex buffer data.
Hoping it’s a just a simple step that I’m missing somewhere. Thanks!