Size of vertex coordinates (was Please help)

Skeletons, animations, shaders, texturing, converting, fixing and anything else related to read game models
theclub456
Posts: 10
Joined: Tue Jan 27, 2015 11:32 pm

Size of vertex coordinates (was Please help)

Post by theclub456 »

How can I tell if a game 3d model uses 2 byte or 4byte or 8 byte vertex coordinates
aluigi
Site Admin
Posts: 12984
Joined: Wed Jul 30, 2014 9:32 pm

Re: Size of vertex coordinates (was Please help)

Post by aluigi »

Moved in the correct section and used a "real" title ("Please help" means nothing and 90% gets ignored).
sleepyzay
Posts: 40
Joined: Mon Sep 15, 2014 5:13 am

Re: Size of vertex coordinates (was Please help)

Post by sleepyzay »

theclub456 wrote:How can I tell if a game 3d model uses 2 byte or 4byte or 8 byte vertex coordinates

Most models I've seen have vertices that are 12 bytes long composing of 3 floats and often some information afterwards like uv and vertex normal data. How I figure it out is by changing the bytes per row displayed until it looks like pic related. The first 3 floats are usually the vertex information. Hope this helps.

Image
TGE
Posts: 38
Joined: Sat Dec 20, 2014 5:14 pm

Re: Size of vertex coordinates (was Please help)

Post by TGE »

Basically, you look at how much data each vertex has.
A vertex position can be stored as a float, short or half float. Floats and half floats usually end with 'F' or 'D' or something similar.
By changing the amount of bytes shown on each line in the hex editor you can figure out how many bytes each vertex consists of
Common sizes are 28,32,64 etc
Vertices usually consist of positions, normals, uvs (often half floats), weights (either floats or bytes), bone indices, vertex colors (often bytes), extra normals (tangent, binormal), extra uv (multiple uv channels).
cra0
Posts: 17
Joined: Fri Aug 08, 2014 12:51 am

Re: Size of vertex coordinates (was Please help)

Post by cra0 »

Dump the shader (if its a dx9 10 11 pc title)
You will see the input signature like

Vertex Stride X
{
VEC3_T POSITION
VEC3_T NORMAL
VEC2_T UV
}

Then you know u need to look for those. Most game devs I've seen pack their Position floats into uint16 for XYZW

To unpack you would read the XYZ values then divide them by the scaler most cases its UINT.MAXVAL (some times its the W component) im typing this from my phone so I cant give you a copy paste function.