These 3 objects do not accept texture replacements

Moderators will move topics here from Help & Support once an issue has been confirmed and enough information provided to reproduce.
User avatar
King of Worms
Posts: 4752
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow (CZ)
Contact:

These 3 objects do not accept texture replacements

Post by King of Worms »

The thing they have in common is that the texture replacement which is not working is a terrain texture placed usually at the top. It applies to all climate zones across the whole game. Is there anything we can do about it please?
Spoiler!
temple.jpg
temple.jpg (443.21 KiB) Viewed 3907 times
dungeon.jpg
dungeon.jpg (458.89 KiB) Viewed 3907 times
city.jpg
city.jpg (660.34 KiB) Viewed 3907 times

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

Re: These 3 objects do not accept texture replacements

Post by XJDHDR »

I just tested this using a custom model that uses Runtime Materials to assign textures to it and it had the same problem. The part of the model which uses the grass terrain texture was still using the vanilla texture instead of DREAM's version:
Spoiler!
Model test.jpg
Model test.jpg (155.48 KiB) Viewed 3798 times

I have attached the model I tested here:
43601.zip
(3.96 KiB) Downloaded 107 times

KOW: Just want to confirm something. Does DREAM 2020-R3 have a modded copy of texture 302_2-0 in it?

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

Re: These 3 objects do not accept texture replacements

Post by King of Worms »

Hi! :) Thanks for looking at the issue.

Yes, DREAM has all the modded terrain tiles included in it, even the 302 etc
Problem with these objects is, that they are the only ones ingame, which are textured using terrain textures (archives 002, 102, 103 etc)

So the issues lies there somewhere, in the terrain shader or stuff like that, I have no idea precisely ofc

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

Re: These 3 objects do not accept texture replacements

Post by XJDHDR »

I just looked through the code for DFU as far as how textures are assigned to a model. The Runtime Materials script figures out which texture to assign by calling the GetMaterial method in MaterialReader.cs (I think the logic for assigning textures for vanilla model calls the same method). When it comes to DFMODs, the TryImportMaterial method is called which, in turn, uses the TryGetAsset method to ask Unity itself if any DFMOD contains a material with the given name.

I don't see any special logic for handling terrain textures. As far as I can tell, as long as you have a material named exactly "302_2-0" in your mod, the material assignment code should be able to find and use it.

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

Re: These 3 objects do not accept texture replacements

Post by King of Worms »

Strange. Thing is, it does not assign the texture. Not only 302 but all the alternatives in different biomes :/ I think Interkarma should know whats up. I have no idea.. I also have a fever and chills 😷

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

Re: These 3 objects do not accept texture replacements

Post by XJDHDR »

Hope you get well soon.

There is one other thing I can think of. Before GetMaterial calls the TryImportMaterial method, it checks if the MaterialReader class has a copy of the material already stored in it's cache before trying to find it in the mods or data files. Maybe it's possible that the game put a copy of the vanilla texture in that cache somehow instead of the modded version? I'll see what I can do once I have some more time.

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

Re: These 3 objects do not accept texture replacements

Post by King of Worms »

Thank you, Im really ill, the oldskool version before we had this c19 stuff, its kicking pretty strong :/

Anyway, thanks for looking into it, you might be up on something with that cache 👍

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: These 3 objects do not accept texture replacements

Post by Interkarma »

I've had a look at this one. Summary of problem is that replacement terrain textures are loaded early and into a texture array. The individual terrain texture replacements aren't left available for standalone objects like these, so they end up with the default texture. Only the part of these models using a terrain texture is affected, the other parts work as expected.

I don't have a solution right now. I'll try to find a low-impact way of solving that doesn't break anything else.

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

Re: These 3 objects do not accept texture replacements

Post by King of Worms »

Hi Interkarma, thanks for looking into the issue. Fingers crossed it gets solved at some point, yet I understand its not a high priority atm

User avatar
Kab the Bird Ranger
Posts: 123
Joined: Tue Feb 23, 2021 12:30 am

Re: These 3 objects do not accept texture replacements

Post by Kab the Bird Ranger »

Not the only issue we have with that array for terrain textures: https://github.com/Interkarma/daggerfal ... ssues/2310

Post Reply