AI Upscaled Textures

Show off your mod creations or just a work in progress.
Post Reply
User avatar
MrFlibble
Posts: 411
Joined: Sat Jan 27, 2018 10:43 am

Re: AI Upscaled Textures

Post by MrFlibble »

MasonFace wrote: Sat Mar 16, 2019 5:54 pm Am I to understand that you used the same xBR + Gaussian Blur method as in the first post and only changed the alpha value for the ESRGAN interpolation?
Yes, I used the Gaussian blur at 2 pixel radius for everything in the previous posts, but more on this below.
MasonFace wrote: Sat Mar 16, 2019 5:54 pm Also, what is the purpose of dropping the color depth back down to the original DF palette? Is that just an artistic touch or does it have a functional purpose?
This is to remove the blue background. With the image converted to the original colours, it detaches almost seamlessly.
MasonFace wrote: Sat Mar 16, 2019 5:54 pm One last thing. How are you able to use GIMP's select color to restore the alpha around the subjects' outlines? When I upscale using AI with a solid colored background, the background ends up having so much noise in it that I can't select by color and get a good outline.
This is exactly what the 8-bit depth conversion is for. I don't need to adjust anything, I just click on the dark blue area and delete it.

I use mtPaint to convert ESRGAN output to the original palette. Make sure you select no dithering and in the options, set colour space to RGB (default is sRGB), I noticed that it increases accuracy.
MasonFace wrote: Sat Mar 16, 2019 5:54 pm The only problem I'm having is that if the sprite has any pixels on them that are close to being blue, it will mask that, too. I was just wondering if converting to the original DF palette helps this. If so, do you know how to change the palette in GIMP? I've tried using "Palette Map," but it doesn't come out looking right at all.
Again, with the 8-bit palette, GIMP doesn't take any liberties with colours and only selects the colour you're pointing at.

Now here's another thing. I noticed that while ESRGAN/Manga interpolation at 0.2 gives generally more preferable results, the interpolation at 0.5 actually seems to do a bit better job with facial features, yet sharpens the image too much. So I decided to compensate that with increased blur.

I didn't show you the initial results with Gaussian blur at the radius of 3, they're too blurry. But what if we set the radius to 2.5? Here are the results:
Image
I think the faces here look more like faces, including the witch oven guard, the priests and the mage guild member. The downside is that the straight lines at odd angles are more jaggy with this method compared to alpha 0.2 (e.g. check the gold trim of the cloak of the guy second from the left in the bottom row).

For a test, I also blended the 2,5 pixel radius blur with the alpha 0.2 result from my previous post:
Image

IMPORTANT: Note that in all cases here, I've used xBR to scale up the original image before applying the blur, not xBRZ.

User avatar
MasonFace
Posts: 543
Joined: Tue Nov 27, 2018 7:28 pm
Location: Tennessee, USA
Contact:

Re: AI Upscaled Textures

Post by MasonFace »

Thanks MrFlibble. Excellent discovery and great documentation!

I think I may give this method a try and see how well it fairs with the MOBs. However, unless MtPaint has an API that allows for batching, I don't think I will be pursuing matching the DF palette and creating the masking layers. I will wait for Phredreeke's response for the masks.

I'll keep you posted on the results.

phredreeke
Posts: 71
Joined: Mon Mar 11, 2019 9:13 am

Re: AI Upscaled Textures

Post by phredreeke »

MasonFace wrote: Sat Mar 16, 2019 5:54 pm @Phredreeke:

Having said that, my masking method is really showing its weaknesses. :?

