Tuesday, October 23, 2018

Quick Start Guide: Importing FFXI zones into Unreal Engine 4

This tutorial will teach you how to extract zones from FINAL FANTASY XI and import them into Unreal Engine 4 using a program called Noesis. You will need to have FFXI installed. You can download the FFXI game client from the game's official website. It is not necessary to actually have an active FFXI account in order to extract the zone files. Simply having the game installed is enough, though if your game client is not updated, you will be unable to load zones that were added to the game via updates.

Loading Into and Exporting From Noesis:

The first step is to create or download a Noesis scene file, which is just a text file, except that it uses the extension ".noesis" instead of ".txt" like a regular text file. You can edit the Noesis scene file in Windows Notepad, or any other standard text editor. Notepad++ is a good option, too. When creating or editing a scene file, note that white space doesn't really matter. Noesis will parse the file the same regardless of whether you use tabs or spaces, so use whichever you prefer.

If you would rather just download a ready-made Noesis scene file instead of creating your own, you can grab one from the following Dropbox folder:

Dropbox Download: Noesis Scene Files - FFXI Zones

A proper scene file should look something like this:


The purpose of creating a scene file is so that you can take advantage of the special advanced load options that Noesis provides. Technically, you can load FFXI's zones without creating a scene file by just opening the corresponding DAT file from within Noesis, but doing it that way doesn't allow you to specify any load options, some of which are necessary to render the finalized geometry correctly after we export it. The load options you want to specify in your scene file are as follows:

Advanced Load Options:

-ff11blendhack 0.99 -ff11keepnames -ff11optimizegeo

There is one advanced load option in particular that I would actually recommend against using unless you have a 3D modeling program and corresponding technical skills, and that's the "-ff11renderunref" command  (i.e. Render Unref), which renders unreferenced geometry — such as the skydome and water pieces — out in the middle of the zone. The reason I recommend against using this particular load option if you're new to this whole process is because the Render Unref command does not position the unreferenced geometry pieces correctly, but instead just spits them all out at identity, thus leaving you to pull them apart and manually place them yourself if you actually want to do anything with them. Trying to do that within Unreal Engine 4 is huge pain in the ass, so you practically need some kind of 3D modeling program to do it effectively and efficiently, and that's going to require more time and effort on your part. If you're just trying to extract a zone using Noesis and import it directly into UE4 as quickly as possible, then it's best to just leave off the Render Unref command.

Anyway, once you've created or downloaded your scene file, open it in Noesis, and then go to "File" → "Export from Preview," which will bring up the Export Media window below:


Click on the "Browse" button and create a new folder named after the zone you're exporting. It's also a good idea to use the zone name as the filename. Next, select the following output options:
  • For "Main output type," select ".fbx - Autodesk FBX."
  • For "Additional texture output," select ".tga - TGA Image."
  • For "Additional animation output," just leave it on "Default" as the selection.
  • For the "Advanced options" field, copy and paste the line of code under the "Advanced Export Options" heading below.
All other options can be left on their default settings.

Advanced Export Options:

-rotate 180 0 180 -scale 90 -fbxscalehack -fbxsmoothgroups -fbxtexrel -fbxtexext .tga
The order in which you list the advanced options does not matter.

Please note that there is a difference between Advanced Load Options and Advanced Export Options. Advanced Load Options do nothing if used as export options, and Advanced Export Options do nothing if used as load options.

A detailed explanation of each advanced option used in this tutorial is provided below:

Advanced Load Options:

-ff11blendhack <arg>

FF11 Blend Hack
sw render to determine alpha coverage, <arg>=min frac.
EXAMPLE: -ff11blendhack 0.99

Technically, this option isn't actually necessary at all. The only thing it does is enable transparencies within the Noesis viewer window. Even if this option isn't used, transparencies will still be exported if you save your texture files in a format that includes an alpha channel.

-ff11renderunref

FF11 Render Unref
render unreferenced map geo at identity.

This option will load in the skydome, the sun, the moon, water pieces, and other unreferenced pieces of geometry which are included in the DAT file but for which there is no position specified. It is assumed that in the official game, these pieces of geometry are placed by either SE's servers or the game client.

-ff11keepnames

FF11 Keep Names
keep map object names intact.

This option will prevent Noesis from renaming the mesh geometry pieces in the scene.

-ff11optimizegeo

FF11 Optimize Geometry
remove degenerates and redundant verts.

This option will combine overlapping and duplicate vertices. Without this option, every individual polygon in the entire scene will technically be a separate piece of geometry, which will cause very hard edges on everything.

