FaceGen SDK Manual - File Formats

All values in data files included with this SDK are stored in little-endian format (as used by x86 and amd64).

Use the 'fg3 endian' utility to convert these files to native big-endian format for use by this SDK source code on big-endian machines (eg PS3 or Xbox360).

CTL

Controls & distribution densities. A binary file format. Valid for all SAMs with the same BasisKey.

char[8] 'FRCTL001'
unsigned long Geometry Basis Version - must match EGM
unsigned long Texture Basis Version - must match EGT
unsigned long GS - Geometry symmetric basis size -- Same # as in EGM (>=0)
unsigned long GA - Geometry asymmetric basis size -- Same # as in EGM
unsigned long TS - Texture symmetric basis size -- Same # as in EGT
unsigned long TA - Texture asymetric basis size -- Same # as in EGT
unsigned long LGS - # of GS linear controls (>= 0)
<linCtrl> * LGS The LGS linear controls, where:
<linCtrl> = float * GS, <label>, where:
<label> = uint L, char[L]
Uint LGA
<linCtrl> * LGA The LGA controls, where:
<linCtrl> = float * GA, label
Uint LTS
<linCtrl> * LTS The LTS controls, where:
<linCtrl> = float * TS, label
Uint LTA
<linCtrl> * LTA The LTA controls, where:
<linCtrl> = float * TA, label
<PrtOffLinCtrls> * 5 The offset linear control for Age and Gender for each race, where:
<PrtOffLinCtrls> = <PrtOffLinCtrl> * 2
<PrtOffLinCtrl> = <float * GS, float>, <float * TS, float>
The 2nd & 4th numbers being the offsets and the 1st & 3rd number groups composing the covariantly scaled axes.
The 5 races are given in the order: All, Afro, Asia, Eind, Euro.
<OffLinCtrl> *
(5^2-5 = 20)
The race morphing offset linear controls in the order:
All - {Afro, Asia, Eind, Euro}
Afro - {All,Asia, Eind, Euro}
Asia - {All, Afro, Eind, Euro}
etc.
<OffLinCtrl> = float * GS, float * TS, float
The last number being the offset and the first numbers composing the covariantly scaled axis.
<density> * 5 The density distributions for each race group, where:
<density> = <combined density>, <geo density>, <tex density>
<combined density> = <mean>, <col> * (GS + TS)
<mean> = float * (GS + TS)
<col> = float * (GS + TS) are the weighted bases.
<geo density> = float * GS * GS
<tex density> = float * TS * TS
NEWER VERSION ONLY:
<combined density> * 2
The improved separated male and female (resp.) all races distributions.


EGM

A binary format containing the principal component modes as one standard deviation vertex deltas.

char[8] Magic number for this filetype: 'FREGM002'
unsigned long Number of vertices (V) (Should equal V+K in TRI file)
unsigned long Number of symmetric morph modes (S)
unsigned long Number of asymmetric morph modes (A)
unsigned long Geometry Basis Version
char[40] Reserved
(float+(short*3)*V)*S Symmetric morph mode data for each vertex and all modes.
For each mode in S,
Start with a floating point scale value x
For each vertex in V,
The morph values are stored as 3 signed short m. The actual morph values should be m * x.
(float+(short*3)*V)*A As above for the asymmetric morph modes.


EGT

A binary file format containing texture statistics data for each pixel for each mode.

char[8] Magic number for this filetype: 'FREGT003'
unsigned long Number of image rows (R)
unsigned long Number of image columns (C)
unsigned long Number of symmetric morph modes (S)
unsigned long Number of asymmetric morph modes (A)
unsigned long Texture Basis Version
char[36] Reserved
<mode> * S Symmetric texture modes. Where:
<mode> = float s, <image> r, <image> g, <image> b
Where s is the scale factor:
<image> = (signed char * R) * C
Multiplying each image component by s yields the RGB mode. Image is defined as left to right, and top to bottom.
<mode> * A Asymmetric texture modes.


FG

A binary file format containing a face coordinate and optionally a detail texture for that face.

FaceGen version 2.1 has a different Texture Basis Version from version 2.2 since the basis has changed. If you need to read version 2.1 FG files into version 2.2 statistics, contact us for conversion instructions.