I have all the sprites (there's a LOT of them!) consolidated into one folder with the proper naming format. Would you be so kind as to generate the masking layer using your refined technique? :P

Consolidated Sprites:
https://drive.google.com/open?id=1IqPIg ... oVf-DnU0qo
Oh boy this is gonna take some time 👀

Meanwhile, here's a few sprites from an upscale I did last week

Image

User avatar
MasonFace
Posts: 543
Joined: Tue Nov 27, 2018 7:28 pm
Location: Tennessee, USA
Contact:

Re: AI Upscaled Textures

Post by MasonFace »

Witchhaven! That game was HARD!!! Not sure I ever got past the third stage. I think my problem was that I played it like as if it was Duke3D and never really adjusted my play style. I need to give that game another chance. Anyhow, very nice looking results on your upscales! :D
Oh boy this is gonna take some time
Yeah, that's why I was hoping I could solve the masking issue on my own, so I wouldn't have to take too much of your time. Unfortunately, my method breaks down in too many cases to rely on it for batching, and I don't think GIMP has the anti-aliasing and scaling models that PSP has, so I can't replicate your method. :cry:

Anyhow, I really appreciate your help on this! Not sure how long it takes your batching script to process, but hopefully you can just let it run overnight.

phredreeke
Posts: 71
Joined: Mon Mar 11, 2019 9:13 am

Re: AI Upscaled Textures

Post by phredreeke »

Yeah, while time consuming (the first 2210 images took 97 minutes to process) it is automated (short of restarting the batch when PSP encounters an error with one of frames, happened on sprites 380-2-0 and 434-2-0)

My current project is Blood. Upscaling wrecked the faces on most of the frames so I've been working on patching together using other frames.
tile2845tg.png
tile2845tg.png (22.99 KiB) Viewed 2952 times
Anyway, hopefully the masks will be done processing by the end of the day. It's roughly 2/3rds done now.

phredreeke
Posts: 71
Joined: Mon Mar 11, 2019 9:13 am

Re: AI Upscaled Textures

Post by phredreeke »

After roughly 6 hours of processing here are the masks http://s000.tinyupload.com/index.php?fi ... 5540987780

User avatar
MrFlibble
Posts: 411
Joined: Sat Jan 27, 2018 10:43 am

Re: AI Upscaled Textures

Post by MrFlibble »

I just did a very small comparison of Phredreeke's scaling method and what I came up with. I took the priest sprite similar to the one on the preview image I ran tests with (second from the right, top row) and scaled it up:
  • left: the antialiased version from Phredreeke's pack with ESRGAN/Manga interpolation at alpha = 0.2
  • right: the xBR + Gaussian blur (radius 2 pixels) version against dark blue with an interpolation (alpha = 0.5) of two models: ESRGAN/Manga109 (0.5) and ESRGAN/Manga109 (0.2) - this gives roughly the same result as blending the results of scaling up with each model separately. I did not clean up residue pixels on the edges
  • centre: original sprite scaled up 4x using nearest neighbour method
Image Image Image
It is immediately obvious that Phredreeke's method gives a much smoother outline of the sprite, whereas the Gaussian blur method more or less preserves the "pixel staircase" leftovers from the low-res image when it comes to lines at odd angles, like the folds of the robe at the left hand and the back of the figure.

On the other hand, the Gaussian blur approach seems to have better preserved smaller features: the right ear is still fairly recognisable, the left cheekbone above the beard line is more pronounced and the eyes are more discernible. By contrast, the anti-aliased version turned the head into an almost completely round ball, with the eyes having become a single line.

It's not clear to me if some further pre-processing of the source images may help improve either result, or combining the strengths of either method shown above is only possible via manual editing.

phredreeke
Posts: 71
Joined: Mon Mar 11, 2019 9:13 am

Re: AI Upscaled Textures

Post by phredreeke »

That sprite wasn't included in the consolidated pack I processed. After finding it, it didn't fare much better with my updated mask script though. The top of the staff still misses some pixels and have sections of it "floating" in the air

phredreeke
Posts: 71
Joined: Mon Mar 11, 2019 9:13 am

Re: AI Upscaled Textures

Post by phredreeke »

I tweaked my script a bit. Now it preserves the shape of the top of the staff better. Of course, this may break other frames. It's questionable whether it'd be actually worth picking out the frames to specifically process rather than just editing the masks for those.
Attachments
181-2-1.png
181-2-1.png (1.88 KiB) Viewed 2898 times

User avatar
MrFlibble
Posts: 411
Joined: Sat Jan 27, 2018 10:43 am

Re: AI Upscaled Textures

Post by MrFlibble »

I think we're again facing the problem of big features vs. small details here. The hand-drawn low-res sprites have a lot of very small features, and both ESRGAN and your scripts tend to distort them. It's probably something that cannot be alleviated altogether without hand-editing the sprites.

What's more, this raises the question of what exactly we're trying to achieve with the whole neural upscale enterprise. The consensus with the Doom upscale when it was discussed was that the end result should be of higher resolution but retain the "pixel art" quality. Doom sprites, mostly just like Duke3D sprites, although produced using different techniques, have enough big features that are successfully enlarged by the neural networks with little distortion. However it seems that here the art style is different enough to present a problem.

If anything, ESRGAN produces a different art style for the sprites. I was playing around with possible ways of cleaning up the mask and thought that you can actually exaggerate that style a bit by applying Kuwahara-Nagao blur (mtPaint; 1 pixel radius with detail preservation):
Image
original sprite set:
Spoiler!
Image
This time I applied the GIMP antialias filter before scaling the image up with xBR, which resulted in a bit better faces (more noticeable with the guy on the bottom right; didn't help the guy on the top left at all though) while playing down some of the details. and contrasts. I used Gaussian blur at 2 pixel radius and the model was a 0.5 interpolation of two interpolated ESRGAN/Manga109 models (one at 0.5 and another at 0.3).

The faces are all distinctly different from their original counterparts. Thankfully at least some detail is preserved, if only in some distorted way, and you can still say that this is a face. The resulting drawing style and expression is completely different. The guy on the top left, well, nothing I did helped to improve his face. The clothes look mostly okay though. At least the images retain their hand-drawn look (to an extent) this way.

Post Reply