Advanced Export Options:

-rotate # # #

Rotate X Y Z
transform all vertices by the given angles.
EXAMPLE: -rotate 180 0 180

Rotates the entire scene by 180 degrees on the X axis and the Z axis. Without this option, your zone will load upside down and backwards when imported into Unreal Engine 4.

-scale #

Scale
scale all vertices on the model, where # is the scale factor.
EXAMPLE: -scale 90

Use this option to increase the size of the zone to the proper dimensions. Without this option, the zone will be too tiny to walk around in when imported into Unreal Engine 4. If you forget this option, you can adjust the "Import Uniform Scale" option when importing into Unreal Engine 4.

-fbxscalehack

FBX Scale Hack
transform override for scale correction.

I'm still not entirely sure what this option does. It sounds likes something to do with the transform (i.e coordinate position) of the geometry, and is to be used in conjunction with the -scale option above. Maybe this command isn't necessary, though? I'm not sure. More experimentation is needed here.

-fbxsmoothgroups

FBX Smooth Groups
generate smoothgroups from vertex normals on export.

Unreal Engine 4 will complain at you if you try to import a 3D model that doesn't have smooth groups.

-fbxtexrel

FBX Tex Rel
only set relative paths for texture filenames.

This option is necessary to preserve the connection between materials and textures. Without it, the filepaths to textures will be incorrect, and models will import as grey and textureless.

NOTE: A previous version of this tutorial listed this option as -fbxtexrelonly instead of -fbxtexrel. Although the command -fbxtexrelonly was correct when this tutorial was originally written, the command was apparently changed in an update to Noesis at some point. I am not certain when exactly this change occurred, but the tutorial has now been updated to reflect this change.

-fbxtexext <arg>

FBX Tex Ext
appends given value to texture names on export.
EXAMPLE: -fbxtexext .tga
EXAMPLE: -fbxtexext .png
EXAMPLE: -fbxtexext .bmp

This option is also necessary to preserve the connection between materials and textures, as it allows you to specify the texture filetype extension. Without this option, UE4 won't be able to determine exactly which texture files its supposed to import for the materials, and so it won't import any, thus leaving your models grey and textureless. If you're saving your texture files in a format other than .tga, then replace ".tga" with the format that you're using.

NOTE: A previous version of this tutorial included an Advanced Export Option called -fbxmtlfrommeshname, which allegedly is supposed to create materials with names matching the pieces of geometry they're applied to. However, the option didn't appear to actually work (at least not for models extracted from FFXI), so I removed it from the tutorial.

Importing into Unreal Engine 4:

When you're importing the FFXI zone geometry into Unreal Engine 4, you'll want to enable the "Combine Meshes" option under the Advanced options for the Mesh section. Otherwise you'll get hundreds of little geometry pieces that will bog down your computer and make rendering a nightmare.


If you used the advanced scale option when you exported your zone from Noesis, then when importing into Unreal you should be able to keep the "Import Uniform Scale" option at its default value of 1.0. If you omitted the scale option in Noesis, then you should set "Import Uniform Scale" to 90.0 in Unreal. If you edit the zone in some other third-party 3D modeling software in between Noesis and Unreal, you may have to experiment with the "Import Uniform Scale" option until you find something that looks correct.


Material Setup:

If you entered the correct Advanced Export Options when you exported your zone data from Noesis, all of the materials should already be hooked up to the correct textures automatically. If everything is gray, go back and try to figure out what you did wrong.

Materials in FFXI can be grouped into four basic types: Standard, Decal, Shiny, and Foliage.

Standard Material Setup:

By default, materials in Unreal Engine 4 are slightly shiny, which does not match the aesthetic of FFXI as presented in the official game client. In order to get rid of the shininess, create a Constant with a value of 0 and plug it into the material's Metallic, Specular, and Roughness channels. Do this for all of the materials (this is very tedious and may take a while). Your finished standard material should look like this:


Decal Material Setup:

Some geometry pieces in FFXI are used as decals to add extra detail to the environment. However, in order to get the decals to display correctly in Unreal Engine 4, you will need to set up the corresponding decal material slightly differently from the standard material above. For decal materials, you should set up the material like this:


Foliage Material Setup:

In order to get materials for bushes and tree leaves to display correctly in UE4, plug the Alpha channel of the Texture Sample into the Opacity Mask channel of the material. Select "Masked" as the Blend Mode, change the Shading Model to "Two Sided Foliage," and put a check in the box for the Two Sided option. The finished foliage material should look like this:




No comments:

Post a Comment