Mesh Replacments can't use texture from the original game

Post here if you need help getting started with Daggerfall Unity or just want to clarify a potential bug. Questions about playing or modding classic Daggerfall should be posted to Community.
Post Reply
User avatar
Uncanny_Valley
Posts: 221
Joined: Mon Mar 23, 2015 5:47 pm

Mesh Replacments can't use texture from the original game

Post by Uncanny_Valley »

Steps to reproduce
1. Create model
2. Create prefab from model
3. Create material with names of orignal game "arhive"-"record"_"frame"
4. Assign material to prefab
5. Build mod with prefab

Result: The model will be replaced in the game with the prefab but the material will remain empty (default white/grey).

Possible issues

In MeshReplacment, FinaliseMaterials(), line 403, you have ...

Code: Select all

 
 if (TextureReplacement.IsDaggerfallTexture(materials[i].name, out archive, out record)
                            && TextureReplacement.TextureExistsAmongLooseFiles(archive, record, 0))
                            
if you remove the second check and end up with...

Code: Select all

 
 if (TextureReplacement.IsDaggerfallTexture(materials[i].name, out archive, out record))
 
Then it works. The model replacement will show up in the game with the texture from the original game.

I'm 99 % that the check for loose file shouldn't be there. :D

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

Re: Mesh Replacments can't use texture from the original game

Post by TheLacus »

Nowadays the best way to handle this is with the RuntimeMaterials component. You can add it to a prefab with missing materials and link material index to texture archive/record from the inspector. Materials are seeked and assigned at runtime, and preserved if gameobject is cloned.

Optionally you can enable climate/season modifier or dungeon texture table.

I added replacement based on name a lot of time ago but i don't know if anyone actually used it. It was limited in scope and required to create one dummy material for each classic texture, which isn't convenient. I'd suggest to use the new component instead. :)

Post Reply