Jump to content
  • Advertisement
Sign in to follow this  
kRogue

OpenGL pretty sure one cannot do this, but maybe one can

This topic is 4945 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, ok, I have never seen this in any of the openGL docs that I have read, but I am hoping (very badly infact) that one can do the following via some funny magic with VBO's: I wish to arrange it so that the index associated to differnt vetex/tex-coord arrays can be different, let me be clear with the simplest of examples: take a typical MD2 model: it has a list of positions and a list of triangles. Each triangle has 3UV co-ordinates and 3 indexes to a position... the typical way one creates the MD2 rendering to use vertex/texCoord arrays is to just create a (potnetially larger in size) array of vertexes, and give them the corosponding texture coord point. if 2 different texute co-ordinates go to the same vertex, then duplicate that vertex.... it is not so bad for MD2, but as I get into rendering MD5 (from doom3) this issue is much worse with repsect to it's wieght/joint position: in a nutshell what it does: there is a list of points (consisting of a position in 3-space, together with a floating point number wieght between 0 and 1) and an index of what "joint" it is attachted to (this joint applies a translation and rotation in a heirarichal manner) now a triangle is made of up of (duh) 3 vertexes, and each vertex is just sum of the position of weights (after they have been transofrmed by the joint they are attached to) times the weight of that point..... the number of points used by a vertex is kind of small, what I have seen so far is always less that 10 points... what I would like to do: make an array of float4's WP, of all the wieght-points(about 1000-10000). make another array JO (of the same size of above ) of floats indicate which joint the wieght-point is attathced to, i.e. WP is attached to the joint JO for this case, just suppose each vertex uses no more then 10 point,wieghts. create 10 index arrays I1,I2, ... ,I10 , each storing for each vertex which wight,point that the vertex uses. finally create one index array TRI of what vertices one uses for ones triangles of the model. what I want to do is that when I issues some kind of "DrawTriangles" command and the vertex arrays are 20 arrays: WP,JO composed with each of the I* arrays.... so eg. Vertex_1=WP[ I1 ] Matrix_1=JO[ I1 ] Vertex_2=WP[ I2 ] Matrix_2=JO[ I2 ] what I want to avoid is the copying of the WP and JO arrays an extra 9 times, I want to say "permute" the arrays by my index arrays I1,I2, ... in C: for each joint node j, create its transfomratio matrix and store it say in vertexProgramMatrix[J], copy these values to ones vertexShader. associate Index1<==>Matrix_1 associate Index2<==>Mateix_2, . . associate Index10<==>Mateix_10, then in the vertexShader:
main(uniform flaot4x4 vertexProgramMatrix[numberOfJoints],
     in float4 Vertex1, in float4 Vertex2, ... , in float4 Vertex10,
     in float in Index1, in Index2, ... , in Index10,  
     /*whatever else*/
{
    outVertex= ModelViewProj( Vertex1.w*vertexProgramMatrix[Index1](Vertex1.xyz) + 
                          Vertex2.w*vertexProgramMatrix[Index2](Vertex2.xyz) + 
                          ...  +
                          Vertex10.w*vertexProgramMatrix[Index10](Vertex10.xyz)             

     return outVertex;
}





(if a vertex uses less that 10 wieght-points, just make the rest of the wieght indexes point to 0 vertex, or jsut add another arrays of floats indicating how far to add) so is there a way to avoid this extra copying of the arrays? since after all that I am after is just permatuations.... and on another note, another reason why I'd like this is so that I can calculate normal's in the vertexShader, since I can discipline myself to use only GL_TRIANGLES, and then I make 2 more "index"-style arrays so that I can recalculate the normal.. for example this vertexShader:
main(in vertex1, in vertex2, in vertex3, /*whatever else...*/)
{
  normal=cross(vertex2-vertex1,vertex3-vertex1),
  outVertex=ModelViewProj(vertex1);
  outNormal=ModelViewIT(normal);
}



since when one does bump mapping, one needs the normal vector and two vectors tangent to the surface of the triangle, passing the 3 vertexes takes just as many registers, and if the model gets deformed, like in skeletal-skin style animations, no worries about "fixing" those vectors... now if I wanted to do the above and I needed to copy the arrays again, one array of weight-points gets mutiplied into 3*MaxNumnerOfWightPointsOnVertex number of arrays! so.... you can see my wish to do this.... Best Regards

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!