How does Asset Injection work?

Discuss modding questions and implementation details.
User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: How does Asset Injection work?

Post by Hazelnut »

I thought you were still using the provider, I mean wasn't it added to DFU for your needs? I reported the issues I saw but when you removed that code I though it was because it had now moved into DFU core. Either way, I've not dived into what it is or how it works so can't be much help advising here - listen to TheLacus instead :D

@Blessed, that code you posted seems to completely ignore the standard DFU code for loading images, and I don't think it should be provided to other modders as the way to do things.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Daniel87
Posts: 391
Joined: Thu Nov 28, 2019 6:25 pm

Re: How does Asset Injection work?

Post by Daniel87 »

Hazelnut wrote: Thu May 27, 2021 6:00 pm I thought you were still using the provider, I mean wasn't it added to DFU for your needs? I reported the issues I saw but when you removed that code I though it was because it had now moved into DFU core. Either way, I've not dived into what it is or how it works so can't be much help advising here - listen to TheLacus instead :D

@Blessed, that code you posted seems to completely ignore the standard DFU code for loading images, and I don't think it should be provided to other modders as the way to do things.
Yes, I will have a look at the MaterialProvider tomorrow again. Not sure if the MaterialProvider alone will be of help for this issue or if I also need to mod the MaterialReader.cs

Code: Select all

Material tileMaterial = DaggerfallUnity.Instance.MaterialReader.GetTerrainTextureArrayMaterial(GetGroundArchive(terrainMaterialData.WorldClimate));
I believe in the GetTerrainTextureArrayMaterial function, the material is created and the depth of the texture2darray is set. This is outside the scope of the TerrainMaterialProvider, if I understood it right.
In Julianos we Trust.

l3lessed
Posts: 1399
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: How does Asset Injection work?

Post by l3lessed »

@Blessed, that code you posted seems to completely ignore the standard DFU code for loading images, and I don't think it should be provided to other modders as the way to do things.
Roger, thanks for the feedback. Was a quick code I grabbed to get work done fast.
My Daggerfall Mod Github: l3lessed DFU Mod Github

My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: How does Asset Injection work?

Post by TheLacus »

Daniel87 wrote: Thu May 27, 2021 6:09 pm Not sure if the MaterialProvider alone will be of help for this issue or if I also need to mod the MaterialReader.cs

Code: Select all

Material tileMaterial = DaggerfallUnity.Instance.MaterialReader.GetTerrainTextureArrayMaterial(GetGroundArchive(terrainMaterialData.WorldClimate));
I believe in the GetTerrainTextureArrayMaterial function, the material is created and the depth of the texture2darray is set.
Yes, this is correct. TextureReplacement doesn't have any knowledge of Daggerfall terrains, it only provides a texture2Darray with the required depth. This is intended and shouldn't be changed.
MaterialReader generates texture arrays (also using TextureReplacement) specifically for the terrain and expects a depth of 56 layers. This value is enforced for both prebuilt arrays (like what you are providing) and runtime genrated ones (i.e. from individual textures from KoW mod).

You should be able to retrieve your texture array asset directly from TextureReplacement (or even with Mod.GetAsset()), at least for now. Proper support for textures from other mods would be trickier. For example, what happens if the other mod doesn't have all required textures? Maybe is better to specifically get textures from a list of known compatible mods.

Post Reply