Help us make VIO and DREAM actually compatible

Discuss modding questions and implementation details.
User avatar
King of Worms
Posts: 3945
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow (CZ)
Contact:

Help us make VIO and DREAM actually compatible

Post by King of Worms »

Ok, so...

Dream and VIO are not compatible. And both me and Kamer are bombarded with bug reports ever since...
It because VIO makes changes in the sprite atlas and swaps things around. And Dream uses modded high-res sprites, and they are - since modded - not in that atlas anymore, but somewhere else.

Thats what I understand is going on.
Is that even right? :lol:

Is there any chance some change either in DFU or VIO or DREAM can change this situation?

Thanks a lot :)

DREAM http://forums.dfworkshop.net/viewtopic. ... 7fd1187dcf
VIO http://forums.dfworkshop.net/viewtopic. ... 7fd1187dcf

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

Re: Help us make VIO and DREAM actually compatible

Post by l3lessed »

I would have to see the code, but he should be able to change out the code that swaps the atlas changes with code that grabs your hi-res sprites from whatever object/path they are held at/in. Null errors will continue to hit your mods until VIO loads your mod objects/hi-res sprites and updates the billboard swapping code to grab your sprite objects instead of the atlas objects.

Magicon had this issue in a different way with my mod. We had to load my mod raw scripts via namespace, so his mod had access to my objects for use in his CalculateAttackDamage formula code/object. Sounds like the same issue of not having access to your objects and not having a coded patch that pulls your sprite objects in place of the default atlas ones.
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
King of Worms
Posts: 3945
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow (CZ)
Contact:

Re: Help us make VIO and DREAM actually compatible

Post by King of Worms »

Thanks a lot for reply and idea I3lessed :) I will redirect Kamer here, I hope he will drop by when he has some time.

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

Re: Help us make VIO and DREAM actually compatible

Post by TheLacus »

King of Worms wrote: Sun Dec 20, 2020 6:03 pm Is there any chance some change either in DFU or VIO or DREAM can change this situation?
Maybe Kamer can use a different approach when custom textures are available. For example mod authors can override and take control of NPCs look by extending MobilePersonAsset. I might be able to give a more on point answer with precise information on how VIO works. ;)
Mod System documentation - Learn how to create mods for Daggerfall Unity.
Modder Discussion - General help and discussion for the mod system.
Github Issues - Submit a bug report for the game, including the mod system.

User avatar
Kamer
Posts: 548
Joined: Mon Mar 05, 2018 9:26 pm

Re: Help us make VIO and DREAM actually compatible

Post by Kamer »

TheLacus wrote: Tue Dec 22, 2020 3:07 pm
King of Worms wrote: Sun Dec 20, 2020 6:03 pm Is there any chance some change either in DFU or VIO or DREAM can change this situation?
Maybe Kamer can use a different approach when custom textures are available. For example mod authors can override and take control of NPCs look by extending MobilePersonAsset. I might be able to give a more on point answer with precise information on how VIO works. ;)
Its just one line that changes the mseh of the Gameobject.

Code: Select all

gameObject.GetComponentInChildren<MeshRenderer>().material.mainTexture = guardTorchTexture;
Its simple, and straight to the point. It also lets me add in graphics without having to replace anything specifically.

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

Re: Help us make VIO and DREAM actually compatible

Post by TheLacus »

Kamer wrote: Tue Dec 22, 2020 7:26 pm
TheLacus wrote: Tue Dec 22, 2020 3:07 pm
King of Worms wrote: Sun Dec 20, 2020 6:03 pm Is there any chance some change either in DFU or VIO or DREAM can change this situation?
Maybe Kamer can use a different approach when custom textures are available. For example mod authors can override and take control of NPCs look by extending MobilePersonAsset. I might be able to give a more on point answer with precise information on how VIO works. ;)
Its just one line that changes the mseh of the Gameobject.

Code: Select all

gameObject.GetComponentInChildren<MeshRenderer>().material.mainTexture = guardTorchTexture;
Its simple, and straight to the point. It also lets me add in graphics without having to replace anything specifically.
You can use TextureReplacement.TryImportTexture(Int32, Int32, Int32, out Texture2D) to import a texture from mods. If you only want to know if a texture exists, you can combine TextureReplacement.TextureExistsAmongLooseFiles(Int32, Int32, Int32, TextureMap) (which doesn't import it) and ModManager.TryGetAsset<Texture2D>(String, false, out tex) (which relies on a cache).

If custom texture exists, material.mainTexture should be a single texture instead of an atlas, so you should be able to handle these two cases as needed.


I'd still suggest to look into extending MobilePersonBillboard and override SetPerson(Races race, Genders gender, int personVariant, bool isGuard) so you can alter this process directly.
Mod System documentation - Learn how to create mods for Daggerfall Unity.
Modder Discussion - General help and discussion for the mod system.
Github Issues - Submit a bug report for the game, including the mod system.

User avatar
King of Worms
Posts: 3945
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow (CZ)
Contact:

Re: Help us make VIO and DREAM actually compatible

Post by King of Worms »

Have you tried the solutions mentioned here Kamer?

User avatar
Kamer
Posts: 548
Joined: Mon Mar 05, 2018 9:26 pm

Re: Help us make VIO and DREAM actually compatible

Post by Kamer »

King of Worms wrote: Thu Jan 07, 2021 5:35 pm Have you tried the solutions mentioned here Kamer?
I think what I'm looking for is this:
TextureExistsAmongLooseFiles(Int32, Int32, Int32, TextureMap)

Problem is, it always returns false. It doesn't detect dreams texture replacement. I'm thinking this is because, as the name suggests, it only looks in loose files. Since Dreams is a DFMOD, it makes it obsolete in detecting.

User avatar
XJDHDR
Posts: 177
Joined: Thu Jan 10, 2019 5:15 pm
Location: New Zealand
Contact:

Re: Help us make VIO and DREAM actually compatible

Post by XJDHDR »

From what I can see, it does indeed only look for loose file textures:

Code: Select all

static readonly string texturesPath = Path.Combine(Application.streamingAssetsPath, "Textures");
public static bool TextureExistsAmongLooseFiles(int archive, int record, int frame = 0, TextureMap textureMap = TextureMap.Albedo)
{
    return DaggerfallUnity.Settings.AssetInjection
        && File.Exists(Path.Combine(texturesPath, GetName(archive, record, frame, textureMap) + extension));
}
Edit: I would say try follow TheLacus' advice about using TryGetAsset() to see if the textures exist. That is what TryImportTexture() uses internally to check for and retrieve dfmod textures.

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

Re: Help us make VIO and DREAM actually compatible

Post by l3lessed »

This is correct. When the mod is built, the assets will be bundled into it. You then need to use the getasset object from the loaded mod, here dream mod, and then setup a null check to stop errors and find non-existence textures.

If not null, then load it instead of the default. If null, then use your current default load method for said texture.

You're trying to load loose files from a directory, instead of checking the mod and then loading it.

You can check my Github and go to ambidexteritymanager.cs under the ambidexterity mod. You can see how I use the get asset object to load my packed particle prefab and inject it into the engine. Check the start routine and properties to see how it is executed code wise.

Lastly, your original getchild method is pretty cpu/script wasteful. You are telling it to scan every object loaded into the engine, including non-npc objects, to find the necessary object to swap the texture for. I recommend using the methods provided by the lucas, so it doesn't start bogging down script loads when players add tons of stuff to their build.
My Beth Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

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

Post Reply