Page 2 of 3

Re: Updating lowres NPC sprites. Wrong palette?

Posted: Wed Sep 29, 2021 10:22 pm
by sayber1
But as I showed in my post in Help&Support even vanilla sprites straight out of Daggerfall IMG loaded through StreamingAssets become distorted.

Re: Updating lowres NPC sprites. Wrong palette?

Posted: Wed Sep 29, 2021 10:31 pm
by bearhead
Based on what Interkarma wrote, it does appear that scaling up an image (say at least x6) makes the artefacts basically unnoticeable. If you have photoshop you can change an image's color mode to "indexing color" and scale it up without blurring.

Even though the image will have rather large dimensions, the file size shouldn't be too bad, since most textures are going to have less than 100 colors or so.

Maybe there is a more elegant solution, but at least this is a quick and dirty work-around.

Also with regards to the sky images, I was only editing the night sky images - which are IMG files. I believe the actual SKY files cannot be edited at this time.

Re: Updating lowres NPC sprites. Wrong palette?

Posted: Wed Sep 29, 2021 10:40 pm
by Interkarma
Hmm, the size of those input images are scaled completely off. 184_18 has a source image size in gamedata of 43x78 and your image is 66x127. That's an X-scale of 1.534 and a Y-scale of 1.628. How are you exporting source images from the game - are you using Daggerfall Imaging or something else?

The replacement image must be either the same size or the same multiple in both axes. I also strongly recommend using POW2 multipliers. For example, 43x78 scales cleanly to 86x156 (2x) or 172x312 (4x). I'm not sure how you ended up with the dimensions you have, they don't match the source image in game data and aren't a clean scale at all.

That's going to cause some weird problems to start with. Images must have the same ratio in both dimensions for DFU to work with, or it's not going to scale into the screen space properly. Same deal when it comes to UI images, so that might be why you're having troubles there also.

Let's focus on getting the texture size correct first, then we start unpacking any other issues from there.

Re: Updating lowres NPC sprites. Wrong palette?

Posted: Wed Sep 29, 2021 10:51 pm
by sayber1
Yeah, the scale is different, because I wasn't sure about about relation between 184 and higher res textures and it all began as a quick proof concept. I've already seen the problem, but before I've started dealing with it, another(this thread) arose.

As streaching and scale difference seemed like a lesser and more clear problem, I decided to focus on the artifact issue first. Again, even the original textures become messed up, so I don't think those two are connected.

EDIT:
And yes, I am using Daggerfall IMG to export files, I just used a sprite from 182 as a template for initial test, because the most high rez sprites are at this resolution.

Re: Updating lowres NPC sprites. Wrong palette?

Posted: Wed Sep 29, 2021 11:09 pm
by Interkarma
I will not be able to provide further support in that case, I'm sorry. The starting condition is that test images must be exported to PNG from Daggerfall Imaging 2 and have the correct scale factor in all dimensions. You can't just feed in any old image size and expect it to work. At the very minimum in this case, you'll need to provide an XML file to correct scale of your images alongside the PNGs, as they're using different scales than the game is using. This just isn't a good starting point, not even for a proof of concept.

Others have been successfully modding sprite and UI images into DFU for years now. It might be worth comparing notes with them and going from there.

Good luck!

Re: Updating lowres NPC sprites. Wrong palette?

Posted: Wed Sep 29, 2021 11:14 pm
by sayber1
As i've said i don't think this is the issue here.
These attached screenshots show the ORIGINAL texture ripped by Daggerfall IMG and imported to the game via StreamingAssets without any edits

Re: Updating lowres NPC sprites. Wrong palette?

Posted: Wed Sep 29, 2021 11:55 pm
by Interkarma
If "Daggerfall IMG" is Daggerfall Imaging 2, then that's fine.

Just to rule out mipmapping once and for all, a couple things to confirm:
  • Is your quality level set to "Beautiful"? This is "QualityLevel = 5" in settings.ini.
  • Are you using retro rendering in these screens? If so do you have "UseMipMapsInRetroMode = False" still configured in settings.ini?
I'll take a closer look when I can, at work right now. :)

Edit: And if not mipmaps, I wonder if asset importer is automatically using some texture compression. This will cause the kinds of "chunking" artifacts we see here. This would be mitigated by upscaling asset by at least 8x. I'll need to step through code later to confirm.

Re: Updating lowres NPC sprites. Wrong palette?

Posted: Thu Sep 30, 2021 12:15 am
by sayber1
I'm not using retro rendering in these, while I do enable mipmaps for retro rendering for smoother far plane.

My quality preset was set to Fantastic, the last preset in menu, I believe.

And yes, Daggerfall IMG is Daggerfall Imaging, I'm just too lazy to write it properly.

Re: Updating lowres NPC sprites. Wrong palette?

Posted: Thu Sep 30, 2021 12:17 am
by Interkarma
Try setting "CompressModdedTextures = False" in settings.ini and let me know if that makes a difference. This is enabled by default as injected assets are usually much higher resolution. Compression won't play nice with retro-sized textures however.

Re: Updating lowres NPC sprites. Wrong palette?

Posted: Thu Sep 30, 2021 1:40 am
by Interkarma
I can now confirm this is caused by texture compression artifacts. This will happen whenever "CompressModdedTextures = True" is configured in settings.ini and behaviour can be disabled there in current builds.

I've also submitted a potential fix to never use compressed textures for retro-sized texture replacement. Retro-sized is defined as having a dimension under 256 pixels in both width and height. This will preserve pixel art and never use compression unless replacement texture is larger than 256 pixels in any dimension. I've provided more details and comparison screenshots in below commit.

https://github.com/Interkarma/daggerfal ... 05969790cc

I'm not 100% happy with this change, as it requires reloading texture. We'll see where it goes after the other devs have provided their feedback. :)