[GUIDE] Mesh, Texture and Sound replacement

Discuss modding questions and implementation details.
User avatar
TheLacus
Posts: 414
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

[GUIDE] Mesh, Texture and Sound replacement

Postby TheLacus » Sat Feb 04, 2017 12:50 am

Read the updated guide on Daggerfall Workshop website.


Index

Tools
Last edited by TheLacus on Thu Apr 27, 2017 11:39 am, edited 8 times in total.
User avatar
TheLacus
Posts: 414
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Textures

Postby TheLacus » Sat Feb 04, 2017 12:50 am

Textures

Textures can be easily imported at runtime, like in recent TES games.
Texture files (in .png format) need to be placed inside StreamingAssets\Textures.

General
The name of the texture sould be archive_record-frame.png, for example 009_1-0.png. If you aren’t familiar with daggerfall naming, the first number is the name of the package where textures are stored (ARCHIVE.XXX, ARCHIVE.009 in our example), the second number indicates this is the n texture of the archive (1 means is the second one), and the third number is the frame, used only for animated billboards. Textures for static models always have frame - 0.

Daggerfall Imaging 2.jpg
Daggerfall Imaging 2.jpg (79.61 KiB) Viewed 2748 times

You can also release optional bump maps (archive_record-frame_Normal.png, for example 009_1-0_Normal.png), and if you release textures with illuminated surfaces (like a wall with a window) you need to create emission maps (archive_record-frame_Emission.png). This is not necessary if the emission surface is the whole texture (lamps, etc.).

archive_record-frame_MetallicGloss.png is for MetallicGloss maps, alternatively you can use an xml file to edit Metallic and Smoothness parameters. archive_record-0.xml

Code: Select all

<?xml version="1.0"?>
<properties>
<metallic>0.5</metallic>
<smoothness>0.5</smoothness>
</properties>


Image
Buildings with a custom albedo texture. Since they have windows, an emission map is also required.

.IMG, .CIF and .RCI
UI and inventory images are handled in a more specific way:

  • .IMGs
    filename.png (ex: MAP100I0.IMG.png) in StreamingAssets\Textures\Img
  • .CIFs and .RCIs
    filename_record-frame.png (ex: INVE16I0.CIF_3-0.png) in StreamingAssets\Textures\CifRci
Last edited by TheLacus on Fri Jul 21, 2017 9:10 pm, edited 9 times in total.
User avatar
TheLacus
Posts: 414
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Textures

Postby TheLacus » Sat Feb 04, 2017 12:51 am

Background images
Images used as background in the inventory and charachter window (SCBG0*.IMG) need to be provided without the frame, as the one seen in game is the frame on the main texture for each of the two windows (INFO00I0.IMG and INVE00I0.IMG).

Image Image
The character window (INFO00I0.IMG) and one of the several backgrounds (SCBG06I0.IMG).

Paperdoll
Body and items textures can only be replaced with images with the same resolution as original at this time.

BODY07I1.IMG.png
BODY07I1.IMG.png (5.49 KiB) Viewed 2751 times

First Person Weapons

Image Image Image

Weapons used by the player have several variations for different kinds of metal. Vanilla textures use a color tint to achieve this; when importing custom textures, we use entirely different images.

WEAPON**.CIF-Record-Frame_metalTag.png

  • metalTag, original color
  1. Iron, Grey
  2. Steel, Light grey
  3. Chain, Silver
  4. Silver, Silver
  5. Elven,
  6. Dwarven, Yellow
  7. Mithril, Blue
  8. Adamantium, Dark grey
  9. Ebony, Black
  10. Orcish, Green
  11. Daedric, Red
Ex: WEAPON04.CIF_0-0.Png for Iron --> WEAPON04.CIF_0-0_Iron.Png

Some weapons (like hands and feet) don't have metal type variations, so they use the usual WEAPON**.CIF_Record-Frame.png

Look here for the complete list of weapons.

HUD and UI elements
Certain UI images need additional informations. These are provided using .xml files, each one with the same name as the texture file it refers to and placed in the same folder. width and height parameters affect the size on screen. Here are provided the defaults values, but it's possible to customize them.

  • HUD Compass
    COMPASS.IMG.xml

    Code: Select all

    <?xml version="1.0"?>
    <info>
    <width>322</width>
    <height>14</height>
    </info>

    COMPBOX.IMG.xml

    Code: Select all

    <?xml version="1.0"?>
    <info>
    <width>69</width>
    <height>17</height>
    </info>
  • Crosshair
    Crosshair.png and Crosshair.xml in StreamingAssets\Textures

    Code: Select all

    <?xml version="1.0"?>
    <info>
    <width>22</width>
    <height>22</height>
    </info>

Save Manager
It is possible to customize the window interface used to load saves, placing custom textures inside StreamingAssets\Textures.

Image

