sarbian Posted October 13, 2014 Share Posted October 13, 2014 (edited) 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/DDSLoaderDownload DDSLoader-1.9.0.0.zipLicence is MIT, as included.Source1.1 Adds support for RGB and RGBA thanks to shaw1.2 force the texture to be read only so they can go to the GPU and free memory1.3 fix a bug with the RGB(A) loading1.4 implement support for the DDPF_NORMAL flag for normal detection1.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 DDS1.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 fix1.9 Fix an Unity bug for those playing with Half or QA big thanks to Shaw for his patch. Edited March 9, 2015 by sarbian Link to comment Share on other sites More sharing options...
nli2work Posted October 13, 2014 Share Posted October 13, 2014 how do you anticipate modders to distribute this? would multiple copies conflict? Should it be in the root GameData foler like ModuleManager? I doubt this is something a player would install by itself. Link to comment Share on other sites More sharing options...
Nori Posted October 13, 2014 Share Posted October 13, 2014 Are they larger or smaller memory use wise? Link to comment Share on other sites More sharing options...
NoMrBond Posted October 13, 2014 Share Posted October 13, 2014 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 More sharing options...
sarbian Posted October 13, 2014 Author Share Posted October 13, 2014 (edited) Edit : OK I ll move it to a folder. Let me edit the script.ok, script edited. now GameData/DDSLoader/DDSLoader.dll Edited October 13, 2014 by sarbian Link to comment Share on other sites More sharing options...
Lilleman Posted October 13, 2014 Share Posted October 13, 2014 (edited) 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 October 13, 2014 by Lilleman Link to comment Share on other sites More sharing options...
Surefoot Posted October 13, 2014 Share Posted October 13, 2014 Are they larger or smaller memory use wise?Should end up being the same, as long as the stock loader disposes of original files properly to clear up RAM. Link to comment Share on other sites More sharing options...
nli2work Posted October 13, 2014 Share Posted October 13, 2014 (edited) 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 October 13, 2014 by nli2work Link to comment Share on other sites More sharing options...
sarbian Posted October 13, 2014 Author Share Posted October 13, 2014 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 More sharing options...
Nori Posted October 13, 2014 Share Posted October 13, 2014 Well this is definitely a exciting option. Don't know about anyone else but my heavily modded KSP takes forever to load up... Link to comment Share on other sites More sharing options...
slumpie Posted October 13, 2014 Share Posted October 13, 2014 (edited) 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 October 14, 2014 by slumpie Link to comment Share on other sites More sharing options...
Paul Kingtiger Posted October 13, 2014 Share Posted October 13, 2014 This looks really promising, thanks Sabrian! Link to comment Share on other sites More sharing options...
slumpie Posted October 13, 2014 Share Posted October 13, 2014 Oh right, forgot to say that.Good job, once again I guess. Link to comment Share on other sites More sharing options...
NathanKell Posted October 13, 2014 Share Posted October 13, 2014 nli2work: memory usage should go down since as I understand it the existing loaders leak >.> Link to comment Share on other sites More sharing options...
Gaalidas Posted October 13, 2014 Share Posted October 13, 2014 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 More sharing options...
Lilleman Posted October 13, 2014 Share Posted October 13, 2014 (edited) 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 October 13, 2014 by Lilleman Link to comment Share on other sites More sharing options...
Camacha Posted October 13, 2014 Share Posted October 13, 2014 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. Link to comment Share on other sites More sharing options...
sarbian Posted October 13, 2014 Author Share Posted October 13, 2014 You're one who see the glass half empty aren't you ? Link to comment Share on other sites More sharing options...
rbray89 Posted October 13, 2014 Share Posted October 13, 2014 As soon as I create/find a library to save files as DDS... Link to comment Share on other sites More sharing options...
rbray89 Posted October 13, 2014 Share Posted October 13, 2014 One thing everyone should note, is that Normal Maps should still be RGBA. Link to comment Share on other sites More sharing options...
Lilleman Posted October 13, 2014 Share Posted October 13, 2014 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 More sharing options...
m1919 Posted October 13, 2014 Share Posted October 13, 2014 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 More sharing options...
nli2work Posted October 14, 2014 Share Posted October 14, 2014 NathanKell: Even better! rbray89: _NRM maps should still be MBM/PNG/TGA? DXT5 should be good for _NRM no? 8bbp RGBAlooks like I need to read up on DXT formats first. Link to comment Share on other sites More sharing options...
slumpie Posted October 14, 2014 Share Posted October 14, 2014 (edited) DXT is known to do bad things to normalmaps though.EDIT2: Apparently you can use DXT5nm. That would be preferable. Edited October 14, 2014 by slumpie Link to comment Share on other sites More sharing options...
Urgante Posted October 14, 2014 Share Posted October 14, 2014 I converted to DDS using Xnview.Around half loading time, from 4 min to 2.All stock textures working fine.Some mod textures not working, (parts are totally white, toolbar icons are purple). http://oi59.tinypic.com/2e0sfit.jpgStill, very promising mod, thanks sarbian Link to comment Share on other sites More sharing options...
Recommended Posts