Why is the vertex size in meshopt_encodeVertexBuffer required to be a multiple of 4? #874
-
In meshopt_encodeVertexBufferLevel here is the code
What is the reason for this requirement? What about vertex sizes that are not multiples of 4, for example a vertex format that is just 3 uint16 position coordinates? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Or are we (the users of meshoptimizer) expected to pad the input vertex data so that it's a multiple of 4 bytes in size? |
Beta Was this translation helpful? Give feedback.
-
This requirement is needed for parts of the fast decoding loop. In addition it is motivated by the fact that many graphics APIs impose the same requirement on strides or formats of vertex buffers; it's uncommon to be able to specify a 6-byte uint16x3 input. Indeed, the expectation is that inputs like this are padded, either with zeroes, or with some other useful data (e.g. for interleaved vertices there's usually opportunities to use padding space for something needed by another vertex component). |
Beta Was this translation helpful? Give feedback.
-
Ok, thanks for the reply. I am currently testing with this vertex format and it seems to be accepted by OpenGL:
See https://x.com/SubstrataVr/status/1914333596418204009 A related question, which I'm unclear about even after reading the documentation: for meshopt_encodeVertexBuffer use with a vertex data buffer with interleaved attributes (such as the format I just described), is it expected that meshopt_encodeVertexBuffer can be called effectively once on the interleaved buffer, or should the individual attributes be de-intereleaved and meshopt_encodeVertexBuffer called on a buffer for each attribute separately? |
Beta Was this translation helpful? Give feedback.
This requirement is needed for parts of the fast decoding loop. In addition it is motivated by the fact that many graphics APIs impose the same requirement on strides or formats of vertex buffers; it's uncommon to be able to specify a 6-byte uint16x3 input.
Indeed, the expectation is that inputs like this are padded, either with zeroes, or with some other useful data (e.g. for interleaved vertices there's usually opportunities to use padding space for something needed by another vertex component).