Are Loose Texture File Replacements Supposed To Inherit Aspects Of Original Texture?

Discuss modding questions and implementation details.
User avatar
Magicono43
Posts: 1139
Joined: Tue Nov 06, 2018 7:06 am

Are Loose Texture File Replacements Supposed To Inherit Aspects Of Original Texture?

Post by Magicono43 »

While adding items and specifically their textures to my current project, I noticed something that I had not before. It seems that textures that are replacing already existing textures seem to inherit the original textures attributes, such as the set size parameters, instead of setting those parameters to the replacing textures size specifications.

For example, the Sapphire item has a size of 7 by 9 pixels, but the texture i'm replacing the original Sapphire texture with is 22 by 32 pixels in size. However, when you actually go in-game you will notice that the texture has been replaced, but the size attributes (and presumably others) are still the same as the old texture, so it renders smaller than one would expect it to.

I seem to have confirmed this using the debug function of Visual Studio, and even though the replacement texture is loaded, it still keeps the old textures parameters, and i'm really not sure why or how to change this. I tried to make a .xml file for said replacement texture as well and include that, but it seemed to have no effect, unlike how it would for something being put on the paper-doll such as a newly added armor or weapon texture.

From my observation I doubt this is the intended behavior, but I don't think I have heard anyone mention or talk about this, is this known or am I the first to bring this up? Thanks.

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

Re: Are Loose Texture File Replacements Supposed To Inherit Aspects Of Original Texture?

Post by King of Worms »

Well if original dimension is 10x10 and you create a HD version of let say 100x100 than you definitely do NOT want the ingame result to be 10x the size of original. You want same size but with 10x the pixel density.

Not sure I understand you corectly tho.

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: Are Loose Texture File Replacements Supposed To Inherit Aspects Of Original Texture?

Post by Hazelnut »

Seems like intended behaviour to me, unless you have an xml file with the new size/position data for your image it will use the vanilla data. This is convenient for replacements of the same resolution and size.

So are you using xml files with these images?
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Magicono43
Posts: 1139
Joined: Tue Nov 06, 2018 7:06 am

Re: Are Loose Texture File Replacements Supposed To Inherit Aspects Of Original Texture?

Post by Magicono43 »

Hazelnut wrote: Fri Feb 12, 2021 10:48 am Seems like intended behaviour to me, unless you have an xml file with the new size/position data for your image it will use the vanilla data. This is convenient for replacements of the same resolution and size.

So are you using xml files with these images?
"I tried to make a .xml file for said replacement texture as well and include that, but it seemed to have no effect, unlike how it would for something being put on the paper-doll such as a newly added armor or weapon texture."

I tried to add an .xml file with the replacement texture but it did not appear to change anything with the inventory icons, nor do I think it changed any of the "imagedata" properties in the section of code that I was looking at, it still inherited the original image size properties. This was also appeared to be the case with the completely custom textures that had no original texture properties to pull from. So I don't know if the paper-doll rendered image gets the imagedata in a different way than the inventory icon images? That seems to be the case at least from messing around with the wearable jewelry stuff.

User avatar
Magicono43
Posts: 1139
Joined: Tue Nov 06, 2018 7:06 am

Re: Are Loose Texture File Replacements Supposed To Inherit Aspects Of Original Texture?

Post by Magicono43 »

Maybe this image will help explain.
Capture2.JPG
Capture2.JPG (126.17 KiB) Viewed 1080 times

The blue gem on the right is the exact same texture properties as the red one on the left, that being they are both 22 by 32 in size, just their color is different.

But the blue one is replacing the "254_2-0" texture for the sapphire, which as a size of 7 by 9. The red one is an entirely custom texture for an item in "4003_0-0" and as you can see, I would expect them both to have their native 22 by 32 texture sizes on the inventory screen, but that's not the case, the replacement inherits the size properties of the original texture. Also to note that giving either of these .xml files did not seem to change anything about them in the inventory icons.

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

Re: Are Loose Texture File Replacements Supposed To Inherit Aspects Of Original Texture?

Post by TheLacus »

This is intended behaviour, it ensures custom textures are applied correctly on UI.
Magicono43 wrote: Fri Feb 12, 2021 12:26 pm The red one is an entirely custom texture for an item in "4003_0-0"
How do you provide this custom texture? If a mod affects inventory window, it's up to the mod to apply changes consistently.

User avatar
Magicono43
Posts: 1139
Joined: Tue Nov 06, 2018 7:06 am

Re: Are Loose Texture File Replacements Supposed To Inherit Aspects Of Original Texture?

Post by Magicono43 »

TheLacus wrote: Fri Feb 12, 2021 1:11 pm This is intended behaviour, it ensures custom textures are applied correctly on UI.
Magicono43 wrote: Fri Feb 12, 2021 12:26 pm The red one is an entirely custom texture for an item in "4003_0-0"
How do you provide this custom texture? If a mod affects inventory window, it's up to the mod to apply changes consistently.
I put the custom texture in the "streaming assets" folder as you would when replacing vanilla textures. The difference is that i'm directly adding in the new items item details in the main "itemtemplates" file. So i'm guessing that's the problem then? There is simply nothing in the code that is able to read what i'm giving it? That's what I was sort of thinking the problem was, but I was not really sure.

User avatar
Magicono43
Posts: 1139
Joined: Tue Nov 06, 2018 7:06 am

Re: Are Loose Texture File Replacements Supposed To Inherit Aspects Of Original Texture?

Post by Magicono43 »

Alright, I think I tracked the problem, and also why xml files don't seem to effect the inventory icons like the paper-doll rendered items. Simply put and probably obvious to some, the part of the code that renders the inventory icons does not have any code that actually checks or reads from any xml files, unlike the paper-doll renderer, which directly references the "XMLManager" when it draws the paper-doll items and such. So i'll have to add something similar to this for the inventory icon rendering and see if it works as I expect.

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

Re: Are Loose Texture File Replacements Supposed To Inherit Aspects Of Original Texture?

Post by l3lessed »

Glad found the solution. Yes, check the code and see if the import texture object adjusts the rect sizes automatically based on custom texture sizes being imported. If not, you will always have to use mod code to inject the custom rect properties to resize said texture to fit the original UI aspect ratio and rendering.
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
Magicono43
Posts: 1139
Joined: Tue Nov 06, 2018 7:06 am

Re: Are Loose Texture File Replacements Supposed To Inherit Aspects Of Original Texture?

Post by Magicono43 »

Ok, I was able to get what I wanted to work with fully custom textures, so now the inventory icons will render the custom textures based on the parameters set by any corresponding xml files included with said texture, similar to the how the paper-doll renderer handles these things, just no scale or offset values, just width and height. I had to do a bit of hacky method adding and slight altering of some other methods to get this to work, but it does at least.
Custom Item That Is Natively 22 by 32, changed to 7 by 9 instead with xml file.
Custom Item That Is Natively 22 by 32, changed to 7 by 9 instead with xml file.
Capture4.JPG (89.54 KiB) Viewed 1012 times
Example Of Simple xml file with parameters being used
Example Of Simple xml file with parameters being used
Capture5.JPG (12.88 KiB) Viewed 1012 times
Main Method Added To XMLManager.cs To Read XML Files For Inventory Icon Rendering
Main Method Added To XMLManager.cs To Read XML Files For Inventory Icon Rendering
Capture6.JPG (21.64 KiB) Viewed 1012 times

I still have to do this as well so that the same can be done with textures that are intending to replace an already existing texture, not as important for my purposes, but will probably add that function just for extra control of item icons that I may add later on.

Post Reply