Jump to content

[WIP][0.23.5] AlternativeTextureLoader 0.1.4 | Temporarily suspended


NasenSpray

Recommended Posts

Note: Downloads for recent versions temporarily suspended


AlternativeTextureLoader 0.1.4

This mod replaces/augments KSP's texture loader to dramatically improve loading time.

ATL supports texture compression, scaling and has automatic normal map detection.

Why should I use it?

  • ​It's really fast
  • It saves more RAM than ATM:

[TABLE=class: outer_border, width: 1000]

[TR]

[TD]Config[/TD]

[TD]Memory[/TD]

[TD]Load time[/TD]

[TD]Notes[/TD]

[/TR]

[TR]

[TD]KSP1[/TD]

[TD]2.77GB[/TD]

[TD]45s[/TD]

[TD][/TD]

[/TR]

[TR]

[TD]KSP1+ATM[/TD]

[TD]1.60GB[/TD]

[TD]56s[/TD]

[TD]compression, 1/2 normal maps with max. 512x512[/TD]

[/TR]

[TR]

[TD]KSP1+ATL[/TD]

[TD]1.59GB[/TD]

[TD]23s[/TD]

[TD]compression only[/TD]

[/TR]

[TR]

[TD]KSP1+ATL[/TD]

[TD]1.40GB[/TD]

[TD]23s[/TD]

[TD]compression, 1/2 normal maps with max. 512x512[/TD]

[/TR]

[TR]

[TD][/TD]

[TD][/TD]

[TD][/TD]

[TD][/TD]

[/TR]

[TR]

[TD]KSP2[/TD]

[TD]-[/TD]

[TD]-[/TD]

[TD]Out of Memory[/TD]

[/TR]

[TR]

[TD]KSP2+ATM[/TD]

[TD]2.73GB[/TD]

[TD]138s[/TD]

[TD]compression, 1/2 normal maps with max. 512x512[/TD]

[/TR]

[TR]

[TD]KSP2+ATL[/TD]

[TD]2.23GB[/TD]

[TD]48s[/TD]

[TD]compression, 1/2 normal maps with max. 512x512[/TD]

[/TR]

[/TABLE]

Test system: Win7 x64, i5-750, 8GB RAM, SSD

How does it work?

