View Full Version : [Dev][Parser]UV Atlas Mapping

09-30-2010, 04:34 PM
Sorry for posting here, but there are only lwscript/node sub-forums in section for developers.

So...I need some help parsing .LWO. If i use planar UV map in my model, it seems Ok then i load it to my engine(at least seems ok, but i'm not sure), but if i use Atlas UV, texcoords are obviously wrong if i load model using my parser. But where's nothing about that in documentation, and i don't see any additional data about that type of UV. And where are only vertex[VX]x[f4]y[f4] data in TXUV chunk. So how should i recognize and parse them?

10-01-2010, 04:29 PM
Also, i've noticed there's a VMAD chunk if i use Atlas Mapping, but how should i apply it for OpenGL Vertex Buffer? Cause there's only one vertex array(vx,vy,vz nx,ny,nz tx,ty,tz) for mesh and VMAD is a per-poly UV, so they're completely unrelated. Just applying VMAD on top of plain VMAP doesn't work.

10-08-2010, 11:34 PM
I have written quite a few exporters for various game formats … and it is more complicated thank you think :-)

Essentially, you are dealing here with discontinuous uvs where you have 2 uv values for a single vertex. As you pointed out, graphic cards can only deal with a single vertex stream ( position,normal,uv etc) so the only correct way to deal with it is to split your vertex into two , duplicating all other vertex attributes (position, normal etc) and use VMAD values for different polygons for uv values for these two vertices.
You need to check if there is a VMAD value for that vertex and if there is one , you need to duplicate it.

The same algorithm applies to material smoothing angle – if you need to replicate a hard edge , you need to duplicate your vertex and use separate normal values for both vertices while keeping all other attributes the same.

A lot of exporters get it wrong and often you will see problems with smoothing and uv values.

Aa a separate point, this also means that the way you uv your object can greatly affect the final size of your vertex stream – in other words, even if Lightwave gives you say 10 000 verts for a model , the way you create your uv map ( how many discontinuous uvs etc) or how many sharp edges you use, can greatly affect the final number of vertices that will need to be created within your game to allow for proper interaction with the graphic card.

10-23-2010, 12:03 AM
Oh, i forgot about this thread. I've fixed this problem using unwrap plug-in(in lw modeler) and recalculating normals(in my parser).