Morrowind

File information

Last updated

Original upload

Created by

Fomad

Uploaded by

fomad

Virus scan

Safe to use

Tags for this mod

About this mod

A tool to create texture atlases for Morrowind. Also updates meshes to reference the new atlas.

Permissions and credits
Upon loading, you will be asked to choose your Data Files directory, so navigate to your Morrowind install and select that Data Files directory.
The next step will be clicking that 'Scan Directory' button in the top right and then choose the directory containing the meshes you want to create an atlas for.  I recommend choosing something small like the 'n' directory to start.  Or, you can now choose presets, that should load up a bunch of related meshes in one click.
Sit back and wait for all the meshes to load (can take a couple minutes, especially if you don't select a sub-directory).
Wait a little more for some user interface setup (the program probably did not hang despite appearances).
Now select from the meshes on the left which ones you would like to use.  You can type a search pattern into the little box to narrow things down.
As you choose meshes, you will notice the texture list changing, only textures that are used in the selected meshes will be displayed.
Once you have chosen your meshes, now choose which textures you want to use.  If a texture is red, you probably don't want to use that one, so far the only texture I have made red is tx_rope_heavy.
You can also choose textures first if that is your style.
Once you are happy with your selection, click 'Create Texture'.

You should get a loading screen for all chosen textures and a pause to set up the user interface again.
You will now be in the texture creation screen.
I made this a little easier, the button you probably want to click will now be green, so you can just follow that if you like, or keep reading.
You probably don't want to click the 'Set Texture Directory' button.  I may remove this in the future.
I've removed the texture size option and now you choose an amount to scale textures in the x and y directions.  As you modify these values, the estimated texture size will update.  If you press the max button beside a scale, it will try to set the maximum value for that scale that will maintain the current estimated texture dimensions.
Texture pad is now a toggle.  When on, it will add a one pixel border around the texture that should reduce or eliminate the appearance of seams.
Force power of two textures will force all dimensions in textures to be a power of two which will usually result in a tighter pack.  The textures will be scaled using a sampling algorithm to fit their new dimensions.
UV Range has been removed, in my tests 0 always yields the best results, plus it changed the texture mapping in a way that was very inaccurate.
Emissive Boost increases the emissive level of all materials which will brighten up the models for you.  This would probably be considered cheating, so don't do it if you have a problem with that.
Modify geometry will chop up triangles that take a lot of uv space into smaller triangles.  This usually results in 4x as many triangles in your final mesh, but some are worse and some are better.  This will improve the quality of your atlas texture.

Click that 'Optimize UV' button and you should get a loading screen telling you that it is optimizing meshes, so go make yourself a sandwich.  This can take a while depending on the number of meshes chosen.  On my pc, it will take about an hour to do my complete meshes directory. (5 minutes after the multi-threading update)

If you looked at the list of textures before, you may have noticed some were green and some were red, green textures will not take up much room in the atlas while red ones will.  Hopefully, the optimize button changed some of those reds to green.
If remove high cost textures is enabled then some textures that were repeated too much will not be included in the atlas.  You can toggle this after clicking 'create texture' and you decide which you prefer.

Now click 'Create Texture' and marvel at it's beauty.  You can choose a different texture scaling or mess with the padding and power of two buttons, then click create texture again if you like, it will probably not crash.
Click 'Save Texture' and name your new atlas texture, it will be saved as a .png file by default which you can convert to something Morrowind can use yourself.  It can take a minute for the save dialog to come up if you have a lot of files in your texture directory, this is a Unity thing and I will try to fix it in the future.  In 0.3, I added dxt1 saving so slap a .dds onto the end of your filename and it will be saved as an s3tc compressed texture using dxt1 which is directly usable by Morrowind.
Now, you can click Merge TriShapes to merge similar trishapes together into one, reducing drawcalls.  If Minimize Material Types is enabled, there will only be 4 different materials used in all of your meshes which will make it so more trishapes are able to merge together.  If you don't minimize material types, then only trishapes that have the same materials can be merged.
Next, click save meshes, choose a directory to save your modified meshes to, see the loading screen come up, and eat your sandwich.  This will take some time, but not as much as optimizing did.  You probably want to back up your original meshes folder first or save to a different folder.  The directory structure will remain intact, so you can just plop that in your Morrowind folder.

Make sure to convert your texture file to something that Morrowind can read and put it in the textures directory, it will not be found if you do not put it in the textures directory.  Also, put the meshes into your data files directory.

Hopefully everything went well and load up your game.

With the reduced number of trishapes being drawn, there will be less drawcalls and your fps should improve.  You will have significantly higher polygon counts, but that doesn't seem to matter as much as the drawcalls.

Just for reference, my PC has a core i7-7700k, 32GB of ram and a GTX 980.  On my system, creating a megatexture (processing all meshes into one giant texture) uses about 9.5GB of ram and takes a good half hour.

The multithreading update in 0.3 makes it so some of the most expensive operations are multithreaded.  I use as many threads as your OS reports it has processors.  This means hyperthreading will get you 2 threads per physical core.  It also means my Octa-core phone gets 8 threads and very warm.  Not that that really matters, just info for those that are curious.  Speaking of phones, I will release an Android version once I figure out how to put ads in it, and it will probably go on the Play Store.  There will not be ads in any other version because it seems ad providers do not want to serve ads on desktop so I can't do it anyhow.  (The ads are mostly to see how it is done, I really don't expect to make any money off of this.)


 
Known issues:
Boxes around textures.  Should be almost eliminated in 0.4.  They still exist, this could be a floating point issue or a problem with my math.  This will also be more noticeable if texture compression is used.  If there is demand, I can add some extra logic to the compression routine that forces the edges to use the same colours but this will reduce texture quality.
in_dwrv_corr4_01.nif is having a problem, it might be a race condition because sometimes it hangs on this nif and sometimes you can get lucky and not have a problem.
Packed texture is not always the same size as estimated/texture has a lot of white space.  For now, try lowering the scale factors until it fits properly, the only solution I can think of at the moment would be to perform a bilinear search across scale values to find the best (similar to how the max buttons work), but I think that would be too expensive.

