Vertex declaration for submesh with gaps /unused data

Problems building or running the engine, queries about how to use features etc.
Post Reply
Pellaeon
Goblin
Posts: 230
Joined: Thu Apr 28, 2011 12:23 pm
x 28

Vertex declaration for submesh with gaps /unused data

Post by Pellaeon »

Ogre Version: 1.12.4
Operating System: Win10 x64
Render System: DX11
Hi,

I want to visualize the calculated mesh from PolyVox(a voxel library) in ogre. Because my mesh will grow over the time, I want to create mesh and submesh objects and copy the whole vertex buffer (and index buffer) instead of the createManual approach, where I have an ogre call for every position value. For the mesh creation I rely on this tutorial: http://wiki.ogre3d.org/Generating+A+Mesh.

Now my problem: the library can create a mesh with position, normal and user data. Now, this user data can't be omitted. So the delivered buffer contains the user data which is not necessary for rendering in ogre (Pos|Normal|Userdata|Pos|Normal|Userdata|... etc.). How can I tell the vertex declaration about this unused data (from ogre sight) in the buffer? I didn't find a proper method to declare this offset. I could misuse another property, but I don't want to have side effects. And atm my user data is uint_8, because I can't set void in the PolyVox library. When setting e.g. a color as attribute, the size would grow
Last edited by Pellaeon on Tue Feb 25, 2020 8:20 am, edited 1 time in total.
Pellaeon
Goblin
Posts: 230
Joined: Thu Apr 28, 2011 12:23 pm
x 28

Re: Vertex declaration for submesh with gaps /unused data

Post by Pellaeon »

OK, I suppose I can do this by setting the correct size in HardwareBufferManager::createVertexBuffer.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: Vertex declaration for submesh with gaps /unused data

Post by dark_sylinc »

Hi!

As you guessed you can create a vertex buffer with a vertexSize larger than its declaration.

Nonetheless it might be better to declare whatever you don't use as extra VES_TEXTURE_COORDINATES in your VertexDeclaration; in order to avoid either Ogre bugs or driver bugs. Some routines like VertexDeclaration::closeGaps are 'optimizations' will forcefully reorganize the data to avoid containing gaps (historically closeGaps was written because extremely old HW did not support them, but we're talking 15 years ago).
If you declare them as extra VES_TEXTURE_COORDINATES (which your materials don't use), closeGaps will not remove them.
Post Reply