While it is not required for swapping texture images, it is possible to use xml files to customize the labes of buttons.

Image
  • Change text color

    Code: Select all

    <?xml version="1.0"?>
    <info>
    <customtext>true</customtext>
    <r>0.8</r>
    <g>0.1</g>
    <b>0.1</b>
    <a>1.0</a>
    </info>
    An omitted alpha value is considered as full opacity.

  • Remove text (to draw text on texture)

    Code: Select all

    <?xml version="1.0"?>
    <info>
    <customtext>notext</customtext>
    </info>

Billboards
It is currently possible to replace billboards (sprites) textures only in interiors, dungeons and fixed locations (towns). Texture replacement for billboards support animations (you can have as many frames as you want, even more or less than vanilla) and emission maps.

For a simple texture swap, only texture files are needed. They will have the same size as vanilla, regardless of resolution. The dowside is that they need to have the same proportions as the original textures or they'll look stretched.
But if you want to follow the power of two rule, you can do so if you take care of telling the game how the texture should be displayed on the billboard mesh. Specifically, you need to provide an xml file with the position of the lower-left vertex on the uv map. All frames share the same file.

Image

Archive_Record-0.xml

Code: Select all

<?xml version="1.0"?>
<info>
<uvX>0.3</uvX>
<uvY>0.1</uvY>
</info>

Tipically, you want to avoid wasting texture space, so you only need to write the x or y value and the other will be set to the default value of zero.

If you want to customize the size of the mesh you can do so with the xml file. All frames share the same file.
For example this has been used for the Remove spider mod, which replaces horizontal spiders with vertical beards avoiding innatural streching.

Archive_Record-0.xml

Code: Select all

<?xml version="1.0"?>
<info>
<scaleX>1</scaleX>
<scaleY>1</scaleY>
</info>

(1:1) means the same size as vanilla, (1:2) has a double height, (0.5:1) is half as wide. If you want to customize only one of the values, you can omit the other one.

Image
An animated torch with an emission map.

Terrain
Thanks to Nystul's Overhaul of the terrain system, it's possible to import albedo, normal and metallicgloss maps. It is important to notice that all textures from the same archive must have the same resolution.
Last edited by TheLacus on Thu Apr 27, 2017 11:45 am, edited 13 times in total.
If you are interested in creating mods for Daggerfall Unity you can find the documentation here.
User avatar
TheLacus
Posts: 414
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Models and Flats

Postby TheLacus » Sat Feb 04, 2017 12:51 am

Models

Part 1: export the mesh


When exporting your model from a modelling software you need to take a few things in consideration:

  • Models exported from Daggerfall Modelling are forty times bigger than they need to be in order to be used in Unity, so you need to scale them down by 0.025.
  • Unity engine reads models as Y-up not Z-up. You can use this plugin for blender to address this. Of course, remember to check also the origin of models.
  • Your model can’t have more than 65,534 vertices. If you need, split your model in several parts and put them togheter inside the prefab.
  • Unity supports different formats, but exporting to .fbx is suggested.

Image Image
Export settings in Blender.

Part 2: import your model

  1. Go to daggerfall-unity-master\Assets\Resources\Models and create a subfolder. Rename it with the ID of the model, then create another folder inside this one and place the .xfb file inside.

    Daggerfall_Modelling_ModelID.jpg
    Daggerfall_Modelling_ModelID.jpg (20.35 KiB) Viewed 2515 times

  2. Place the relative textures inside daggerfall-unity-master\Assets\Resources\Textures. You need to do so even if you’re using vanilla textures.
  3. Now open Unity and let it import all the new files. When it’s done, navigate to the model subfolder in the project window and create new materials, one for each texture you need to use.

    Image

  4. Drag your model in the scene view and assign materials to the model. Then place it in a prefab with the same name as the folder: /models/modelID/modelID.prefab

    Image

    Seasonal changes

    If the model you are replacing has a winter version, you need to provide materials for this season, too. Create another prefab named modelID_winter.

  5. When you’re done, you can compile the project and look for your model in-game.
Image
Image
Last edited by TheLacus on Sat Mar 25, 2017 12:17 am, edited 9 times in total.
User avatar
TheLacus
Posts: 414
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Models and Flats

Postby TheLacus » Sat Feb 04, 2017 12:52 am

Flats

Image
Replacing sprites with 3d models.

  1. Go to \Assets\Resources\Flats and create a subfolder, named after the sprite texture we are replacing.
    For example 205_0 for the texture 0-0 in archive 205.
  2. Place your model inside this folder (maybe in a subfolder called Mesh or Assets, for example), the texture you need to use in the usual Resources/Textures folder and create materials.
  3. Create the prefab, name it with the same ID as above and place it in the main subfolder.
    In our case we will have /Flats/205_0/205_0.

Image

