Question for gildor:
Have you considered exporting Materials to T3DPGK format? It's a text based format and supports textures, materials and even StaticMeshes.
I wrote my own tool (for Arkham Asylum) for this and here is an example output:
- the stuff between 'Begin Binary' and 'End Binary' is the first miplevel converted to a png file as hex...
Begin TopLevelPackage Class=Package Name=BAA_EngineMaterials Archetype=Package'Core.Default__Package'
Name="BAA_EngineMaterials"
ObjectArchetype=Package'Core.Default__Package'
End TopLevelPackage
Begin PackageTexture ParentPackage=BAA_EngineMaterials
Begin Texture Class=Texture2D Name=DefaultNormal ObjName=DefaultNormal Archetype=Texture2D'Engine.Default__Texture2D'
SizeX=128
SizeY=128
Format=PF_DXT1
SRGB=False
UnpackMin(0)=-1.000000
UnpackMin(1)=-1.000000
UnpackMin(2)=-1.000000
UnpackMin(3)=-1.000000
CompressionSettings=TC_Normalmap
LODGroup=TEXTUREGROUP_WorldNormalMap
OriginalSizeX=128
OriginalSizeY=128
Name="DefaultNormal"
ObjectArchetype=Texture2D'Engine.Default__Texture2D'
Begin TextureData
Version=0.0
Begin SourceArt
Begin UntypedBulkData
ElementCount=1146
ElementSize=1
Begin BinaryBlob
Size=1146
Begin Binary
89,50,4e,47,0d,0a,1a,0a,00,00,00,0d,49,48,44,52,00,00,00,80,00,00,00,80,08,06,00,00,00,c3,3e,61,
cb,00,00,04,41,49,44,41,54,78,da,ed,dd,c1,4a,dc,50,14,c6,f1,3c,9b,e0,62,0a,7d,80,0a,0a,56,0a,c5,
42,75,1f,02,21,64,d9,85,48,57,45,44,84,3e,42,bb,28,f8,4c,b3,cc,22,8b,34,b9,66,d2,73,cf,d8,b9,5e,
6f,42,ed,9c,ff,e2,23,a5,93,64,72,6e,7e,8e,d7,4c,66,4e,d6,5e,5e,74,32,5d,91,a7,a5,52,29,5e,57,da,
cf,5f,fc,24,d7,5f,ab,e4,af,3a,ba,fe,ac,a9,8e,1e,0b,3f,ae,5d,9a,b7,bb,b3,5e,f9,69,74,f4,36,91,8f,
07,f7,1f,1b,fd,7c,ef,72,97,a1,f8,ae,ba,e9,74,fd,5b,cf,bf,f4,78,84,d6,8f,4c,f0,78,54,fd,0e,80,1c,
84,f6,43,b9,33,cd,99,9f,56,e7,a3,8a,7e,5c,ef,53,3d,1e,dc,7f,6c,f4,f1,8b,e2,37,00,64,fd,5b,cf,1f,
1c,8f,da,4b,6c,bd,c1,f5,23,13,1a,3f,5d,ff,04,60,1a,04,03,bf,02,36,c5,4b,00,2f,af,ff,ff,fb,15,20,
eb,ef,01,9c,74,eb,ea,a0,1b,96,ee,84,95,e5,7e,a7,ea,7f,4a,dd,89,ff,e1,96,6d,f5,be,ff,f7,1b,b7,b4,
58,3f,00,00,00,00,00,00,c0,2e,80,b6,1c,07,a0,5f,ba,89,02,00,00,00,00,00,00,00,00,00,b0,01,c0,f8,
00,58,9f,04,03,00,00,00,00,00,00,00,60,15,00,93,40,00,00,00,00,00,00,00,6f,06,9d,30,09,04,00,00,
00,00,00,00,00,80,49,e0,fe,a6,e8,07,a0,1c,07,a0,04,00,00,00,00,00,00,00,00,00,5c,08,e2,4a,20,00,
00,00,00,00,00,00,00,96,26,81,00,00,00,00,00,00,00,00,98,bd,1f,a0,3c,e9,d6,c5,41,37,2c,01,00,00,
00,00,00,00,00,00,00,37,84,00,00,00,00,00,00,00,00,00,00,2e,04,f1,66,d0,fe,fe,00,00,00,00,00,00,
00,00,00,60,16,c0,f0,25,59,c5,f8,25,59,00,00,00,00,00,00,00,00,00,80,49,20,17,82,00,00,00,00,00,
00,00,00,00,00,00,00,00,00,00,00,00,00,fb,78,43,48,71,d4,6d,d2,5e,9d,6f,37,7e,dc,4a,ad,32,f7,fa,
b1,09,ec,5f,37,4e,bc,fe,da,ff,ff,f7,29,5e,e3,c8,eb,f3,05,8e,6f,e6,7a,12,b7,d7,f5,67,de,c9,bf,ef,
57,b8,29,77,e7,56,65,ee,f5,63,13,da,ff,37,3f,cd,7d,ed,0d,82,77,f2,9f,53,ff,d2,49,1d,af,c0,f6,ba,
fe,4c,9e,fc,21,cd,cf,7a,77,7e,e5,7e,e6,5e,3f,36,b1,fb,bf,af,bd,41,90,27,ff,59,f5,2f,9d,d4,f1,0a,
6d,af,ea,cf,e4,c9,b7,f2,0a,20,07,41,9e,7c,2b,af,00,b2,fe,ac,b9,3c,ef,9a,e3,7c,ca,56,37,eb,53,95,
b3,85,73,1a,48,e2,fe,37,ed,d3,5d,17,ed,4f,57,5d,b0,fe,d4,e3,8f,ad,6f,ee,ed,55,74,fd,8f,dd,c3,e5,
20,ac,54,0e,6b,3f,ab,7c,d9,e8,e7,9b,fb,f9,45,f1,5d,31,ce,01,76,d5,9f,7a,fc,2b,95,c3,c8,a4,6e,af,
a3,ea,ff,d3,3e,7e,1c,04,0b,af,00,9b,e2,27,00,bb,ea,df,c3,57,00,59,7f,26,ff,0c,1a,06,61,78,bf,d8,
8f,fe,53,aa,5e,38,79,20,69,fb,97,c5,7b,00,fe,5a,ff,dc,c7,ff,6f,a3,eb,e7,42,90,f1,c6,99,00,00,00,
00,00,00,00,bb,00,cc,37,8c,b0,f6,05,19,00,00,00,00,00,00,00,00,30,09,34,7b,43,48,53,dd,f5,3f,f4,
0f,6e,09,00,00,00,00,00,00,00,80,55,00,34,8d,02,00,00,00,00,00,00,d0,3c,da,d0,00,94,77,5d,53,3c,
b8,25,1f,0c,01,00,00,00,00,00,00,f0,e1,50,9a,46,01,00,00,00,00,00,00,00,60,6a,12,68,fc,86,08,00,
00,00,00,00,00,00,00,98,04,72,43,88,c5,0b,61,00,00,00,00,00,00,00,00,d0,30,82,49,20,00,00,00,00,
00,00,00,00,dc,10,02,00,00,00,00,00,00,00,00,00,4c,4c,02,f9,96,30,00,00,00,00,00,00,00,00,cc,dd,
14,6a,fd,83,31,00,00,00,00,00,00,00,00,70,43,08,17,82,00,00,00,00,00,00,00,00,e0,86,10,00,00,00,
00,00,00,00,00,0c,7c,38,54,34,4e,74,8d,94,83,fd,e8,43,fd,ed,d5,e3,ba,79,61,15,4a,68,ff,69,eb,0f,
0d,93,1b,d7,35,7c,4c,71,36,a5,bd,ba,78,c1,f1,a6,1e,7f,ea,fe,e2,eb,df,b4,8e,7f,6c,1f,2f,4f,fe,53,
dd,b3,6f,03,09,ad,af,ba,77,27,ef,3f,b1,db,76,37,76,cd,d6,00,dc,c9,1f,ea,0f,1d,6f,e0,f9,1b,95,c5,
bb,89,47,d6,2f,5b,c7,4f,00,64,0b,f5,60,3f,fa,50,7f,fa,d0,e3,5b,eb,eb,c4,6e,1f,b7,fe,00,c0,43,20,
4e,fe,93,f5,47,1e,ff,ba,3f,06,99,e8,fd,c5,d6,17,3b,5e,a2,75,bc,03,20,4f,be,95,57,00,89,40,9e,7c,
2b,af,00,12,c1,6f,6c,e6,54,60,a7,a3,8f,dc,00,00,00,00,49,45,4e,44,ae,42,60,82,
End Binary
End BinaryBlob
End UntypedBulkData
End SourceArt
Begin Texture2DData
Format=DXT1
SizeX=128
SizeY=128
End Texture2DData
End TextureData
End Texture
End PackageTexture
Begin PackageTexture ParentPackage=BAA_EngineMaterials
Begin Texture Class=Texture2D Name=DefaultDiffuse ObjName=DefaultDiffuse Archetype=Texture2D'Engine.Default__Texture2D'
SizeX=128
SizeY=128
Format=PF_DXT1
OriginalSizeX=128
OriginalSizeY=128
Name="DefaultDiffuse"
ObjectArchetype=Texture2D'Engine.Default__Texture2D'
Begin TextureData
Version=0.0
Begin SourceArt
Begin UntypedBulkData
ElementCount=605
ElementSize=1
Begin BinaryBlob
Size=605
Begin Binary
89,50,4e,47,0d,0a,1a,0a,00,00,00,0d,49,48,44,52,00,00,00,80,00,00,00,80,08,06,00,00,00,c3,3e,61,
cb,00,00,02,24,49,44,41,54,78,da,ed,dd,41,4e,c2,40,18,86,61,8e,a3,7b,62,17,ba,21,b2,22,a9,51,4e,
50,42,58,61,ba,6c,4c,3c,01,4a,b8,85,e7,44,87,91,02,c2,b2,24,c8,ff,2c,de,03,cc,e4,21,2d,dd,7c,bd,
f1,cd,ed,3a,74,e5,f8,a0,51,39,0a,55,2f,5d,42,7d,57,b4,bd,df,3f,84,69,0b,60,36,9d,b5,cd,5f,e7,57,
5d,35,ad,da,5a,00,8b,c7,e1,fa,eb,65,9c,7b,7a,0e,d1,5f,00,cb,d5,32,f7,79,e5,fd,9e,b3,79,6b,00,00,
e0,14,80,6b,ef,14,80,c9,0f,80,8f,65,a8,9a,06,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,ce,50,99,5b,0c,86,1b,00,
e9,12,aa,49,05,00,00,81,01,a4,d1,e8,84,20,44,83,5c,dd,2f,0e,00,a4,0b,89,54,3a,73,0b,20,72,d1,e6,
e2,8f,e6,e3,a3,5f,40,f4,1f,c0,06,c0,fe,a6,fc,a5,ee,de,77,d5,fe,59,b7,00,d2,23,70,5b,fa,77,10,a5,
03,00,51,e7,d3,8f,5e,82,2f,7c,f6,be,ab,00,00,20,03,88,fe,21,24,fa,87,30,00,00,00,00,00,00,00,00,
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,
ce,0b,20,fa,7c,7a,38,00,65,2e,2d,a8,03,00,c0,0e,c0,7f,d9,bd,ef,aa,74,e6,fd,f1,e8,84,20,44,83,5c,
dd,2f,76,00,cc,c7,c7,ed,1b,7f,e8,19,90,94,cf,64,f0,00,00,00,00,49,45,4e,44,ae,42,60,82,
End Binary
End BinaryBlob
End UntypedBulkData
End SourceArt
Begin Texture2DData
Format=DXT1
SizeX=128
SizeY=128
End Texture2DData
End TextureData
End Texture
End PackageTexture
Begin PackageMaterial ParentPackage=BAA_EngineMaterials
Begin Material Class=Material Name=DefaultMaterial ObjName=DefaultMaterial Archetype=Material'Engine.Default__Material'
Begin MaterialData
Version=0.0
Begin ExpressionObjectList
Begin Object Class=MaterialExpressionTextureSample Name=MaterialExpressionTextureSample0
Texture=Texture2D'BAA_EngineMaterials.DefaultDiffuse'
MaterialExpressionEditorX=563
MaterialExpressionEditorY=106
Name="MaterialExpressionTextureSample0"
ObjectArchetype=MaterialExpressionTextureSample'Engine.Default__MaterialExpressionTextureSample'
End Object
Begin Object Class=MaterialExpressionTextureSample Name=MaterialExpressionTextureSample2
Texture=Texture2D'BAA_EngineMaterials.DefaultNormal'
MaterialExpressionEditorX=745
MaterialExpressionEditorY=383
Name="MaterialExpressionTextureSample2"
ObjectArchetype=MaterialExpressionTextureSample'Engine.Default__MaterialExpressionTextureSample'
End Object
End ExpressionObjectList
DiffuseColor=(Expression=MaterialExpressionTextureSample'MaterialExpressionTextureSample0',Mask=1,MaskR=1,MaskG=1,MaskB=1)
SpecularColor=(Expression=MaterialExpressionTextureSample'MaterialExpressionTextureSample0',Mask=1,MaskR=1,MaskG=1,MaskB=1)
Normal=(Expression=MaterialExpressionTextureSample'MaterialExpressionTextureSample2',Mask=1,MaskR=1,MaskG=1,MaskB=1)
bUsedAsSpecialEngineMaterial=True
Expressions=(MaterialExpressionTextureSample'MaterialExpressionTextureSample0',MaterialExpressionTextureSample'MaterialExpressionTextureSample2')
ReferencedTextures=(Texture2D'BAA_EngineMaterials.DefaultNormal',Texture2D'BAA_EngineMaterials.DefaultDiffuse')
Begin ExpressionList
Expression=MaterialExpressionTextureSample'MaterialExpressionTextureSample0'
Expression=MaterialExpressionTextureSample'MaterialExpressionTextureSample2'
End ExpressionList
Begin ReferencedTextureList
ReferencedTexture=Texture2D'BAA_EngineMaterials.DefaultNormal'
ReferencedTexture=Texture2D'BAA_EngineMaterials.DefaultDiffuse'
End ReferencedTextureList
End MaterialData
End Material
End PackageMaterial
I have uploaded a complete example here:
http://www.sendspace.com/file/c9zeezThis file also contains a StaticMesh, the Binary data for StaticMeshes is like this:
struct StaticMeshElement
{
Vector3 Position1;
Vector3 Position2;
Vector3 Position3;
float UVs1[8];
float UVs2[8];
float UVs3[8];
int VertexColor1; // D3DCOLOR
int VertexColor2; // D3DCOLOR
int VertexColor3; // D3DCOLOR
int ElementIndex;
int MaxFragmentIndex; // ? always 0
int SmoothingGroup; // flag (0x1, 0x2, 0x4, etc), max group 32
int NumUVs;
int Unknown[28]; // unused, maybe shadow map stuff, all 0
}
You need to compute the smoothing group from the normals to make things look good...
my own tool does this by
- finding duplicate vertices (positions and normal),
- finding all edges sharing 2 vertices,
- and treating all faces which share edges as smoothing group
- reduce the number of smoothing group to max 32 by assigning the same index to groups that are not adjacent
Your PSK export should also calculate new smoothing groups from the normals. I do this using the same method as for staticmeshes and the normals generated on import into UDK look a bit better (more sharp edges where they should be)