char[8] 'FRFG0001'
unsigned long Geometry Basis Version - Should match EGM. Use 0 if no geometry coordinates provided.
unsigned long Texture Basis Version - Should match EGT. Use 0 if no texture coordinates provided.
unsigned long SS - number of symmetric shape modes (>0) -- Same # as in EGM
unsigned long SA - number of asymmetric shape modes (>0) -- Same # as in EGM
unsigned long TS - number of symmetric texture modes (>0) -- Same # as in EGT
unsigned long TA - number of asymmetric texture modes (>0) -- Same # as in EGT
unsigned long Must be 0.
unsigned long Detail Texture flag - 0 if none, 1 if present.
signed short [SS] Symmetric shape mode coefficients (scaled up by a factor of 1000).
signed short [SA] Asymmetric shape mode coefficients (scaled up by a factor of 1000).
signed short [TS] Symmetric texture mode coefficients (scaled up by a factor of 1000).
signed short [TA] Asymmetric texture mode coefficients (scaled up by a factor of 1000).
[<DetailImg>] Detail texture image, where:
<DetailImg> = N, <jpg>
N is unsigned long which tells us # of bytes required to store <jpg>
<jpg> is an RGB JPG detail image (of size 256x256, 512x512, 1024x1024, 2048x2048 or 4096x4096).


FIM

A binary file format containing an image resampling transform, used to transform the detail modulation image from internal (cylindrically projected) coordinates to the (arbitrary) SAM UV layout.

The image resampling coordinates are in the OpenGL convention, with range [0,1], from left to right, bottom to top of the image.

A value of (-1,-1) indicates that the transform falls out side of the face region and is therefore undefined.

The FIM is usually subsampled from the desired transform image size, and is usually 2:1 interpolated where valid transform data exists.

char[8] 'FIMFF001'
long W - Image width in pixels.
long H - Image height in pixels.
char[48] Unused
<vec>[W * H] Image resampling coordinates for each pixel, left to right, top to bottom, where:
<vec> = float,float


TRI

A binary format containing a polygonal model composed of triangles and quads and, optionally, texture coordinates, either per-vertex or per-facet (indexed). Normal information is not stored, as normals must be dynamically computed in a SSM.

char[8] FRTRI003
int V, number of vertices, [1,maxInt]
int T, number of triangles, [0,maxInt]
int Q, number of quads, [0,maxInt]
int LV, number of labelled vertices
int LS, number of labelled surface points
int X, number of texture coordinates, [0,maxInt]
(0 for per-vertex texture coordinates, X for per-facet)
int <ext> Extension Info
<ext> & 0x01     True if there are texture coordinates.
<ext> & 0x02     True if surface point labels are 16bit chars.
int Md, number of labelled difference morphs
int Ms, number of labelled stat morphs
int K, total number of stat morph vertices
char[16] Reserved for future use. Set to 0 when saving.
<vert> * (V+K) <vert> = float, float, float, in order X,Y,Z (coordinate system varies)
<tri> * T <tri> = int,int,int, the vertex indices of the tri facets.
<quad> * Q <quad> = int,int,int,int, the vertex indeices of the quad facets.
<vlabels> * LV <vlabels> = int,<string>
<string> = int S,char[S]
<slabels> * LS <slabels> = int, float, float, float, <string>
<string> = int S,char[S]


... If per-vertex texture coordinates (ie X == 0 and [<ext< & 0x01] == true): ...

<tex> * V <tex> = float, float in OpenGL texture coordinate system.


... Else if per-facet texture coordinates (ie X > 0 and [<ext> & 0x01] == true): ...

<tex> * X <tex> = float, float in OpenGL texture coordinate system.
<ttInd> * T <ttInd> = int,int,int Indexes into the texture point list.
<qtInd> * Q <qtInd> = int,int,int,int Indexes into the texture point list.


... And if Md > 0: ...

<morph> * Md <morph> = <label>, <deltas>
<label> = int N,char[N] a null terminated string holding the label.
<deltas> = <scale>, <delta> * V
<scale> = float (a scale factor to be multiplied to each delta)
<delta> = short, short, short in order X,Y,Z.


... And if Ms > 0: ...

<morph> * Ms <morph> = <label>, <L>, <VtxIdxList>
<label> = int N,char[N] a null terminated string holding the label.
<L> = int. Number of model vertices affected
<VtxIdxList> = int * <L> The affected vertex indices to
the combined vertex list. (Note that these vertex indices
should always be less than V).
Note that Sum of all <L> == K.