Models and Flats notes

  • Models should have the origin in the same position as vanilla mesh.
    Custom flats prefabs are placed in game assuming the origin of the model is at the base, where they touch the ground or the surface they are positioned on, so place it in this position.
  • If the model is supposed to collide with the player, check Generate colliders in the mesh inspector inside the Unity editor.
  • Using prefabs give us a lot of freedom as they allow combining more than one mesh, using particles and scripts.
    If your model is split in parts, import an .xfb file for each of them. Them set one as parent, associate the others as children and drag the parent in the prefab. Note: do not use an empty gameobject as parent, always use one of the components.

    Image
    Mesh, point light and particles emitter. This prototype by Uncanny_Valley does a great job showing what's possible to do.

  • Since sprites rotate to always face the player, when we replace them with models we don't have a rotation value for an exact placement. In most cases this is not a problem, as they are used for vegetation and random props, but there are a few exception where there is ony one correct position, for example wall torches.
    In this case we can use a script to place the model correctly in all circumstances. Select your prefab, click Add Component in the Inspector and search FaceWall.cs.

    Image

  • You can replace replace NPCs with 3d models like any other flat. Right now Daggerfall Unity has only interior characters, static or with looped animations.

FAQ
  • Why the difference in scale?
    From MeshReader.cs

    Code: Select all

    // Using 1/40 scale (or * 0.025).
    // True world scale is 1/39.37007874015748 (or * 0.0254). Basically conversion is inches (Daggerfall) to metres (Unity).
    // 1/40 scale has been carefully chosen as it is close to true scale but requires less floating-point precision
    // for tiling assets. It also produces numbers easier to remember for editor layouts and is easier to
    // calculate manually (i.e. just divide by 40 to convert native units to Unity units).
    // For example, an RMB block dimension is 4096 native units.
    // 4096 / 40 = 102.4 (easy to remember for manual editor layouts, less precision required).
    // 4096 * 0.0254 = 104.0384 (harder to remember for manual editor layouts, more precision required).
    // This means world is slightly smaller over large distances (13107.2m error across entire map width).
  • How can i change the filter type of imported textures?
    There is a .ini setting (MainFilterMode, under [Video]) which change it for both vanilla and custom textures.

    Image
Last edited by TheLacus on Sat Mar 25, 2017 9:19 pm, edited 9 times in total.
User avatar
TheLacus
Posts: 414
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Release mods

Postby TheLacus » Sat Feb 04, 2017 12:52 am

Release mods

Textures
Textures can easily be released as Png files, to be placed inside StreamingAssets\Textures. It's important to note that textures found in here will be applied to both vanilla and custom models, so it's up to modders who create models to choose the name accordingly. Vanilla textures which should be affected by this, should be named with the usual Archive_record-frame, while new textures should have unique names to avoid involuntary replacement (for example place your name or the name of your mod in front of it).

Models and Flats
Models have to be placed inside assetbundles. We can easily do so with the Mod Builder, found in the Unity editor under the Daggerfall Tools tab.

In the Mod Builder we find a number of fields to compile and a button to import selected assets.
Here we have to import only the gameobject, meaning the .prefab. Do not include mesh, material or textures. The name of the Mod must be the id of the model (modelID or Archive_record).
Once we have built the Mod we can find three folders, one for each operating system. What's important it's the modelID.dfmod file. Once renamed to modelID.model, it can be placed inside StreamingAsset\Models.

The same process apply to models intended to replace sprites. Rename their assetbundles to Archive_record.flat and place them inside StreamingAsset\Flats.

To quickly do this process automatically, you can use this batch script on windows. Save it in a .cmd file and launch it in the path where you have the three OS folders.

Image

Code: Select all

:: DUModCreator
:: A small utility to quickly create release folders for Daggerfall Unity mods
:: Author: TheLacus
:: http://www.dfworkshop.net/
@ECHO OFF

ECHO -
ECHO -- DUModCreator --
ECHO -
ECHO -- version 1.1 --
ECHO -
ECHO - 0: Create release for mods
ECHO - 1: Create release for models (.dfmod to .model)
ECHO - 2: Create release for flats (.dfmod to .flat)
ECHO - 3: Create release for videos (.dfmod to .dfvideo)
ECHO - 4: Close program
ECHO -

:insertNumber
set /p id="Insert number : "

IF "%id%"=="0" (
SET extension=dfmod
SET folder=Mods
)

IF "%id%"=="1" (
SET extension=model
SET folder=Models
)

IF "%id%"=="2" (
SET extension=flat
SET folder=Flats
)

IF "%id%"=="3" (
SET extension=dfvideo
SET folder=Videos
)

IF NOT "%id%"=="0" (
IF NOT "%id%"=="1" (
IF NOT "%id%"=="2" (
IF NOT "%id%"=="3" (
IF "%id%"=="4" (
exit /b
)
ECHO -
ECHO Invalid entry
ECHO -
goto :insertNumber
)
)
)
)

