Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
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  
  Slow Vertex Arrays - NIO Evil??  (Read 3944 times)
0 Members and 1 Guest are viewing this topic.
Offline Vorax

Senior Member


Projects: 1


System shutting down in 5..4..3...


« Posted 2005-06-10 05:23:48 »

In the constant pursuit of improving peformance of my engine, I discovered something very surprising - Vertex Arrays aren't actually any faster then immediate rendering.

For shits and giggles, I removed the call to the vertex arrays and called the immediate mode renderer method instead.  My FPS actually increased by 1!

Here is the Array code:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
        // Vertices
       gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
        gl.glVertexPointer(3, //3 components per vertex (x,y,z)
           GL.GL_FLOAT, 0, vertex_buffer);

        // Color 3 (OPTIMIZATION ASSUMPTION: Only 1 color per object)
       if (color_buffer3 != null) {
          gl.glColor3f(color_buffer3.get(0),color_buffer3.get(1), color_buffer3.get(2));
        }

        // Color 4
       if (color_buffer4 != null) {
          gl.glEnableClientState(GL.GL_COLOR_ARRAY);
          gl.glColorPointer(4, //4 components per color (r,g,b,a)
             GL.GL_FLOAT, 0, color_buffer4);
        }

        // Texture coordinates 2D
       if (coords_buffer1 != null) {
          gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY);
          gl.glTexCoordPointer(2, //2 components coord
             GL.GL_FLOAT, 0, coords_buffer1);
        }

        // Normals
       if (normal_buffer != null) {
          gl.glEnableClientState(GL.GL_NORMAL_ARRAY);
          gl.glNormalPointer(GL.GL_FLOAT, 0, normal_buffer);
        }

        gl.glDrawArrays(GL.GL_TRIANGLES, 0, vertex_buffer.limit()/3);

        // Reset client state
       if (normal_buffer != null)
          gl.glDisableClientState(GL.GL_NORMAL_ARRAY);

        if (coords_buffer1 != null)
          gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY);

        if (color_buffer3 != null || color_buffer4 != null)
          gl.glDisableClientState(GL.GL_COLOR_ARRAY);

        gl.glDisableClientState(GL.GL_VERTEX_ARRAY);


This is the immediate mode renderer code:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
        // Render
       gl.glBegin(GL.GL_TRIANGLES);

        // engine only uses one color per geo object, so all verts should
       // have the same color, UNLESSS multi_color is explicitly set
       if (color_buffer3 != null && !multi_color) {
          gl.glColor3f(color_buffer3.get(0), color_buffer3.get(0 + 1),
              color_buffer3.get(0 + 2));
        }
        if (color_buffer4 != null && !multi_color) {
          gl.glColor4f(color_buffer4.get(0), color_buffer4.get(0 + 1),
              color_buffer4.get(0 + 2), color_buffer4.get(0 + 3));
          colors4 += 4;
        }

        for (int i = 0; i < vertex_buffer.limit(); i += 3) {

          if (multi_color) {
            if (color_buffer3 != null) {
              gl.glColor3f(color_buffer3.get(i), color_buffer3.get(i + 1),
                  color_buffer3.get(i + 2));
            }
          }

          if (normals != null)
            gl.glNormal3f(normal_buffer.get(i), normal_buffer.get(i + 1), normal_buffer.get(i + 2));

          if (app != null && app.getTexture() != null)
            if (coords_buffer1 != null) {
              gl.glTexCoord2f(coords_buffer1.get(texInd), coords_buffer1
                  .get(texInd + 1));
              texInd += 2;
            }

          gl.glVertex3f(vertex_buffer.get(i), vertex_buffer.get(i + 1), vertex_buffer.get(i + 2));

        }
        gl.glEnd();


