Jump to content

[0.90] DDSLoader 1.9 (Mar 9) - Loads DDS Texture "Boringly fast" edition


sarbian

Recommended Posts

So, here a plugin that uses the "GameDatabase code tweaked to allow modders to write their own asset loaders." of the 0.25 release note.

It's not flashy and does not add part, contracts, modules or even explosions. It just allow KSP to load a new type of texture.

Then what's the point Sarbian you may ask ? You see when KSP load an PNG it first decompress it and then ask Unity to compress it in a format native to your graphic card. A DDS texture file store texture in those format, so you can just load them from the disk and push them directly to your graphic card. No time lost on decompressing one format to compress in an other.

So now you may ask how faster ? Well, I did not yet convert all my texture to test, but I did one test with RSS 8k textures. In PNG it takes 3357ms to load. With DDS 116ms. The numbers speaks for themselves.

So now you have to convert your textures. This loader support the DXT1 and DXT5 format, with or without mipmap.

You can find some command line tools to convert like the Nvidia Tools or crunch. On Windows Paint.NET can save as DDS.

For normal map (files ending with NRM) I assume that they already transformed in the format Unity uses ( rgba => gggr ).

Some tools/script to make your life easier may come if there is interest.

If you don't understand what if going on here just walk away, some modders will do the work for you.

If you want to include it in your mod just make it so it ends up in <KSP>/GameData/DDSLoader

Download DDSLoader-1.9.0.0.zip

Licence is MIT, as included.

Source

1.1 Adds support for RGB and RGBA thanks to shaw

1.2 force the texture to be read only so they can go to the GPU and free memory

1.3 fix a bug with the RGB(A) loading

1.4 implement support for the DDPF_NORMAL flag for normal detection

1.5 Added suppport for skipping first N mipmaps (including original image), so this effectively works as a texture reduction. Number of skipped mipmaps can be configured in a .cfg file which contents looks like:

DDSLoader

{

mipmapBias = 1

normalMipmapBias = 2

}

normalMipmapBias specifies bias for normal maps, while mipmapBias for other mipmapped textures. Both values shoud be 0 in the default configuration file, of course.

(default config file not included in this version)

1.6

- Support for more format now support : DXT1, DXT5, A8, RGB24, BGR24, RGBA32, BGBR32, RGB565, ARGB4444 and RGBA4444

- texture with name ending with READ stays readable

- Config file for forcing a texture to be a normalMap and/or keep it readable. Example config included. You can have more than one config file (if someone want to include one in their mod DL), just don't add the mipmapBias & normalMipmapBias in those.

- It also import ATM config, so if you have the "BoulderCo\ActiveTextureManagerConfigs" dir you have exception for a lot already.

- Changed the exposed call to be more usable by mods who need to load a DDS

1.7 Fix error with some DXT1/5 and make Apply() optional for the plugin who need to load a texture but don't want to display it (resource map,...)

1.8 Rebuild for 0.90 + minor fix

1.9 Fix an Unity bug for those playing with Half or Q

A big thanks to Shaw for his patch.

btn_donate_SM.gif

Edited by sarbian
Link to comment
Share on other sites

Presumably like FireSpitter, where the all copies go to ...\GameData\DDSLoader\Plugins and if you want to include it, they all include the plugin at that exact location so they don't end up with multiple copies

Link to comment
Share on other sites

Since my 0.25 install now take 3 whole minutes to load and I'm not done with mods yet, I will definitely take a look at this.

How does this work? you just put the dll in a GameData folder and KSP is able to load DDS?(edit: is there anything else to do, mod-side, apart from converting textures?)

Edited by Lilleman
Link to comment
Share on other sites

Are they larger or smaller memory use wise?

memory use would be the same; but it would avoid the current TGA (sporadic loading/not loading) and PNG (no mipmaps) loading problems nicely. and DDS would be smaller downloads than MBM files.

Edited by nli2work
Link to comment
Share on other sites

Lilleman : nothing more. Once the dll is here KSP know how to load DDS and does it. You just have to convert the texture.

Nori : the DXT1 and DXT5 are how texture end up in memory so I don't think it will save any memory or use more. But who know ...

Link to comment
Share on other sites

Well, DXT1 compresses noticeably more than the other formats, because it doesn't save the alpha data.

DXT5 does on the other hand and therefore the textures end up being clearly bigger in size.

Yay, diffuse only...

EDIT: Forgot to mention that DXT1a does actually have a 1-bit alpha.

EDIT2: DXT1 uses half as much space, yes that's 50% of what DXT5 takes.

Edited by slumpie
Link to comment
Share on other sites

I should say something witty about taking a leak now... but my brain is fried after classes today. Interestingly enough, I believe we were just discussing file formats the other day in one of the dev threads I frequent. I just can't quite remember which one...

Link to comment
Share on other sites

So, I made some quick tests: I made a copy of my modded install (1.2GB of mods, it's not that much but I don't use ATM), and converted everything to dxt5 with crunch (1376 textures converted, to be precise).

RPM don't seems to like it, so I had to switch back to old textures format for this mod. Also, some textures seems to be flipped (see the Chatterer icon in the screen). Other than that, everything seems to be normal.

As for the most important part, the loading time: I used a chronometer, started it as soon as I hit the "enter" key to launch KSP, and stop it as soon as I hear the first note of the main menu theme:

I went from 3min20 to 1min37... It litterally divide my loading time by 2!

That's very promising! More rep for you, my good sir!

Edit : Whoops, it seems like I spoke too soon, once again... Some mods don't load textures correctly, while others are running just fine... I'll try that again later, one mod at a time.

Edited by Lilleman
Link to comment
Share on other sites

It looks like you can redistribute the crnlib library (the one used by Crunch), I don't know what's Squad's policy about mods with dependencies, though. Worst case scenario: the source code of crnlib is available.

Link to comment
Share on other sites

Does this mean that editing textures becomes harder? I like to adjust mod made texture more to my liking sometimes, but I do not see that happening with this.

No, DDS files can be edited the same as other formats like tga or png.

.mbm files however are a pain to work with.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...