IF NOT "%id%"=="0" (
REM rename .dfmod to .model, .flat or .video
cd /D %~dp0\StandaloneLinux
ren *.dfmod *.%extension%

cd /D %~dp0\StandaloneOSXUniversal
ren *.dfmod *.%extension%

cd /D %~dp0\StandaloneWindows
ren *.dfmod *.%extension%
)

REM move to folder release
mkdir "%~dp0\Release\Linux\StreamingAssets\%folder%"
move "%~dp0\StandaloneLinux\*.%extension%" "%~dp0\Release\Linux\StreamingAssets\%folder%"
mkdir "%~dp0\Release\OSX\StreamingAssets\%folder%"
move "%~dp0\StandaloneOSXUniversal\*.%extension%" "%~dp0\Release\OSX\StreamingAssets\%folder%"
mkdir "%~dp0\Release\Windows\StreamingAssets\%folder%"
move "%~dp0\StandaloneWindows\*.%extension%" "%~dp0\Release\Windows\StreamingAssets\%folder%"

ECHO -
ECHO -
ECHO Release folders created.
timeout /t -1
Last edited by TheLacus on Sun Apr 09, 2017 4:51 pm, edited 5 times in total.
User avatar
TheLacus
Posts: 414
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Documentation

Postby TheLacus » Sat Feb 04, 2017 12:53 am

Last edited by TheLacus on Sat Mar 18, 2017 12:58 am, edited 2 times in total.
User avatar
TheLacus
Posts: 414
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Sound and Movies

Postby TheLacus » Sat Feb 04, 2017 12:53 am

Sound and Movies

  • Sound Clips (player, enemies, environment)

    StreamingAssets/Sound/SoundClipName.wav
    ex: StreamingAssets/Sound/PlayerFootstepNormal.wav

  • Songs

    1. StreamingAssets/Sound/Song_Name.ogg
      ex: StreamingAssets/Sound/song_magic_2.ogg

    2. StreamingAssets/Sound/Song_Name.mid
      ex: StreamingAssets/Sound/song_magic_2.mid

    3. Look here how to import sound files with different extensions and customize the playlist.
      This requires coding knowledge.
  • Videos

    It's possible to import videos, in Ogg Theora format, inside Daggerfal Unity through the Mod Builder, as explained above. The mod will be renamed to ".dfvideo".
    name.ogg inside StreamingAssets/Videos/name.dfvideo
    ex: ANIM0001.ogg inside StreamingAssets/Videos/ANIM0001.dfvideo
Lists
Tools
  • DFJukebox: Play audio directly from within Daggerfall Jukebox, or export to standard file formats. Sound is exported to .wav, and music to .mid.
  • DaggerSound: Extract sound files from DAGGER.SND. You may need to use Audacity's raw import to actually make a use of the extracted .wav files (see here).
  • WINRipper: Extract HMI files from MIDI.BSA and convert them to MIDI files.
  • dfmusics2.zip: All MIDI song files from the game.
  • VIDTitle: A collection of tools for adding subtitles, captions, or other overlays to Daggerfall VID files.
  • DagVid V1.01: A Daggerfall and Skynet video file player for Win 9X/NT, with source code (broken download link).
  • DFVid2AVI 0.43b: Write out to AVI.
You can get the tools without a link from the UESP wiki.
Last edited by TheLacus on Fri Mar 24, 2017 8:11 pm, edited 10 times in total.
If you are interested in creating mods for Daggerfall Unity you can find the documentation here.
User avatar
kingOfWyrms
Posts: 44
Joined: Fri Aug 07, 2015 3:46 am

Re: Mesh and Texture replacement - guide

Postby kingOfWyrms » Sat Feb 04, 2017 12:32 pm

TheLacus wrote:The name of the Mod must be the id of the model (modelID or Archive_record).
Once we have built the Mod we can find three folders, one for each operating system. What's important it's the modelID.dfmod file.


Does this mean we'll need to have a separate asset pack for each item we're replacing?
User avatar
TheLacus
Posts: 414
Joined: Wed Sep 14, 2016 6:22 pm
Contact:

Re: Mesh and Texture replacement - guide

Postby TheLacus » Sat Feb 04, 2017 7:15 pm

kingOfWyrms wrote:
TheLacus wrote:The name of the Mod must be the id of the model (modelID or Archive_record).
Once we have built the Mod we can find three folders, one for each operating system. What's important it's the modelID.dfmod file.


Does this mean we'll need to have a separate asset pack for each item we're replacing?

Yes, for now. It's my intention to integrate it more with the mod system and support importing models from mods, with load order and all, but this require still some work.
If you are interested in creating mods for Daggerfall Unity you can find the documentation here.

Return to “Modder Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest