VBO with few vertices

Started by
3 comments, last by bluntman 12 years, 11 months ago
[font=arial, sans-serif][size=2]Hi,

I read somewhere that should not create VBOs with few vertices, since this is getting worse performance than the direct rendering mode. Is this true?

I was creating a VBO for each part of the wall (100x100) of the scene. So that I could implement frustum culling efficiently. But this would imply having several VBOs with only 4 vertices and texture.

But also I thought of joining all vertices of a region of the wall in a single object, so theVBO would not be so small, but that would not be draw on the screen. This approachwould also get the code less intuitive, since the moment I have a class that representsa squared which is part of the wall (receiving as parameter in the constructor when creating the instance the overall position of four vertices).[/font]
[font=arial, sans-serif][size=2]
[/font]
[font=arial, sans-serif][size=2]I'm confused on how to organize my[/font][font=arial, sans-serif][size=2] basic[/font][font=arial, sans-serif][size=2] classes to have a good performance.[/font]
[font=arial, sans-serif][size=2]
Thanks[/font]
Advertisement
Firstly direct rendering is deprecated now as far as I know, and all rendering should use VBOs, IBOs and/or VAOs.
Secondly you should break your geometry up using IndexBufferObjects NOT VertexBufferObjects. My advice would be to pack up to 2**16 verts into a single VBO and then use a few IBOs to draw parts of it. e.g. you could put a few rooms all into a single VBO and then use an IBO for each wall section, door, ceiling, floor sections etc.

But, you probably don't want to cull down to single quads. It is more efficient generally to give the graphics card more work to do rather than to give the CPU more work to do. This is a very simplified statement, obviously there are exceptions, and profiling is the only way to be sure, and even then you are only sure on your own hardware. My advice would be don't cull until you need to. i.e. just render everything and see how fast it is. Chances are it is fast enough. If it isn't then break your geometry into rooms, and do manual PVS (potentially visible sets) and frustum culling. If this is still too slow then you may have a problem which more culling won't solve.

[font="arial, sans-serif"]I read somewhere that should not create VBOs with few vertices, since this is getting worse performance than the direct rendering mode. Is this true?
[/font]


I doubt it.
If you don't optimize your code, then yes, you lose a lot of performance.
Pack a lot of objects into 1 VBO.

Here you go
http://www.opengl.org/wiki/VBO_-_more#Size_of_a_VBO.2FIBO

and also
http://www.opengl.org/wiki/Buffer_Objects
http://www.opengl.org/wiki/General_OpenGL
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
[color=#888888][font=arial, sans-serif][size=2][color=#000000][size=2]Thanks for the replies. I'll try to use vertex arrays and VBO then to compareperformance, but it's hard to find tutorials for JOGL (I do not understand c + + very well).

I need to create an array of colors if I use texture? Is there any other kind of array formaterials?

My other doubt is about how to use simultaneously more than one texture?? Cause Iwant to do bump mapping, have a texture and other image with the normal, how do Iget to send two images to the GLSL?

[/font]

[color="#888888"][font="arial, sans-serif"][color="#000000"]but it's hard to find tutorials for JOGL (I do not understand c + + very well).[/font]


If you understand Java well, then you should understand the C++ examples well enough to implement them in Java. If you don't understand Java well then I would start there before trying to write complex programs like 3D games.
You should read the GL/GLSL API documentation to find out about binding parameters (including textures) and then come back if you don't understand it or can't get it to work.
This should get you going:
http://www.opengl.org/wiki/GLSL_Sampler#Binding_textures_to_samplers

This topic is closed to new replies.

Advertisement