Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (488)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (553)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Re-using VBOs | Several objects  (Read 991 times)
0 Members and 1 Guest are viewing this topic.
Offline Giovanni

Junior Member




chop!


« Posted 2012-03-28 20:23:36 »

Hi,
I have switched to VBOs some time ago and read several tutorials about them.

After reading them I got some questions:

1.) Do I have to create a Float Buffer (for example) for every object I create? I guess that slows things down. What would be a smart way to combine them then? For example range checking? Like if objects are far away I combine them to one FloatBuffer? Wouldn't a huge FloatBuffer be slow too?

2.) How do Indexed and Interleaved VBOs exactly work? I have seen that you use an IntBuffer to reuse vertices, but how does that work?

Thanks in advance.
Offline sproingie

JGO Kernel


Medals: 202



« Reply #1 - Posted 2012-03-28 20:51:06 »

1) Far away scenery objects are often billboarded, which reduces their model down to a quad or a couple triangles. Furthermore, repeated objects are instanced, which means only having one object.  Condensing multiple objects into an indexed buffer the way you might put multiple textures in an atlas is, I suppose doable, but I don't know if this technique is common or has a name.

2) An interleaved VBO puts vertices and their attributes in a single buffer so they alternate, as in (vertex,color,texcoord, vertex2,color2,texcoord2, etc), as opposed to separate buffers for each, or (even less common) separate contiguous sections of a buffer.  All three of these approaches are able to be indexed -- all an indexed buffer means is that you use an extra buffer containing the indexes of the vertices to draw instead of drawing the whole thing.  This is handy if you have a lot of repeated vertices, since you can just repeat indexes, so it's a sort of compression.

Offline theagentd
« Reply #2 - Posted 2012-03-28 22:28:02 »

Hi,
I have switched to VBOs some time ago and read several tutorials about them.

After reading them I got some questions:

1.) Do I have to create a Float Buffer (for example) for every object I create? I guess that slows things down. What would be a smart way to combine them then? For example range checking? Like if objects are far away I combine them to one FloatBuffer? Wouldn't a huge FloatBuffer be slow too?

2.) How do Indexed and Interleaved VBOs exactly work? I have seen that you use an IntBuffer to reuse vertices, but how does that work?

Thanks in advance.
1) No. Why would you need a float buffer for each object? Once you've uploaded data to a VBO there's should be no need to upload it again. I guess this depends on what you're drawing so please provide us with more info on that... If you want to draw a 3D model at two different places you'd just bind the VBO, set the matrix for the first instance, draw it, set the matrix to the second instance, draw it, e.t.c. You don't need a float buffer per object, let alone a VBO per object.

2) Sproingie covered interleaved data, but I'd like to add another thing about indexed vertex data.  If you don't use an index array, your GPU will transform 3 vertices, then build a triangle out of these. However, in a normal 3D model you'll end up with many duplicate vertices. Indexed vertices allows you to present a set of vertices, and then an index array which builds triangles out of them. This allows you to reuse vertices shared between triangles. Without indices, you need 3 vertices processed for each triangle. With indices you can build more triangles for less vertices. From my experience the average triangle/vertex ratio is over 1.0, meaning that there's more triangles than vertices. Example: Bob the dwarf. He has only 875 vertices but 1027 faces, meaning that each vertex is on average used more than 3 times. We're saving so much vertex processing by using indices when rendering 3D models. It's not really for compression, but for performance.

Myomyomyo.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

TehJavaDev (17 views)
2014-08-28 18:26:30

CopyableCougar4 (26 views)
2014-08-22 19:31:30

atombrot (39 views)
2014-08-19 09:29:53

Tekkerue (36 views)
2014-08-16 06:45:27

Tekkerue (33 views)
2014-08-16 06:22:17

Tekkerue (22 views)
2014-08-16 06:20:21

Tekkerue (33 views)
2014-08-16 06:12:11

Rayexar (69 views)
2014-08-11 02:49:23

BurntPizza (46 views)
2014-08-09 21:09:32

BurntPizza (37 views)
2014-08-08 02:01:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!