optimized vertexBuffer length

Software: Away3D 4.x

Avatar
80prozent, Sr. Member
Posted: 05 October 2011 09:54 PM   Total Posts: 430

Hi

i am still working on a Cinema4d to away3d solution using xml.

i am trying to reduce the vertexbuffer length as much as possible, using shared vericles.

i am doing this in python while exporting. i loop through each point of each triangle, to check if a point with the same position and uv was allready spotted or if its a new one. this way i end up with a much smaller count of verticles than not using shared verticles (which would be triangle count * 3).

i imported the two example files(head.obj/soldier-ant.3ds) into c4d and exported them with my tool to away3d.

than i checked both my vertexbuffer lengths and the vertexbuffer lengths in the examples and was surprised that the vertexbuffers in the examples are still smaller than mine.

traces:

myTest (head.obj) =        17684 tris / 10780 verticles
away3d example (head.obj) = 17684 tris / 9203 verticles

myTest (soldierAnt.3ds) =        17384 tris / 18332 verticles
away3d example (soldierAnt.3ds) = 17384 tris / 8718 verticles

does anyone have a clue why this might be ?

while developing the function that get rid of shared verticles, i mostly used a simple cube and calculated the count of verticles it should export (for different uv mappings) to see if the functions works fine. so i think i can say my python-script exports only unique verticles and i really dont know how you could reduce this vertexbuffer-length even more.

one thing that caught my eye is, that for the head.obj (where my count of verticles is very close to the examples-verticles-count) its uv-mapping consist of only a few large uv-groups that doesnt overlay each other, while the ant.3ds (my count of verticles nearly doubles the example-verticles-count) has more uv-groups that overlay each other.

another thing i am worry about is that on my imported models in away3d i can clearly see the uv seams (on the back of head.obj) while in the example they are not visible at all. is that because i am not exporting any normalData?

thanks for any help.

 

 

 

 Signature 

sorry…i hope my actionscript is better than my english…

   