Version History:
0.4.0 Finally implemented my own texture packing algorithm (based heavily on the example at Binary Tree Bin Packing Algorithm).  This should almost eliminate the appearance of seams, plus it seems to pack nicer and more consistently than the unity packer.
skipped files in presets if they were not present rather than hanging
changed padding to a toggle rather than a slider
removed uv range
added option to force power of two textures
texture size is determined by the size of the textures going in and controlled by scale factors
0.3.1 corrected rotation of normals so lighting should be applied correctly again
made uv update threaded
made writenif threaded
saving default directories to the last directory used now
changed some presets to be more reasonable
changed remove high cost textures from a button to a toggle
removing high cost textures only removes them from models where they will be a problem as opposed to removing them completely
textures repeated many times in a small space do not get optimized any more
0.3 made optimize multithreaded
added emissive boost
added dxt1 saving
removed reliance on unity method to merge meshes which allowed me to make merge TriShapes multithreaded
0.2.2 processing multitextures now rather than ignoring, rarely used in base game, but used in many mods, any trishape with multiple textures will not be optimized/merged now.
fixed f/furn_dwrv_beltdrive00.nif, was copying data from the wrong position in the original file. (NiAutoNormalParticlesData)
fixed merging to not merge trishapes with SkinInstances.
0.2.1 Changed backslashes in directories to forward slashes, hopefully fixing Linux issues.  NiParticleSystemController now updates Particle Extra field to point to the correct node, fixing light_dae_brazier00.nif and possibly others.  Rotated trishapes when merging, fixing sewers in vivec and probably others.
0.2 Added shape merging and presets
0.1 Initial Release - Makes atlases and applies them to meshes.