NIFopt beta

Post » Fri Oct 07, 2011 1:21 am

Outline:

NIFopt is a tool which optimizes NIF-files. It is based on niflib (the same code-base as PyFFI). Initially I just wanted to write an optimizer, which is fast, thorough, and in it's approach upto-date (vertex-cache, overdraw, triangle-lists). Then it became a bit more. :) The interface is command-line and offers task-based GUI, if you run the tool without any parameters, you'll see how you have to call it and what you can change:

$ nifopt_x32Usage:nifopt_x32.exe [options] in [out]Options: -havokgeotoprim   convert Havok geometry to primitives (everywhere) -stripstolists    convert NiTriStrips to NiTriShapes (everywhere) -optimizelists    optimize NiTriShapes for vertex-cache and overdraw -optimizeparts    optimize NiSkinPartitions for vertex-cache and overdraw -optimizekeys     optimize keyframes in timelines -optimizehavok    optimize Havok NiTriShapes and regenerate MOPP-code -optimizetexts    optimize DDS quality, re-mip -optimizequick    optimize faster but not so well, applies to NIFs and DDSs -optimizenothing  don't optimize, just do conversions -barestripfar     "_far" NIFs will be stripped bare to the bone -mipgamma         treat color-maps as in gamma-space and filter them special -tsnormals        treat normal-maps as in tangent-space and code them special -steepnormals     steepen the normal-map every mip-level, reduces smoothing -parallaxmapping  turn on parallax mapping -leavetexpaths    leave the texture-paths as-is, otherwise make meshes BSAable -leavehdrtexts    leave the hdr-textures as-is, otherwise compress them -dropextras       drop extra files from the hierarchy (thumbs.db, .psd, etc.) -dropunattached   don't repair unattached nodes, throw them away (dangerous) -droptrimeshes    don't reuse non-matching TRI-data, replace by NIF-data -skiphashcheck    don't verify BSA hashes, recover contents -compress  when wring BSA, compression-strength +- <0-9,10> -compressimages   any image will be converted to DXT-DDSs, tex-paths adjusted -compresssounds   compress sounds to MS ADPCM -skipexisting     skip if the destination file exist -skipnewer        skip if the destination file (or BSA) is newer -skipimages       skip processing of image-files -skipsounds       skip processing of sound-files -skipprocessing   skip any of the NIF i/o, just copy and report -passthrough      copy broken and every file which is not a NIF as well -simulate         operate in read-only mode, nothing will be written -verbose          output more information -criticals        output only critical error related information -copy             copy only preset, never change or compress anything -deployment       deployment preset, everything maxed outSome explanations: When run without parameters it doesn't do much. Removing void entries and fixing texture-paths basically. If the support-library NIFlib can not load a NIF it'll bail out with an error message and no destination is created. The tool runs on files, archives and directories, with and without outputs. It will not overwrite it's own input, so if there is no distinct destination given it'll append "_opt" to the NIF/DDS. It can distinguish the purposes of the texture-files by their suffix, "_n" is a normal-map f.e. and it uses appropriate routines for each different type. When obvious it can identify the alpha-channel as transparency-carrier. If you want to mark specific files to have optimal specific treatment you can further add suffixes, like "_xyz"/"_rgb" which will drop alpha-channels, or "_rgba" which will specifically utilize the transparency-optimizations. Informational suffices will be dropped, or converted into "_n". Converted image-formats other than DDS will receive the DDS-extension and texture-paths will be changed to it as well. Textures need to be in a sub-folder named "textures", otherwise no conversion occurs. This is to prevent screens to be mistaken for textures and converted. When creating or modifying archives it will utilize the given strength of compression ranking from 0-9 as for the equivalent option in the zlib. You can also utilize 10 in which case a 7z-based deflater brute-force searched the parameters for best compression. The tool normally reconsiders compressing files like mp3s and videos if they are not really well compressed. If you supply negative levels (-1 to -10) you can force it to compress always.


The tool can be downloaded here:
http://paradice-insight.us/stuff/oblivion/NIFopt.7z
And I started setting up a home here:
http://obge.paradice-insight.us/wiki/Modder%27s_Supplements

Whenever something happens while operation, it'll try to inform you appropriatly.
Okay, that should do it as baseline-info.

----------------------------------------------------------

FAQ:

What do the funny numbers of the optimizer mean?

optimizing: Clusters         : 31 CacheIn/Out      : 1.020x (1.563/1.531) OverdrawIn/Out   : 7.938x (0.000/0.000) OverdrawMaxIn/Out: 108.631x (0.057/0.001)


CacheIn/Out relates approximately to ATVR, the exact measure is actually ACMR (Average Cache Miss Ratio). 1.531 means on average 1.5 vertices of a triangle (3 vertices) are in the cache and 1.5 are not. It's 50% efficient.

In/Out is clear, it's the ratio of incoming mesh (into the optimizer, not into NIFopt, it already does modifications to the original order) to outgoing mesh (that's what is written back to disk).

