Page 1 of 2

These 3 objects do not accept texture replacements

Posted: Mon Nov 15, 2021 12:08 pm
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 4010 times
dungeon.jpg
dungeon.jpg (458.89 KiB) Viewed 4010 times
city.jpg
city.jpg (660.34 KiB) Viewed 4010 times

Re: These 3 objects do not accept texture replacements

Posted: Mon Dec 13, 2021 8:12 am
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 3901 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?

Re: These 3 objects do not accept texture replacements

Posted: Mon Dec 13, 2021 6:55 pm
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

Re: These 3 objects do not accept texture replacements

Posted: Mon Dec 13, 2021 9:14 pm
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.

Re: These 3 objects do not accept texture replacements

Posted: Mon Dec 13, 2021 9:33 pm
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 😷

Re: These 3 objects do not accept texture replacements

Posted: Mon Dec 13, 2021 9:47 pm
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.

Re: These 3 objects do not accept texture replacements

Posted: Tue Dec 14, 2021 9:50 pm
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 👍

Re: These 3 objects do not accept texture replacements

Posted: Fri Jul 08, 2022 6:33 am
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.

Re: These 3 objects do not accept texture replacements

Posted: Fri Jul 08, 2022 11:25 am
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

Re: These 3 objects do not accept texture replacements

Posted: Fri Jul 08, 2022 2:53 pm
by Kab the Bird Ranger
Not the only issue we have with that array for terrain textures: https://github.com/Interkarma/daggerfal ... ssues/2310