Avatar
theMightyAtom, Sr. Member
Posted: 06 October 2011 07:40 AM   Total Posts: 669   [ # 1 ]

I know nothing about Cinema 4D, but in 3D Studio MAX you would just select all faces and assign to the same smoothing group. That would remove duplicated vertices, with visual feedback of any potential problems.

Don’t know if that’s any help at all,

Good Luck!

   

Avatar
80prozent, Sr. Member
Posted: 06 October 2011 03:50 PM   Total Posts: 430   [ # 2 ]

hi
thanks for reply

i dont think that solves my problem, since i allready optimize my meshes with cinema4ds functions for that (preventing doubled verticles).
the thing is that cinema4d does not works with one indexbuffer for both uv and verticles, but with two indexbuffers, one presenting indexes to verticles in a verticles pool and the other presenting indexes to uv-points in a uv pool
.

example:
a simple cube consist of 12 triangles and 8 verticles, but depending on the uv mapping the count of different uv-points can be max 36 (if each triangle is mapped as its own uv group). to build the buffers for such a cube in away3d i would end up with 36 verticles, 36 uv points, and 12 triangles.

if the mapping of the cube would consist of more uv groups (more shared uv points) the count of used verticles/points would be smaller.

please tell me if anything i am saying is nonsense, but for me it all made pretty much sense and worked as i exspected it to work.
only when i checked the new examples and realised that the used buffers are smaller than mine i started wondering how this can be, and what i am doing wrong.

i am really stuck with this, since it doesnt make much sense to develop my exporter tool much further (i allready can export morhshapes and vertexanimations) as long i am not shure that the basic mesh is as optimized as it can be.

very gratefull for any help!

 Signature 

sorry…i hope my actionscript is better than my english…

   

Richard Olsson, Administrator
Posted: 06 October 2011 04:08 PM   Total Posts: 1192   [ # 3 ]

Sounds like you simply have a bug in your C4D exporter. Unfortunately I can’t help you at this point, but just to let you know that I have started experimenting with an AWD2 exporter for C4D, so expect that to arrive in a few month’s time. That should remove all needs of rolling your own exporter for Away3D.

   

Avatar
80prozent, Sr. Member
Posted: 06 October 2011 05:55 PM   Total Posts: 430   [ # 4 ]

@richard: i hope i am not bothering you to much, but i am not willing to give up yet. far to much time was spend allready…
i am shure your c4d exporter will work very well for awd2-export, but i would really like to be able to export a lot more cinema4d-spezific stuff than awd2 will allow. i allready succeeded in many things (for example the morphtag that controlls a whole hirarchy of objects, and animates not only the objects matrix, points and uv data, but also object-specific parameters).

please can you tell me if you agree with the statements i made in the previous posts. so i can know if its a bug in my code, or rather a error in my concept.

 Signature 

sorry…i hope my actionscript is better than my english…

   

Avatar
80prozent, Sr. Member
Posted: 06 October 2011 09:49 PM   Total Posts: 430   [ # 5 ]

i managed to export normal data and the uv seams are gone.

really glad for that.

now the models look like they should but are still using more vertex/uv/normal data as if loadet by obj or 3ds.

 Signature 

sorry…i hope my actionscript is better than my english…

   

Avatar
Choons, Sr. Member
Posted: 06 October 2011 11:00 PM   Total Posts: 281   [ # 6 ]

“but are still using more vertex/uv/normal data as if loadet by obj or 3ds.”

Hi Pro - can you explain that a bit more? Once a model is loaded in to Away3D it should always be consistent in how it is represented internally regardless of what export format you used to load it.

   

Avatar
80prozent, Sr. Member
Posted: 06 October 2011 11:36 PM   Total Posts: 430   [ # 7 ]

hi choons

as i explained in earlier posts its about using shared verticles vs unique verticles between different triangles.

if you would use 3 unique verticles/uv/normals for each triangle on a mesh with 10.000 triangles, you end up with 30.000 verticles/uv-points in your vertexbuffer.

however, the same 10.000 triangles could be displayed by using only 8.000 verticles (for example) since neigboured triangles can use the same verticle/uv-point.

when i import the head.obj into c4d i can see that it consists of 17684 triangles but only 8844 verticles. i cannot tell you of how many uv points it consists, but even with the best possible uv map (one big uv group) it must have more than 8844 uv points, since the uv map must have a seam somewhere (in this case on the back of the head) and all verticles on this seam have two uv points.

when i try to calculate the lowest vertexbuffer for use in away3d (since away3d use the same indexbuffer for both uvs and verticles) i end up with 10780 uv/verticles, but in the eamples with the very same model they have only 9203. the model looks the same….

i am still looking at the obj and 3ds parsers to figure out where this magic happens. smile

there is one thing you have to worry about when dealing with this, and that is, that when using shared verticles on your mesh, away3d shading will make hard edges look soft. i believe you have seen this, since the old cylinder.as suffered from this, before alejandro fixed it.

one way to have both sharedverticles and unique verticles in one mesh, is to make shure you have a uv seam on this hard edge. then it is rendered correctly, since the verticles on this seams are no longer shared between triangles. since i dont want to many uv seams in my uv maps, on my c4d exporter i use a point-selection with a spezial name (“hard_edge”), to let my exporter know where i want this hard edges, without having to split up my uvs.

i am no native english speaker so its quite hard for me to get this thoughts into words wink

i would be happy if someone who really knows about this would correct me if i am talking shit right now, or let me know if i am correct.

 

 

 Signature 

sorry…i hope my actionscript is better than my english…

   

Avatar
Choons, Sr. Member
Posted: 06 October 2011 11:49 PM   Total Posts: 281   [ # 8 ]

I think you need to change your signature- your English has become exceptionally good in the past few months ; )

So yeah I see what you mean, I think. You are getting down to the AGAL level which I don’t know enough about to offer any decent advice on this. I know McFunkypants mcfunkypants.com is releasing a book any day now that shows how to work at the AGAL level. He might know/be willing to give advice on the issue.

   

Avatar
80prozent, Sr. Member
Posted: 07 October 2011 12:11 AM   Total Posts: 430   [ # 9 ]

yeah. i am waiting on this book too.
i think i am going to send mcfunkypants an mail asking him to look at this thread.

thanks

this forum is really pushing my english skills smile

i tried to change my signature several times in the last 2-3 month, but it seems like the signature-functions are no longer available (due to spammers?) and so i am stuck with this statement.

but i hope my as3 is still better than my english wink

 Signature 

sorry…i hope my actionscript is better than my english…

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X