It saves already compressed/mip-mapped textures in a single file (that's also compressed with LZ4), called the cache. That allows to skip every post-processing step that KSP normally does while loading.

It interfaces with DirectX (and now also Mono/Unity) in order to do that.

Supported plattforms

  • Windows XP/Vista/7/8/8.1 32/64-bit, DirectX, 32-bit KSP only

Features

  • DXT1/DXT5 compression depending on actual alpha channel usage
  • Configurable scaling with upper/lower limits
  • LZ4 compression of the cache
  • "Fake" start-up routine for bootstrapping

Usage

  • Install ATL (copy contents into GameData)
  • Start KSP
  • Wait until main menu
  • Set your desired settings
  • Hit "Rebuild cache"
  • Restart KSP
  • Enjoy
  • Repeat this process whenever you install/remove mods

Settings

  • ​Scaling: How much the textures should be scaled while building the cache
  • Min. dimensions: Neither side of a texture will be scaled down lower than this. Textures are never upscaled
  • Max. dimensions: Neither side of a texture will exceed this size after scaling, even with 1/1 scaling
  • Scaling always maintains aspect ratio
  • config.cfg (created after first start):
    • compressColor/compressNormal [true/false] Normal-map compression may lead to lightning artifacts and needs to be activated manually

Download

  • ATL 0.1 binary
  • Source (v0.1; License: None, aka all rights reserved, until further development)
  • Note: Current version will be back up soon!

Possibly Asked Questions

  • Do I still need ATM for bootstrapping?

Nope. ATL now performs a memory saving dummy start on first usage and whenever you delete your cache!

  • Do I really need to rebuild when I remove/add mods?

No, you actually don't. Added textures will be loaded by KSP and removed textures are simply not loaded at all (but still in cache)

  • What is this "native.dlz" file and why is it so big?

It's a native DLL written in C++ and has this weird file extension so that KSP doesn't try to load it as an add-on.

It contains the native portion of ATL dealing with DirectX/Mono/Unity and is statically linked with the size inflating CRT.

Known incompatibilities

  • ATM
  • Texture replacement mods, e.g. TextureReplacer
  • All mods that need access to texture data
    • ​EVE, LoadOnDemand etc.
    • Temporary fix:
      Uninstall these mods and everything they modify, rebuild the cache, reinstall them and hope it works.
      Log messages like "Texture ' ' has no data" mean that there are still cached textures they need to access.
    • 0.1.3 has rudimentary support for EVE (it's always super cloudy :D)

Known Problmens

  • Textures that have an alpha channel for no ********** reason prevent the usage of DXT1
    • That can only be solved by the creators of those textures (not SQUAD, they only use alpha when needed :) )

Roadmap

  • Taking control of UnityEngine.Texture2D
    • transparent handling of GetPixel/SetPixel calls etc
    • needed to get texture replacement mods working
    • first steps done since 0.1.2

    [*]Incremental/offline cache build

    • Incremental: append only, the file format doesn't allow for removal

    [*]KSP 64-bit support

    [*]Texture upload to Video RAM

    [*]perhaps OpenGL/Linux support

Credits

  • rbray89, the creator of ATM, for the inspiration
  • JetBrains dotPeek, it allowed me to figure out how KSP works internally

When stuff goes wrong

ATL creates a log file called atl.log in GameData. Post/Send it together with the regular KSP.log file and I'll see what went wrong.

Changelog


= 0.1.4 ==========================
- memory saving first start-up by replacing every texture with a dummy
-> no dependency on ATM!

= 0.1.3 ==========================
- fixed bug that made unmanaged normal-maps load ultra slow

= 0.1.2 ==========================
- fake EVE support (clouds are different)
-> Texture2D.GetPixel() & Texture2D.GetPixelBilinear() calls are now intercepted for every managed texture
-> everyone who calls GetPixel() gets solid black
-> everyone who calls GetPixelBilinear() gets a random shade of light gray (EVE's using that to determine cloud color)

= 0.1.1 ==========================
- removed useless log messages
- fixed compatibility with ProceduralParts/StretchyTanks
-> ATL didn't set UnityEngine.Texture.name

= 0.1 ============================
- initial release

Edited by NasenSpray
added top message, removed suspended links
Link to comment
Share on other sites

yeah, i just changed the title to include the KSP version and now the content is gone -.-

@mods: do i need to create a new thread or can this be fixed somehow? i can't edit anything

Edit: Thank you, DYJ!

Edited by NasenSpray
Link to comment
Share on other sites

yeah, i just changed the title to include the KSP version and now the content is gone -.-

Seems the whole topic vanished. Perhaps it's because you were replacing the default loader or something? I was just about to download and test it as it seemed like a pretty damn good mod! May be a bit to get it going, but I'm sure it'd have been well worth it. Once it's back up, you best bet I'll be trying it out!

Edit: so confused. How in the kerbalverse did Space_Kraken become the first poster o.0?

Link to comment
Share on other sites

Seems the whole topic vanished. Perhaps it's because you were replacing the default loader or something? I was just about to download and test it as it seemed like a pretty damn good mod! May be a bit to get it going, but I'm sure it'd have been well worth it. Once it's back up, you best bet I'll be trying it out!

Edit: so confused. How in the kerbalverse did Space_Kraken become the first poster o.0?

I don't think it has anything to do with that as my posts go through moderation. I'm going to create a new thread...

Link to comment
Share on other sites

If this works as advertised it would possibly be really neat, not sure I'm brave enough to try it though. Report your findings Kraky.

I've hit ram limit with full res textures + non-aggressive ATM, half res/aggressive ATM makes the game pretty horrible to look at.

Edited by K3|Chris
Link to comment
Share on other sites

If this works as advertised it would possibly be really neat, not sure I'm brave enough to try it though. Report your findings Kraky.

I've hit ram limit with full res textures + non-aggressive ATM, half res/aggressive ATM makes the game pretty horrible to look at.

Start your game with aggressive ATM, make the first build, restart without ATM, tweak settings and rebuild again. The second rebuild overrides any scaling ATM has done.

Already have a suggestion. Could ATL possibly rebuild caches upon first start before ksp fully initializes, that way we won't have to start ksp twice each time we install a mod?

The problem is that the normal map detection only works after KSP loaded all parts. That's the reason ATM needs config files for all the mods... But you don't need to rebuild instantly as uncached textures are still loaded by KSP.

Apparently I hit the memory limit, and then my game crashed.

ATL creates logs (in KSP.log and GameData/atl.log). Please send them to me and I can take a look at why it's crashing.

Edited by NasenSpray
Link to comment
Share on other sites

+1 for working, with the default settings i have about the same memory usage, and 1/3 the loading time upon gamestart.

+1 for the method to make the change from ATM simple, it works well if you install it right.

-1 for not working with the EnvironmentalVisualEnhancements mod, generally low frames, very low during timewarp, and 0 fps on the mapscreen, the debug log is spammed with [Error]: Texture '' has no data. Removing the mod fixes the issue.

Edited by MilkDust
Link to comment
Share on other sites

+1 for working, with the default settings i have about the same memory usage, and 1/3 the loading time upon gamestart.

+1 for the method to make the change from ATM simple, it works well if you install it right.

-1 for not working with the EnvironmentalVisualEnhancements mod, generally low frames, very low during timewarp, and 0 fps on the mapscreen, the debug log is spammed with [Error]: Texture '' has no data. Removing the mod fixes the issue.

Thanks for reporting. I hope I can solve that :)

Link to comment
Share on other sites

Time for my unsuccessful results......

zU4gHlt.jpg

There's my mod folder, or rather the one with ATL installed. My first test was using the exact same mods, with LoadOnDemand and ATM aggressive. According to process explorer, the private byte usage was 2,612,840. This was while loaded with the KerbalX on the launchpad.

Upon using ATL, and following the directions to get it up and going with ATM, I manage to get to the space center, but upon trying to launch a ship(kerbalX), the game peaks out the memory usage. It also spits out the same error in my debug log as the person above. "Texture '' has no data (Filename: Line: 995)" I have exactly 259,079 instances of this in my log. Unfortunately, I had to force quit the game, so no crash log(or atl.log) was generated. Upon looking at process explorer(before quiting), my private byte usage was well over 3,500,000

I will try again later and see about adding each mod 1 by 1 to see if there's one specific one doing it. Seeing as me and MilkDust are both using EVE, I'm suspecting that. But, I will update you with my findings!

Link to comment
Share on other sites

Time for my unsuccessful results......

http://i.imgur.com/zU4gHlt.jpg

There's my mod folder, or rather the one with ATL installed. My first test was using the exact same mods, with LoadOnDemand and ATM aggressive. According to process explorer, the private byte usage was 2,612,840. This was while loaded with the KerbalX on the launchpad.

Upon using ATL, and following the directions to get it up and going with ATM, I manage to get to the space center, but upon trying to launch a ship(kerbalX), the game peaks out the memory usage. It also spits out the same error in my debug log as the person above. "Texture '' has no data (Filename: Line: 995)" I have exactly 259,079 instances of this in my log. Unfortunately, I had to force quit the game, so no crash log(or atl.log) was generated. Upon looking at process explorer(before quiting), my private byte usage was well over 3,500,000

I will try again later and see about adding each mod 1 by 1 to see if there's one specific one doing it. Seeing as me and MilkDust are both using EVE, I'm suspecting that. But, I will update you with my findings!

Every mod that needs access to texture data (LoadOnDemand, EVE etc) won't work with ATL right now because Unity doesn't care to give access to DXT compressed textures even though they are still in RAM. I'm working on EVE and TextureReplacer (that will take some time, I need to hook Unity), but I don't think LoadOnDemand will ever work.

Link to comment
Share on other sites

Every mod that needs access to texture data (LoadOnDemand, EVE etc) won't work with ATL right now because Unity doesn't care to give access to DXT compressed textures even though they are still in RAM. I'm working on EVE and TextureReplacer (that will take some time, I need to hook Unity), but I don't think LoadOnDemand will ever work.

Please note that I do NOT have lod installed for testing out ATL ;) I figured there would be issues so I didn't even attempt to try it. Don't get me wrong tho.....I was tempted to test the compatibility between the two :P

