DGL
https://delphigl.com/forum/

vbo considerations for glmodel
https://delphigl.com/forum/viewtopic.php?f=19&t=8910
Seite 1 von 1

Autor:  noeska [ Sa Jan 02, 2010 16:34 ]
Betreff des Beitrags:  vbo considerations for glmodel

With openg3 i need to supply a new rendering path to glmodel.
For now i started with updating the opengl 1.5 vbo path that is very broken.

With my old opengl 1.0 render path i just rendered the vertices etc in order and insterted glend/glbegin when a material change was needed. Now with buffers that is no option.

So what is the best way?
-a vbo per mesh object or a vbo per model. With a vbo per model i would loose the ability of enabling/disabling certain meshed so that is no option.
-but a vbo per mesh object is not enough as i am the unable to change materials(e.g. textures) inbetween.
-so i need multiple vbo's per mesh object, one per material.
That makes me wonder is there a limit to the number of vbo's i can use at once?

Next when i go implement a proper opengl3 path i need to find a way to replace the lighting and material way i use now. For just color i then would be able to use buffer again, but could the same also be used for changing textures, e.g. by providing texture id's in a buffer?

Or is there a different much better way i have not thought about yet?

Thanks in advance for thinking along with me.

Autor:  Skeptiker [ Sa Jan 02, 2010 17:03 ]
Betreff des Beitrags:  Re: vbo considerations for glmodel

Well, i use two different solutions, first one: Order your Vertices by Material, bind the Material and Draw just the part of your VBO (See: http://wiki.delphigl.com/index.php/glDrawArrays and http://wiki.delphigl.com/index.php/glDrawElements) that has the same material, then with the next Material the same thing. Second solution: Add a Material Index to your vertices (For example (Vertex Format): x,y,z,nx,ny,nz,material_index) and pass it to a shader, now bind - via uniform variables - your materials and render it there.

Hope i could help you.

Autor:  noeska [ Sa Jan 02, 2010 19:07 ]
Betreff des Beitrags:  Re: vbo considerations for glmodel

So i can make one big vbo. And next i only render parts from it allowing to change material. Like you say the vbo should be filled so that vertices with the same material are in order. Also i should keep track where a material begins and ends in order to render the correct part of the buffer.

I keep your idea of storing material id's for the openg3 path. The only trouble i fear with this is changing textures?

Autor:  Skeptiker [ Sa Jan 02, 2010 19:11 ]
Betreff des Beitrags:  Re: vbo considerations for glmodel

noeska hat geschrieben:
I keep your idea of storing material id's for the openg3 path. The only trouble i fear with this is changing textures?


Whats about texture-ids in the Vertices and uniforms for every Texture? But i would prefer this way: Take all your 2D Textures and generate a 3D Texture, instead of switching between all of your 2D Textures you can use the third dimension of the texture coordinates as an "Index" and you dont have to bind more than one texture to your shader.

Autor:  Lord Horazont [ Sa Jan 02, 2010 19:46 ]
Betreff des Beitrags:  Re: vbo considerations for glmodel

Beware, there are also limitations how many layers a 3d texture can have.

I would say, you are better off with one index array per material containing the indicies („pointers“) of the vertices belonging to that material. So you only need one draw call per material and you can sort by materials. You can also place the vertices at any position in the vertex buffer you like.
If you need to disable each separate mesh you would need an index array per material per mesh of course.

Also you should consider that different materials may have different shaders (Phong vs. Blinn e.g. or even water shaders) and you should really avoid an „uber-shader“ which handles any material.

good luck ;)

Autor:  noeska [ So Jan 03, 2010 00:45 ]
Betreff des Beitrags:  Re: vbo considerations for glmodel

Lord Horazont hat geschrieben:
good luck ;)

Thanks i need that, because for now i totaly fail at creating indices per mesh per material... :( Am i supposed to keep alle the vertex data in one buffer or do i also need to split that up per material?

Autor:  Lord Horazont [ So Jan 03, 2010 11:27 ]
Betreff des Beitrags:  Re: vbo considerations for glmodel

No, you can keep the data in one VBO. You even need to have the vertices which are referenced by one index array also in one vbo.

greetings

Autor:  noeska [ So Jan 03, 2010 14:02 ]
Betreff des Beitrags:  Re: vbo considerations for glmodel

The problem is that i appear to missing some vertices for certain materials making a mess of the endresult. If you want you may want to look at latest version of glmodel in svn the files that matter are the ones is glvbomesh.pas ... I must be doing something very wrong but i cannot see it for now :-(

Autor:  noeska [ So Jan 03, 2010 16:10 ]
Betreff des Beitrags:  Re: vbo considerations for glmodel

Made some progress now the static meshes work, but i am having some problems with updating when bone and skin with animation is applied ... So milkshape ascii models dont work for now with the vbo render path.

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/