The effect of both is identical in terms of what they render (actually the immediate mode can handle colors per vertex..but I don't use them anyway) and how they get their data, but the immediate mode runs 1 FPS faster! 

Is this an evil of NIO?  Is it that under the hood copying the data to the card from the NIO buffer takes just as long as it would to call the glXXXXX methods anyways?

Offline eraboin

Senior Newbie





« Reply #1 - Posted 2005-06-10 05:39:20 »

I'm not sure what's different about your code, but I notice a massive drop in framerate when I stop using glDrawArrays.
Offline Vorax

Senior Member


Projects: 1


System shutting down in 5..4..3...


« Reply #2 - Posted 2005-06-10 05:55:24 »

Hmm...  Maybe it's something to do with my video card?  Geforce 5500FX, latest drivers.   I find that unlikely though, because nVidia is pretty hard core about opitimizing and vertex arrays have been around since OpenGL 1.1.  I would think they would have optimized it as much as possible long ago.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline eraboin

Senior Newbie





« Reply #3 - Posted 2005-06-10 06:33:40 »

How many polygons are in your array, and how are you allocating it?
Offline Vorax

Senior Member


Projects: 1


System shutting down in 5..4..3...


« Reply #4 - Posted 2005-06-10 06:36:40 »

It's actually several arrays that compose the objects on screen.  They range from about 100-1000 verts each plus corresponding normals and texture coordinates, all sent as arrays.  Each are allocated as direct ByteBuffers, then tranformed into FloatBuffers (long before the rendering stage).

Offline eraboin

Senior Newbie





« Reply #5 - Posted 2005-06-10 06:45:55 »

I tried using ByteBuffer.allocateDirect(size).asFloatBuffer() early on and it wasn't working for me... so I found the BufferUtils class in jogl. Now I'm using BufferUtils.newFloatBuffer(size) instead.

I have no idea if it makes a difference or not.
Offline Vorax

Senior Member


Projects: 1


System shutting down in 5..4..3...


« Reply #6 - Posted 2005-06-10 06:50:30 »

That method does the same thing - Allocates a direct ByteBuffer the gets a FloatBuffer from that.  If doing it yourself  wasn't working, you were probably forgeting to set the ByteBuffer to native order.

Offline eraboin

Senior Newbie





« Reply #7 - Posted 2005-06-10 07:09:34 »

Ok... so with buffer.order(ByteOrder.nativeOrder()); added into the code, it now works just as well as the BufferUtils method.
Offline pepijnve

Junior Member




Java games rock!


« Reply #8 - Posted 2005-06-10 10:25:24 »

If the your ByteBuffers are direct buffers, there shouldn't be any copying. That's kind of the point of these things Smiley
It's really strange that the frame rate actually increases when rendering without vertex arrays, since you're doing many extra JNI calls. The overhead of those must not be as big as I thought. Maybe you could use the TraceGL pipeline to check if you're making unnecessary calls in the vertex array case? Or the DebugGL to check for errors?
Something you could also try is reducing the number of glEnable/DisableClientState calls you are making. Calling these methods probably triggers a state validation in the driver which might slow things down. The enabling and disabling of the vertex array for instance seems pointless since you are always using it.
IIRC going from vertex3f to drawArrays made a big difference in my rendering code. Something that can give you a boost as well is using triangle strips and/or fans instead of triangles (don't know if this is feasible in your specific case of course).
Offline princec

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #9 - Posted 2005-06-10 11:18:42 »

Doing a pure glDrawArrays direct from system RAM is the worst way to use vertex arrays. It's probably doing a copy from system RAM into AGP RAM and thence onwards to the card, every frame; and what's more if you're filling the system RAM buffers up with data every frame you've shafted your cache unneccessarily. You need to be using, at the very least, glDrawRangeElements; EXT_compiled_vertex_array is a crap extension and shouldn't be used any more. NV_vertex_array_range2 is the next best solution on Nvidia cards. And the very best way to do it is Vertex Buffer Objects.

What's more this bit of code quite easily could just be a microbenchmark anyway with all the silliness that entails. No mention of overheads, number of vertices, pixels drawn, fill rates, etc. etc. It's a testament to Nvidia's driver writers that they've got immediate mode as fast as plain vertex arrays in your special case.

Cas Smiley

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline pepijnve

Junior Member




Java games rock!


« Reply #10 - Posted 2005-06-10 13:35:35 »

I'm curious as to what makes glDrawRangeElements inherently more efficient than glDrawArrays?
Offline princec

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #11 - Posted 2005-06-10 14:31:06 »

The way glDrawArrays works is that you are effectively saying, "all this data needs to be drawn, entirely, now." but rarely do you actually have this situation. Normally you are drawing chunks of elements from a big load of vertex data. So typically you'll be using glDrawElements anyway. But underlying it all:

glDrawArrays can be implemented by the drivers in various ways but one of the ways it'll be optimised is to copy system RAM data out to AGP, and then let the card suck it over in its own time. It's not that glDrawArrays is slow; its the particular kind of RAM you're using that's slow. The usage of glDrawArrays won't make any difference here - it's purely down to where those buffers came from.

Now then.. glDrawRangeElements specifies a minimum and maximum bounds for the indices normally used by glDrawElements. What this does is precisely enable the drivers to determine the range of vertex memory pointed at, and copy only that which it is necessary to copy over to AGP RAM (along with a few other optimisations). If that data is already in AGP RAM by virtue of NV_vertex_array_range or VBOs, then the optimisations are not nearly as significant.

I'm wired on coffee and starving so I might be rambling and not making much sense here.

Cas Smiley



Cas Smiley

Offline pepijnve

Junior Member




Java games rock!


« Reply #12 - Posted 2005-06-10 16:12:03 »

Hmm, I can't say I completely understand yet. Given the following methods:
1  
2  
3  
void glDrawArrays(GLenum mode, GLint first, GLsizei count);
void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
void glDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);

The only difference between glDrawArrays and glDraw(Range)Elements is the use of indirection via the indices array. I don't see how one of these methods could be noticeably more effient than the other. To me it seems that they just serve different purposes. If you don't need the indexing provided by draw(Range)Elements, why use it in the first place?
I have to admit I've never done any low level OpenGL profiling/debugging so I'm only looking at this at an API level...
Offline pepijnve

Junior Member




Java games rock!


« Reply #13 - Posted 2005-06-10 16:45:39 »

Thought about this a bit more...
The only way I see glDraw(Range)Elements being inherently faster than glDrawArrays is if you reuse vertices multiple times. Using the draw(Range)Elements methods you just refer to them multiple times in the indices array, whereas with drawArrays you have to repeat the vertex/color/tex coord data each time, which means you're pushing more data to the video card. Wild guess, but maybe the driver can also reuse calculations if it encounters the same index twice?
Does this make any sense?
       
Offline princec

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #14 - Posted 2005-06-10 17:58:52 »

It's specifically to do with optimising what data the drivers send over to the graphics card. If you've already decided what format and where the data is going to be by using VBO or NVVAR, it's neither here nor there - probably (unless theres some interesting "paging" or "windowing" or something going on in the hardware AGP bus). The drivers may still copy your data into a more efficient format. But in the case of plain old direct buffers of vertex data, the driver has absolute discretion of how it's going to get the data to the card and this usually involves it copying it to AGP RAM. If you are able to be more specific about what data you're going to be needing you should use glDrawRangeElements because then the driver doesn't need to needlessly copy tons of data or parse the entire index array to work out a min/max vertex.

Cas Smiley

Offline Vorax

Senior Member


Projects: 1


System shutting down in 5..4..3...


« Reply #15 - Posted 2005-06-10 18:53:12 »

Doing a pure glDrawArrays direct from system RAM is the worst way to use vertex arrays. It's probably doing a copy from system RAM into AGP RAM and thence onwards to the card, every frame; and what's more if you're filling the system RAM buffers up with data every frame you've shafted your cache unneccessarily.

Well, if the entire array needs to be drawn, this is supposed to be the fastest way because it causes the least indrection, as opposed to the other GL array functions which are better at working with portions of arrays.

Quote
You need to be using, at the very least, glDrawRangeElements; EXT_compiled_vertex_array is a crap extension and shouldn't be used any more. NV_vertex_array_range2 is the next best solution on Nvidia cards. And the very best way to do it is Vertex Buffer Objects.

glDrawRangeElements is better if you only want to use a portion of the data, I am drawing all vertices, normals and tex coords.  Using drawRangeElements wouldn't improve it.  VBO's would, but that's VBO's not vertex arrays and not OpenGL1.1.

Quote
What's more this bit of code quite easily could just be a microbenchmark anyway with all the silliness that entails. No mention of overheads, number of vertices, pixels drawn, fill rates, etc. etc. It's a testament to Nvidia's driver writers that they've got immediate mode as fast as plain vertex arrays in your special case.

Cas Smiley

This not a full blown benchmark but it's a pretty realistic one.  It's the renderer in my game for the ships and cockpit.  It's a very diverse set of data ranging from small to farily large quantities of vertices and different combinations of normals - no normals, tex coords - no tex coords.  The test is to remove the static objects (roids, planets, etc) and leave nothing but moving objects and then restrict all movement of the ships, but allow them to rotate. 

I do agree this is a testament to nVidia's drivers, but I really don't think this is a special case.

Offline Vorax

Senior Member


Projects: 1


System shutting down in 5..4..3...


« Reply #16 - Posted 2005-06-10 19:23:58 »

The way glDrawArrays works is that you are effectively saying, "all this data needs to be drawn, entirely, now." but rarely do you actually have this situation. Normally you are drawing chunks of elements from a big load of vertex data. So typically you'll be using glDrawElements anyway. But underlying it all:

I have that situation all the time.  My vertex arrays are all self contained in a scene graph structure.  Frustum culling determines exactly which nodes need to be drawn and then they draw themselves entirely.  This isn't a sliced buffer, each has it's own.  glDrawArrays isn't supposed to be faster for data transfer (though you save some), the performance boost is supposed to be in requiring less OpenGL calls..alot less calls.  The same amount of data or less will go to the card either way.  What I don't understand is why it's not doing what it says on the box....faster because uses far less OpenGL calls and cards may be able to optimize becuase of predictability of the vertexes being rendered (they are all triangles to render for the next 1000 verts for example).



Offline Vorax

Senior Member


Projects: 1


System shutting down in 5..4..3...


« Reply #17 - Posted 2005-06-10 19:37:05 »

It's specifically to do with optimising what data the drivers send over to the graphics card. If you've already decided what format and where the data is going to be by using VBO or NVVAR, it's neither here nor there - probably (unless theres some interesting "paging" or "windowing" or something going on in the hardware AGP bus). The drivers may still copy your data into a more efficient format. But in the case of plain old direct buffers of vertex data, the driver has absolute discretion of how it's going to get the data to the card and this usually involves it copying it to AGP RAM. If you are able to be more specific about what data you're going to be needing you should use glDrawRangeElements because then the driver doesn't need to needlessly copy tons of data or parse the entire index array to work out a min/max vertex.

Cas Smiley

Although that's all true, it still doesn't apply if you do actually want to render all the buffers pointed to entirely, which I do.  For a bulk render, where all the buffers pointed to through glVertexPointer, glNormalPointer, etc. is needed, drawArrays should be faster then drawElements...and it should be much faster then using the immediate calls.  According to the red book, the only reason it would be as slow as immediate calls is if I have geometry saturation on the card, which really means that the card itself has become the bottleneck...which can't be the case.  Considering JNI's overhead, in Java I would expect it to outperform the immediate calls by even more then in C. 

Offline pepijnve

Junior Member




Java games rock!


« Reply #18 - Posted 2005-06-11 09:51:04 »

From the OpenGL man pages:
Quote
Implementations denote recommended maximum amounts of vertex and index data, which may be queried by calling glGet with argument GL_MAX_ELEMENTS_VERTICES and GL_MAX_ELEMENTS_INDICES. If end - start + 1 is greater than the value of GL_MAX_ELEMENTS_VERTICES, or if count is greater than the value of GL_MAX_ELEMENTS_INDICES, then the call may operate at reduced performance.
This bit is only mentioned in the context of glDrawRangeElements, however it might be equally valid for glDrawArrays. Maybe you can try limiting the amount of data you are passing by doing multiple calls to glDrawArrays taking that GL_MAX_ELEMENTS_VERTICES value into account. I don't have a clue about all the memory transfers involved, but it might be worth a try Smiley
Offline princec

JGO Kernel


Medals: 282
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #19 - Posted 2005-06-11 15:03:02 »

Hang on a sec: it really is a rare case to call glDrawArrays unless you have some very peculiar characteristics of your scenegraph. These scenegraphs notably being that the entire scene has a single rendering state (texture, same vertex format) and I can't think of many games where this is the case. Even my crappy 2D games have tons of different rendering states operating on the same vertex data.

Cas Smiley

Offline eraboin

Senior Newbie





« Reply #20 - Posted 2005-06-11 18:16:25 »

By the way... this is a slightly different question, but it's on the same subject. I have my program loading ms3d models into vertex arrays / vertex buffer objects (it does both, it just checks first) but I'm curious what's the best way to handle skeletal animations.

I don't think I should be running through my entire array every frame and rewriting the position of each vertex. It's bad enough to do that with regular arrays, but doing it with put() seems slightly disingenuous. OpenGL handles transformations really well when you use rotatef/translatef etc. It's a hell of a lot faster than using my own matrix calculations anyway, but I don't know how to apply it to my model as it's being rendered. Do I just need to keep track of how the vertices have been transformed, and just push/pop transformations as I render them? Or is there some way to use opengl for a transformation and have it actually return the transformed vertices?
Offline Vorax

Senior Member


Projects: 1


System shutting down in 5..4..3...


« Reply #21 - Posted 2005-06-11 18:40:24 »

Hang on a sec: it really is a rare case to call glDrawArrays unless you have some very peculiar characteristics of your scenegraph. These scenegraphs notably being that the entire scene has a single rendering state (texture, same vertex format) and I can't think of many games where this is the case. Even my crappy 2D games have tons of different rendering states operating on the same vertex data.

Cas Smiley

You must be using one large block of ram and then splitting it up.  In a 2D game that is fine, but in a 3D game, there is way to much data, unless you force everyone into a minimum of 128MB cards or make them deal with major thrashing....one large detailed terrain alone could thrash a 16MB card Smiley

Fortunetly, there are lots of cases in a 3D engine where the only thing that changes is the data, not the state.  Models typically consist of hundreds to thousands of vertices using the same format for textures, colors, normals etc.

As a simplified example - picture a model of a sphere composed of 16x16 segments with colors and texture (default modulate), done with floats, rendered as triangles.

  • 1536 vertices
  • 1536 normals
  • 1536 colors (rgb)
  • 512 texture coordinates

Total amount of data that must get to the card to render a single frame: 17920 bytes  (4 bytes per float, and exluding texture upload)

Immediate mode calls necessary:   6144
GL pointer calls with glDrawArrays:  13 including state changes

This is why I am confused - The JNI savings alone are huge and the data comes in a pointer to an unsegmented block of RAM that is already in a format ready for the native GL calls.


Offline Vorax

Senior Member


Projects: 1


System shutting down in 5..4..3...


« Reply #22 - Posted 2005-06-11 18:42:15 »

From the OpenGL man pages:
Quote
Implementations denote recommended maximum amounts of vertex and index data, which may be queried by calling glGet with argument GL_MAX_ELEMENTS_VERTICES and GL_MAX_ELEMENTS_INDICES. If end - start + 1 is greater than the value of GL_MAX_ELEMENTS_VERTICES, or if count is greater than the value of GL_MAX_ELEMENTS_INDICES, then the call may operate at reduced performance.
This bit is only mentioned in the context of glDrawRangeElements, however it might be equally valid for glDrawArrays. Maybe you can try limiting the amount of data you are passing by doing multiple calls to glDrawArrays taking that GL_MAX_ELEMENTS_VERTICES value into account. I don't have a clue about all the memory transfers involved, but it might be worth a try Smiley

That shouldn't matter in this case.  I am well below any limits and I am not using glGet.

Offline Vorax

Senior Member


Projects: 1


System shutting down in 5..4..3...


« Reply #23 - Posted 2005-06-11 18:47:28 »

By the way... this is a slightly different question, but it's on the same subject. I have my program loading ms3d models into vertex arrays / vertex buffer objects (it does both, it just checks first) but I'm curious what's the best way to handle skeletal animations.

I don't think I should be running through my entire array every frame and rewriting the position of each vertex. It's bad enough to do that with regular arrays, but doing it with put() seems slightly disingenuous. OpenGL handles transformations really well when you use rotatef/translatef etc. It's a hell of a lot faster than using my own matrix calculations anyway, but I don't know how to apply it to my model as it's being rendered. Do I just need to keep track of how the vertices have been transformed, and just push/pop transformations as I render them? Or is there some way to use opengl for a transformation and have it actually return the transformed vertices?

Off topic but --  basically push and pop is what you need for each group as they are transformed from their parents coordinate system.  To do full skelatal is a more complicated then that though and will require some inverse kinematics

Offline eraboin

Senior Newbie





« Reply #24 - Posted 2005-06-11 19:07:06 »

ok... should I use glDrawRangeElements for that? Because a bone may influence only part of a mesh.

I don't need to do anything fancy with the skeleton stuff, since MS3D lets you model animations yourself and just specify keyframes. It gives you rotation/position keyframes for all the joints, and you can just interpolate the frames in between. My main issue is doing it quickly, and applying my own transformations in Java (which I could have done) is just slow as molasses.
Offline Vorax

Senior Member


Projects: 1


System shutting down in 5..4..3...


« Reply #25 - Posted 2005-06-11 19:13:53 »

It all depends on how the data for your models is allocated.  If all the data for the model is in a single buffer, then yes, you will want to use the finer grain calls to operate on subsets of the vertices...if all the data for ALL your models is allocated in a single buffer, you'll get the thrashing I described above unless the user has an ubber card and you'll have no choice but to use the fine grain calls.

Offline tom
« Reply #26 - Posted 2005-06-11 20:36:33 »

It's actually several arrays that compose the objects on screen.  They range from about 100-1000 verts each plus corresponding normals and texture coordinates, all sent as arrays.  Each are allocated as direct ByteBuffers, then tranformed into FloatBuffers (long before the rendering stage).
There is probably some overhead in enableing/disableing the client state and calling glDrawArrays. Have you tried using vertex arrays only when there are many verts, like atleast 500. Can you find a breaking point where vertex arrays are faster than immediate mode?

It migh also be the case that transfering the vertices to the card is not the bottleneck. That when using immediate mode you are feeding the card at exactly the right pace. Still strange that vertex arrays are slower.

If I were in your situation I would start making a whole lot of tests to find out what was going on.

Offline eraboin

Senior Newbie





« Reply #27 - Posted 2005-06-11 21:36:41 »

Quote
if all the data for ALL your models is allocated in a single buffer, you'll get the thrashing I described above unless the user has an ubber card and you'll have no choice but to use the fine grain calls.

I'm creating a buffer for each mesh, since vertices are not shared between meshes. I still have a big problem though, since knowing how to divide up the vertices is not the same as dividing up the triangles. There can be any number of triangles in a mesh which are composed of vertices bound to separate joints, meaning they stretch when the bones move, and don't just rotate/translate. The only way to do this is transform some of the vertices and not others, so you can't really break these triangles into 'groups' and render them all at once. If I push/pop matrices for every transformation, I'd have to do so multiple times for each of the triangles which share these vertices.

I've been searching around all over the place for an elegant solution to this problem. With every major video game using skeletal animation these days, I cannot believe they're doing all the transformations in software. What are they doing differently?
Offline tom
« Reply #28 - Posted 2005-06-12 00:16:52 »

Quote
if all the data for ALL your models is allocated in a single buffer, you'll get the thrashing I described above unless the user has an ubber card and you'll have no choice but to use the fine grain calls.

I'm creating a buffer for each mesh, since vertices are not shared between meshes. I still have a big problem though, since knowing how to divide up the vertices is not the same as dividing up the triangles. There can be any number of triangles in a mesh which are composed of vertices bound to separate joints, meaning they stretch when the bones move, and don't just rotate/translate. The only way to do this is transform some of the vertices and not others, so you can't really break these triangles into 'groups' and render them all at once. If I push/pop matrices for every transformation, I'd have to do so multiple times for each of the triangles which share these vertices.

I've been searching around all over the place for an elegant solution to this problem. With every major video game using skeletal animation these days, I cannot believe they're doing all the transformations in software. What are they doing differently?

Skinning can be done in vertex shaders. I'm guessing that is what most games are doing. But of course, it also provides a path that does it in software if the card don't support vertex shaders.

So you need to provide a software option. You just have to optimize the code to make it as fast as possible. This is one case where java is slower than c/c++, but still adequate.

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.

xsi3rr4x (36 views)
2014-04-15 18:08:23

BurntPizza (32 views)
2014-04-15 03:46:01

UprightPath (47 views)
2014-04-14 17:39:50

UprightPath (30 views)
2014-04-14 17:35:47

Porlus (47 views)
2014-04-14 15:48:38

tom_mai78101 (68 views)
2014-04-10 04:04:31

BurntPizza (128 views)
2014-04-08 23:06:04

tom_mai78101 (228 views)
2014-04-05 13:34:39

trollwarrior1 (193 views)
2014-04-04 12:06:45

CJLetsGame (200 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
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!