Still a bit confused why there is an issue with EVE, if the issue is even with eve. I'll be tracking down the error tonight to see which of my mods broke ATL. My next test will be just one mod +atl for each test, to determine which mods will cause an error(aside from eve)

In the meantime, mind writing us a small guide on what each of the settings do? I felt pretty dumb looking at it so I just used the default setting :)

Link to comment
Share on other sites

Please note that I do NOT have lod installed for testing out ATL ;) I figured there would be issues so I didn't even attempt to try it. Don't get me wrong tho.....I was tempted to test the compatibility between the two :P

Still a bit confused why there is an issue with EVE, if the issue is even with eve. I'll be tracking down the error tonight to see which of my mods broke ATL. My next test will be just one mod +atl for each test, to determine which mods will cause an error(aside from eve)

In the meantime, mind writing us a small guide on what each of the settings do? I felt pretty dumb looking at it so I just used the default setting :)

Wow, thanks for the help! :D EVE is an issue because it needs to (afaik) modify textures on the fly. Unity's way of providing access to textures is to hold onto a copy of the raw texture data. But I'm loading the textures directly using DirectX and hand them to Unity as external textures. The only solution is either to exclude every texture from ATL that needs to be modified or to trap calls to the texture manipulation functions... the former needs config files that are a pain in the ass to maintain, but the latter can be done by replacing Unity's internal calls and should work universally.

Edited by NasenSpray
Link to comment
Share on other sites

I have found another bug. Stretchy tanks and probably Procedural Parts(not tested) have multiple textures for a single part wich can be changed ingame, it does not work, and the debug log says [Log]: *ST* Textures not found for German, where German is the name of the texture(same error msg for the rest of the textures, only the texture name changes). However the default texture for the parts does load.

Link to comment
Share on other sites

I have found another bug. Stretchy tanks and probably Procedural Parts(not tested) have multiple textures for a single part wich can be changed ingame, it does not work, and the debug log says [Log]: *ST* Textures not found for German, where German is the name of the texture(same error msg for the rest of the textures, only the texture name changes). However the default texture for the parts does load.

Thanks for reporting, fixed in 0.1.1 :)

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...