c++ - Sorting submeshes/VBO -


i have level need render. broken hundreds of submeshes information on submesh can see submesh. each level has pool of textures of submeshes can reference. submeshes have vertices sorted texture. here example.

submesh 1

index[1, 3, 4, 5, 6, 2, 7, 8, 10...] texture 1

index[12, 15, 16, 12, 13, 19] texture 2

when there 1000 submeshes , 20 textures possible, amount of texture swapping gets ridiculous factoring in visibility.

i have of submeshes sequentially in vbo. have been trying figure out best way go optimizing rendering , eliminate unnecissary texture swaps. if sort vbo, lose submesh connections , visibility data becomes useless. or there better way that?

or should create index list every frame based on visibility or slow?

edit: here breakdown of current setup.

vbo of vertices in order running submesh 1 texture 1, submesh 1 texture 2, way submesh n, texture n.

i have ibo of indices of meshes, in same relative order.

when render, consult submesh , have starting index , count start index in ibo submesh , texture , count number have texture.

this why doing swapping slowing things down.

vbo of vertices in order running submesh 1 texture 1, submesh 1 texture 2, way submesh n, texture n.

there's problem. "submesh" should single rendering call, not multiple rendering calls. each "submesh" should equivalent of "submesh x, texture y" pairs. particular submesh uses particular set of glvertexattribpointer calls, glbindtexture calls, , single gldrawelements call render.

each submesh in scheme uses specific texture. therefore, can sort draw order textures use. submeshes use texture 1 can rendered @ same time, 1 glbindtexture call between them.

for best performance, since of "submeshes" use same buffers (and therefore, it's change use same vertex format), should try use gldrawelementsbasevertex render particular "submesh", rather making separate glvertexattribpointer calls each submesh.

the idea there make vbo 1 long array, of every submesh's vertices in same array. each submesh stores base offset index data, count of vertices render, , base vertex offset, represents index submesh's data starts in big array.

at start of rendering submeshes, make one set of glvertexattribpointer calls. , it's glbindtexture , gldrawelementsbasevertex on. don't call glvertexattribpointer ever each submesh. use basevertex define each submesh's data comes in vbo.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -