Mod Texture Load failures
-
- Posts: 102
- Joined: Tue Feb 12, 2019 12:55 am
Mod Texture Load failures
I decided to try to debug some of the texture load failures that happen when you load textures from a Mod that haven't been prepared correctly with the editor. I get (eventually) thousands of errors that read Texture atlas needs textures to have Readable flag set! There's a 1/2 dozen posts on this online but there doesn't seem to be a way to programatically edit the texture.
Anyway, before I spend more time on this I wanted to see if it was worth it since it seems, based on what I'm reading, it will take rewriting the texture with an editor which might not be a small feat.
Anyway, before I spend more time on this I wanted to see if it was worth it since it seems, based on what I'm reading, it will take rewriting the texture with an editor which might not be a small feat.
- King of Worms
- Posts: 4753
- Joined: Mon Oct 17, 2016 11:18 pm
- Location: Scourg Barrow (CZ)
- Contact:
Re: Mod Texture Load failures
I set read/write flags in unity inspector. You can batch-select as many files as u want and than change this flag on all of them.jimfcarroll wrote: ↑Tue Sep 17, 2019 1:01 pm I decided to try to debug some of the texture load failures that happen when you load textures from a Mod that haven't been prepared correctly with the editor. I get (eventually) thousands of errors that read Texture atlas needs textures to have Readable flag set! There's a 1/2 dozen posts on this online but there doesn't seem to be a way to programatically edit the texture.
Anyway, before I spend more time on this I wanted to see if it was worth it since it seems, based on what I'm reading, it will take rewriting the texture with an editor which might not be a small feat.
Which mods have this problem?
DREAM Nexus https://www.nexusmods.com/users/73250038?tab=user+files
DREAM Forums viewtopic.php?f=27&t=1168
DISCORD: king_of_worms_cz
DREAM Forums viewtopic.php?f=27&t=1168
DISCORD: king_of_worms_cz
-
- Posts: 102
- Joined: Tue Feb 12, 2019 12:55 am
Re: Mod Texture Load failures
Good question. With only the DREAM mod installed (though I know there's a bunch of dfmod files as part of this) I get 40 of these as the startup screen is loading (Note: I added my own log statement so the line numbers for TextureReader.cs are slightly off):
Code: Select all
Texture atlas needs textures to have Readable flag set!
UnityEngine.Texture2D:PackTextures(Texture2D[], Int32, Int32, Boolean)
DaggerfallWorkshop.Utility.TextureReader:GetTexture2DAtlas(GetTextureSettings, SupportedAlphaTextureFormats) (at Assets/Scripts/Utility/TextureReader.cs:434)
DaggerfallWorkshop.MaterialReader:GetMaterialAtlas(Int32, Int32, Int32, Int32, Rect[]&, RecordIndex[]&, Int32, Boolean, Int32, Boolean, Boolean) (at Assets/Scripts/MaterialReader.cs:531)
DaggerfallWorkshop.DaggerfallBillboardBatch:SetMaterial(Int32, Boolean) (at Assets/Scripts/Internal/DaggerfallBillboardBatch.cs:187)
DaggerfallWorkshop.Utility.GameObjectHelper:CreateBillboardBatchGameObject(Int32, Transform) (at Assets/Scripts/Utility/GameObjectHelper.cs:1242)
DaggerfallWorkshop.Utility.GameObjectHelper:CreateRMBBlockGameObject(DFBlock, Int32, Int32, Boolean, DaggerfallRMBBlock, DaggerfallBillboardBatch, DaggerfallBillboardBatch, DaggerfallBillboardBatch, TextureAtlasBuilder, DaggerfallBillboardBatch, ClimateNatureSets, ClimateSeason) (at Assets/Scripts/Utility/GameObjectHelper.cs:481)
DaggerfallWorkshop.Utility.GameObjectHelper:CreateRMBBlockGameObject(String, Int32, Int32, Boolean, DaggerfallRMBBlock, DaggerfallBillboardBatch, DaggerfallBillboardBatch, DaggerfallBillboardBatch, TextureAtlasBuilder, DaggerfallBillboardBatch, ClimateNatureSets, ClimateSeason) (at Assets/Scripts/Utility/GameObjectHelper.cs:410)
DaggerfallWorkshop.Game.UserInterfaceWindows.DaggerfallUnitySetupGameWizard:CreateBackdrop() (at Assets/Scripts/Game/UserInterfaceWindows/DaggerfallUnitySetupGameWizard.cs:247)
DaggerfallWorkshop.Game.UserInterfaceWindows.DaggerfallUnitySetupGameWizard:ShowOptionsPanel() (at Assets/Scripts/Game/UserInterfaceWindows/DaggerfallUnitySetupGameWizard.cs:419)
DaggerfallWorkshop.Game.UserInterfaceWindows.DaggerfallUnitySetupGameWizard:ShowNextStage() (at Assets/Scripts/Game/UserInterfaceWindows/DaggerfallUnitySetupGameWizard.cs:608)
DaggerfallWorkshop.Game.UserInterfaceWindows.DaggerfallUnitySetupGameWizard:Update() (at Assets/Scripts/Game/UserInterfaceWindows/DaggerfallUnitySetupGameWizard.cs:184)
DaggerfallWorkshop.Game.DaggerfallUI:Update() (at Assets/Scripts/Game/DaggerfallUI.cs:362)
I couldn't find a method on `Texture2D` that would tell me if the texture was going to have this problem when it was given to `PackTextures` but it also seems to cause `Apply` to throw an exception so I added this right before the call:
Code: Select all
Debug.LogFormat("Total number of textures: {0}", albedoTextures.Count);
foreach (var cur in albedoTextures)
{
try
{
cur.Apply();
}catch
{
Debug.LogFormat(" ----> {0}, {1}", cur.name, cur);
}
}
Code: Select all
201_0-0
201_0-1
201_0-2
201_0-3
201_1-0
201_1-1
201_1-2
201_1-3
201_2-0
201_3-0
201_3-1
201_3-2
201_3-3
201_4-0
201_4-1
201_4-2
201_4-3
201_5-0
201_5-1
201_5-2
201_5-3
201_6-0
201_6-1
201_6-2
201_7-0
201_7-1
201_7-2
201_7-3
201_8-0
201_8-1
201_8-2
201_8-3
201_9-0
201_9-1
201_9-2
201_9-3
201_10-0
201_10-1
201_10-2
201_11-0
- King of Worms
- Posts: 4753
- Joined: Mon Oct 17, 2016 11:18 pm
- Location: Scourg Barrow (CZ)
- Contact:
Re: Mod Texture Load failures
Will check those textures thank u.
I never seen any deffinitive guide on read/write
All is just few msgs during the years.. so its a miracle it works and has only 40 reports mostly from one single archive from grand total of 10 000s
I never seen any deffinitive guide on read/write
All is just few msgs during the years.. so its a miracle it works and has only 40 reports mostly from one single archive from grand total of 10 000s
DREAM Nexus https://www.nexusmods.com/users/73250038?tab=user+files
DREAM Forums viewtopic.php?f=27&t=1168
DISCORD: king_of_worms_cz
DREAM Forums viewtopic.php?f=27&t=1168
DISCORD: king_of_worms_cz
-
- Posts: 102
- Joined: Tue Feb 12, 2019 12:55 am
Re: Mod Texture Load failures
Maybe the tool that packs the mod components into the .dfmod file can check the textures before putting them in? If you point me to the code where that's done I can take a look.
- King of Worms
- Posts: 4753
- Joined: Mon Oct 17, 2016 11:18 pm
- Location: Scourg Barrow (CZ)
- Contact:
Re: Mod Texture Load failures
Please let The Lacus know about it. He knows a lot about modding framework. Im just a peasant using his work either he will know or he will provide a direction. Sry I cant help more.jimfcarroll wrote: ↑Wed Sep 18, 2019 12:28 pm Maybe the tool that packs the mod components into the .dfmod file can check the textures before putting them in? If you point me to the code where that's done I can take a look.
I can only confirm that having all the flags right is not trivial, esp for newcommers to modding.
Thank you for investigating this stuff!
DREAM Nexus https://www.nexusmods.com/users/73250038?tab=user+files
DREAM Forums viewtopic.php?f=27&t=1168
DISCORD: king_of_worms_cz
DREAM Forums viewtopic.php?f=27&t=1168
DISCORD: king_of_worms_cz
- TheLacus
- Posts: 1305
- Joined: Wed Sep 14, 2016 6:22 pm
Re: Mod Texture Load failures
Read/write flag is required when a texture needs to be edited at run time. For example many UI images are cut to individual pieces (buttons, panels) ; another example is the optional x16 grid which is created from original texture.
The modding documentation explain when this flag is needed, or at least it aim to; currently there is not a complete list of textures but is possible to make one, provided someone want to invest what could be a considerable amount of time in this.
The modding documentation explain when this flag is needed, or at least it aim to; currently there is not a complete list of textures but is possible to make one, provided someone want to invest what could be a considerable amount of time in this.
-
- Posts: 102
- Joined: Tue Feb 12, 2019 12:55 am
Re: Mod Texture Load failures
My suggestion was to change the tool that builds the .dfmod file to validate any textures by checking the flag. If you think this makes sense and want to point me to the right area of the codebase, I'll give it a shot.
As it is, with a large swath of mods installed, I get this error I mentioned 1000's of times (the count of errors stops at 999+).
As it is, with a large swath of mods installed, I get this error I mentioned 1000's of times (the count of errors stops at 999+).
- TheLacus
- Posts: 1305
- Joined: Wed Sep 14, 2016 6:22 pm
Re: Mod Texture Load failures
I think i should explain what Read/Write flag does. By default a texture is stored inside video-ram, which means that cpu code can't access it directly. Sometimes is necessary to perform modifications to a texture, so the workaround is to keep a copy of texture data in ram, make changes to this copy and then upload it to v-ram. This means that additional memory is used, so is not acceptable to force this flag on all textures bundled with a mod. It's up mod authors to set required inspector options for each texture.jimfcarroll wrote: ↑Thu Sep 19, 2019 12:29 pm My suggestion was to change the tool that builds the .dfmod file to validate any textures by checking the flag. If you think this makes sense and want to point me to the right area of the codebase, I'll give it a shot.
As it is, with a large swath of mods installed, I get this error I mentioned 1000's of times (the count of errors stops at 999+).
Some automatization might be possible if we had a list of textures that need it; but, as i said, it would be a laborious work to write it and it would also be susceptible of changes.
-
- Posts: 102
- Joined: Tue Feb 12, 2019 12:55 am
Re: Mod Texture Load failures
Thanks for the explanation. That makes sense.
Perhaps I could automate determining which ones require it. Any texture passed to PackTextures here:
https://github.com/Interkarma/daggerfal ... er.cs#L423
... fails if the read/write flag isn't set. The problem is, the context of which textures are passed there (that is, their origin) is lost by the time that call is made, so I can't track where the textures originally came from without some changes. Would it be worth doing that?
Also, would it be worth programatically setting the read/write flag in places like that call. I know this isn't trivial and if it's possible, probably requires something along the lines of rewriting the texture to disk then using editor functionality to change the flag, then reloading them.
Perhaps I could automate determining which ones require it. Any texture passed to PackTextures here:
https://github.com/Interkarma/daggerfal ... er.cs#L423
... fails if the read/write flag isn't set. The problem is, the context of which textures are passed there (that is, their origin) is lost by the time that call is made, so I can't track where the textures originally came from without some changes. Would it be worth doing that?
Also, would it be worth programatically setting the read/write flag in places like that call. I know this isn't trivial and if it's possible, probably requires something along the lines of rewriting the texture to disk then using editor functionality to change the flag, then reloading them.