Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

jmakitalo

Member Since 05 Apr 2006
Offline Last Active May 21 2013 10:50 AM
-----

Posts I've Made

In Topic: Rendering Doom 3 models, HORRIBLE texture seams.

13 March 2013 - 05:43 AM

One problem with md5mesh format is that it does not store normal vectors, so the mesh needs to be smoothed after it is loaded. If the artist used some custom smoothing schemes when baking the normals, the renderer has no chance of getting the correct results. I guess that Doom 3 smoothes the meshes uniformly or uses some sort of fixed threshold smooth angle, which is then also used when baking the normal maps.

 

Note that at texture seams, there are degenerate vertices, which should have the same normal. To properly smooth the mesh, it is not sufficient to compare if two faces share the same vertex index, but you must actually compare the vertex positions, possibly with some threshold distance.


In Topic: +4 bones vertex skinning

05 February 2013 - 07:00 AM

I'm confused. Is was under the impression that in fact this is the "bind pose approach" - these weight positions are provided only in bind pose (scratch that, they are pose independant, they only inform about mesh "volume", combined with bones, bind pose or not, they give the final result) and I also have bind pose skeleton provided. So how do I get rid of these weight positions? What's the usual approach here? Right now I have bind pose skeleton but in fact I don't use it while animating. It's only helpful when "unpacking" animation (skeleton) frames but it looks like there's a reason it's there. I have no idea if Doom3 uses these weight positions in shaders. I just followed mentioned tutorial and ended up here.

 

I animate MD5 meshes in a way C0lumbo implied. Post multiply your animation pose matrices with the inverse bind pose. Then you can just send the bind posed vertices to the GPU.

 

I'm not sure how animating is done in Doom 3, but maybe it is possible that they did not use GPU skinning, because they needed the transformed vertices for constructing shadow volumes. Then it should be faster to have the vertices in weight space so that post multiplication by inverse bind pose is avoided.


In Topic: Trouble with very slow rendering with nvidia under Linux

05 February 2013 - 06:52 AM

Which drivers are you using? The default open source drivers have poor 3D performance, so make sure you have the nvidia's closed drivers installed.


In Topic: Summary of best VBO practices

21 January 2013 - 07:11 AM

Katie made the point that you shouldn't try to second-guess the driver, and this is so true. When you're writing this kind of code you are no longer in the software-only realm, and things that you think may make sense to do might actually turn out to be the worst possible choice. That, to me, is the single most important point here - if you're of a mindset that "doing X is better because it saves memory", etc, you need to shake that mindset off quite quickly.

 

Yes, this sounds probable. Although it seems to me that the best way to go in this sort of things tends to change over time.

 

I also read that calling glVertexAttribPointer is very expensive. I would guess that if I can squeeze about 100 meshes into a single VBO, it would make sense to first sort by VBO and then by texture, although texture binds are also expensive. Having only a few large VBO:s is also probably good from the point of view of LOD. If each mesh would have its own VBO, then adding levels of detail would increase the number of buffer binds, which could diminish the benefit of having LOD in the first place.


In Topic: Summary of best VBO practices

20 January 2013 - 01:34 PM

"Should I put all vertex data to a single VBO?"

Whereever possible, yes. It means the whole vertex will be pulled into a cache at the same time. By having multiple VBOs, you're using multiple memory units which means multiple caches need to be loaded. Each will contain the vertex data for more vertices, but that's not necessarily useful; if you use the coords for a vertex, you'll use the normal data and probably quite soon, so the memory effort in loading it is useful.

If you have multiple memory units loading many verts into their cache, their effort may well be wasted -- touching vertex V implies nothing about when or even whether you will need the data for vertex V+1.

"If a group has, say 4000 polygons (which could happen for the player models), is it advisable to call glDrawElements once for the whole chunk, or should I cut it into pieces?"

Do the whole thing. Reason; let the driver do the optimisation work. It knows what shape the hardware is, and you don't. Don't try and second guess it unless you have a known crap driver you're trying to work round. Some drivers, for example, may take the min/max vert index and transform everything in that range and then bin the unused values. If you unchunk the data, they'll obviously waste more time on unused nodes. For the same sorts of reasons, try and make sure all the verts in a chunk are adjacent in your VBO.

You're also likely to transform verticies on the split boundaries more than once, whereas as one draw, they'll likely only be done once.
Ok, thanks for your insight. And I guess that interleaving is useful, if all attributes are used, but maybe not so if only e.g. position data is used (like for shadowmaps).

I'm thinking of writing a VBO manager that is passed to mesh classes and such to unify vertex data management. I was thinking of writing two classes: CVertexArrayObject to store one vbo for attributes, a vertex array object and one index buffer, and CVertexArrayManager, which would create new vertex arrays whenever a buffer size exceeds some threshold. Something like
class CVertexArrayObject
{
private:
  GLuint vaoID;
  GLuint vboID;
  GLuint indexID;
// ...
};

class CVertexArrayManager
{
private:
  std::vector<CVertexArrayObject*> objects;

  // ...

public:
  CVertexArrayManager();
  ~CVertexArrayManager();

  // Maximum buffer sizes.
  void setVertexBufferSize(int _vbSize);
  void setIndexBufferSize(int _ibSize);

  // Request new buffer, which is identified by index to object
  // and offset within the buffer of the object.
  bool allocateVertexBuffer(int size, int &objectIndex, int &offset);
  bool allocateIndexBuffer(int size, int &objectIndex, int &offset);

  // Bind object for rendering (vertex attribute buffers and index buffer).
  void bindObject(int objectIndex);

  // Write index data to allocated buffer.
  void fillIndexBuffer(int objectIndex, int offset, GLushort *indices, int nindices);

  // Write vertex data to allocated buffer.
  // Data is a struct array containing interleaved data.
  template <class T>
  void fillVertexBuffer(int objectIndex, int offset, const T *data, int size);
};

An instance of the manager would then be passed to a mesh class, which would fill the buffers with its data. What do you think?

PARTNERS