OverdrawIn/Out is the average number of pixels drawn more than once, of you have triangles on top of each other (from some PoV) you have overdraw if the back triangle is drawn first, then the front triangle. If you'd switch that order around and you draw the front triangle first, then the back triangle, then the hardware can reject the overdraw right at the front-end of the processing and it never calls the shaders fe. The lower the better ofc. Having this low means we can throw much more complex shaders at the geometry and it wouldn't nose-dive.

OverdrawMaxIn/Out is the absolute worst-case overdraw from a specific PoV, like say from the side of an object (arbitrary). This is important for smoothness. Let's say you're circling a NPC and it has a very very bad worst-case on some side, then your game stuffers for a moment, struggling to draw. If the worst-case is very low you have a butter-smooth circling.

----------------------------------------------------------

History:

Update 27.08.2011:
- fixed a critical bug in NIFlib which basically destroyed all SkinPartitions
- there is some suspicous flag-handling by NIFlib, bone-nodes get flagged as "6" while original bone-nodes have "14", please verify if it leads to problems (people indicate it's not a problem, stay put anyway)
Update 28.08.2011
- fixed a bug in the SkinPartition-destripping, strips where removed but the counter not reset to 0
Update 30.08.2011
- added .tri-file support
Update 01.09.2011
- added .bsa-file support, use them like folders "Test.bsa/meshes/..."
- compressing into BSAs wasn't working
Update 02.09.2011
- fixed path-casesensitivity
- fixed a memory-hazard (no more lockups with the version from yesterday)
Update 04.09.2011
- fixed a few corner-cases of bad NIFs
- improvements in the provision of texts and feedbacks in case of errors
- fixed another path-casesensitivity
Update 06.09.2011
- optimizer broke bones, I hope that is fixed now
Update 08.09.2011
- EGMs of tri-strips meshes fixed, morph-data and modifier-group support for vertice-removal added
- DDS-support library carried over from OBGE, complete support for auto-optimization of textures, including modding with PNG-textures and deployment as DDSs
Update 10.09.2011
- fixed a little bit of the mipmap-level truncation code
- fixed NiPSysMeshEmitter mesh-links
- fixed TriStrip-root conversion
- preparing OpenMP parallel execution; initial internal WAV i/o
- fixed the form: "nifopt ", the BSA was never writen back to disk
- added empty directories for BSA, now you can have files in the root-dir, I just don't know if it's permitted, the semantic works though (checked with BSA-commander)
Update 13.09.2011
- fixed a little bit of the automatic texture-format selection
- fixed GB v1.0 file i/o
- fixed a bit of the BSA-handling ("" folder)
- multi-threaded texture compression/mipmapping
- asynchronous multi-threaded BSA-writing
- made the output a bit more structured
Update 16.09.2011
- uncompressed texture mip-strip fixed
- suffix/extension conflic fixed ("_n.dds" became "_n")
- BSA-hash regression fixed, ups
- ultra-highly preview havok-shapes optimization built-in, don't use x64 (havok has no 64bit bundle), and don't tell me which files it doesn't work on, if you wish you can report working exotic collision-setups; it's really only in the files because I wanted to supply the fixes
Update 19.09.2011
- SkinPartition regression fixed, ups
- 32bit Havok-optimization added, 64bit still has RPC problems
- fixed sounds going up from 8bit to 16bit
- fixed a referencing-problem with NiMultiTargetTransformController (detected in Midas' Magic)
- fixed the RPC, you can use 64bit for Havok now (still need to have some better init/exit behaviour)
- added reports of what's going on to the Havok-server window
Update 19.09.2011
- fixed a wrong OpenMP reduction destroying the lower 3-4 miplevels
- fixed "-simulate" to work without giving an output
- added duplication-eliminations for BSAs (duplicate files point to the same data-blob on disk)
- added "-skipnewer"
Update 22.09.2011
- slowly figuring out the multi-material MOPP approach, they may work now already
- fixed a premature box-optimization
Update 24.09.2011
- added "-skipimages"
- added "-skipsounds"
- implemented KF-support
- implemented key-frame optimization
- fixed an access-violation for invalid morph-vertex counts (is a message now)
- fixed an access-violation for invalid materials (is a message now)
- fixed an access-violation for invalid face-indices (is a message now)
Update 24.09.2011
- added task based GUI, configurable via the .ini
Update 27.09.2011
- fixed a BSA-consolidation bug in relation to -skipnewer
- delay-load the GUI so you have a chance to use the tool on XP without GUI

----------------------------------------------------------

For a reference of the "broken" files we've found in mods please consult the old thread:

http://www.gamesas.com/index.php?/topic/1224714-nifopt-damaged-nif-registry/

----------------------------------------------------------

My thanks to everyone interested in it - using it, for the better or worst, either way - and supporting it by testing it and suggesting me enhancements.
I point the finger to you like Uncle Sam: I thank You.

----------------------------------------------------------

TODO:

Explain how/why the GUI-config works. Mention the GUI is Vista+ only.

----------------------------------------------------------

Known problems:

- Optimizing faces leads to disabled race-menu sliders.
- Multi-material MOPPs still don't work.
User avatar
Leonie Connor
 
Posts: 3434
Joined: Mon Mar 12, 2007 4:18 pm

Return to IV - Oblivion