NiFlipController somewhy causes lag
I had lag problems with NiFlipControllers in OpenMW, so i tried to understand why it happens, with below "test":
->There is 5 test NIF for comparison
NIF1: Contains 1x plane Nitrishape with Niflipcontroller (61x NiSourceTexture, 256x256 size, total 15MB) - no lag
NIF2: Contains 30x plane Nitrishape with Niflipcontroller (61x NiSourceTexture, 256x256 size, total 15MB) - **insane lag**
NIF3: Contains 30x plane Nitrishape with Niflipcontroller (61x NiSourceTexture, 32x32 size, total 68kB) - no lag
NIF4: Contains 1000x plane Nitrishape, NO Niflipcontroller (1x NiSourceTexture, 256x256 size, total 256kB) - no lag
NIF5: Contains 800x plane Nitrishape, NO Niflipcontroller (4x NiSourceTexture, 4096x4096 size, total 74MB) - no lag (only short freeze from big texture load for first time)
So for example:
In NIF2, there is 30xcopy of same plane mesh, with same NiFlipController source textures.
NIF3 is same as NIF2, just uses 32x32 textures..
NIF4 and NIF5 is just to demonstrate that lag isn't caused by either 'too large total textures size' or 'too much overlapping mesh'
-> Lagtest in video:
- trying out NIF1 - https://youtu.be/Q3UvXp6E5D8?t=34 - no lag
- trying out NIF2 - https://youtu.be/Q3UvXp6E5D8?t=103 - This is the problem (long lasting lag)
- trying out NIF5 - https://youtu.be/oW-CmgdPSY8 - only 'short freeze only caused by loading big total texture size', but no afterwards lag
Question A: Why NIF2 lags, but NIF1 doesn't?
These two NIFS have same used texture amount/size -> So overall loaded texture size isn't direct cause of lag
Question B: Why NIF2 lags, but NIF3 doesn't?
These two NIFS have same total mesh size, and amount of nodes or controllers -> So mesh size/controller/node amount isn't direct cause of lag
So it looks like lag happens, when NIF uses "large enough" texture size AND have "multiple different Niflipcontrollers in it". Like only combination of these hits some 'memory treshold".
-> Lag description:
OpenMW
: Lag happens after NIF2 is loaded, and lasts for a long time like in the video. (NIF2 has 2.00sec anim time, but lag can last 10+sec). It's notable, that after a time, the lag passes away, and on further uses it'l disappear.
Tested this in Win10 OpenMW 0.46, 0.47, 0.48, same. didn't find any releveant-looking in openmw.log
VanillaMW
: This type of "long-lasting lag" doesn't happen. There, NIFs with NiFlipControllers may only cause a 0.5-2 sec game freeze, when game has to load large textures like 50-100MB. This is 'normal behaviour' and happens in OpenMW too as u can see with NIF5's video. It's only noticable with NIFS loaded during gameplay, like a spell effect's NIF is loaded first time when you cast it (for example mods like this uses big size anim textures for spell effects, and have lag https://www.nexusmods.com/morrowind/mods/47702
So this freeze is just the game loading in textures, but after they're loaded there's no lag. Just for note, it can be avoided with MWSE script by "pre-loading" the NIF, so you can use 'higher-res animated textures' for spell effects.
how to reproduce:
0.download rar https://drive.google.com/file/d/1VP4SYvu32psSV1aqiuPRLeRBHSq4jQ5q/view?usp=sharing
1.copy files in MW Data Files
2.enable "NiflipLagtest.esp (this will replace Lightning Shield cast effect's NIF to test)
3. To use NIF1 : In meshes/kurp/s folder, Save "vfx_k_h_ssho - NIF1.nif" as "vfx_k_h_ssho.nif"
To use NIF2: In meshes/kurp/s folder, Save "vfx_k_h_ssho - NIF2.nif" as "vfx_k_h_ssho.nif"
To use NIF3: In meshes/kurp/s folder, Save "vfx_k_h_ssho - NIF3.nif" as "vfx_k_h_ssho.nif"
To use NIF4: In meshes/kurp/s folder, Save "vfx_k_h_ssho - NIF4.nif" as "vfx_k_h_ssho.nif"
To use NIF5: In meshes/kurp/s folder, Save "vfx_k_h_ssho - NIF5.nif" as "vfx_k_h_ssho.nif"
4. Load game, and cast "lightning shield" spell, this will play the above NIF.
(ps.: sorry i'm unable to format text nicely here.)