Duke4.net Forums: Scaling sprites by combining waifu2x and xBRZ output - Duke4.net Forums

Jump to content

Hide message Show message
Welcome to the Duke4.net Forums!

Register an account now to get access to all board features. After you've registered and logged in, you'll be able to create topics, post replies, send and receive private messages, disable the viewing of ads and more!

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Scaling sprites by combining waifu2x and xBRZ output

User is offline   MrFlibble 

  • 569

#31

View PostMrFlibble, on 04 October 2018 - 10:11 AM, said:

It's also worth noting that I tried scaling up Doom sprites, with the results broadly similar to what another user achieved with NVIDIA GameWorks Super Resolution neural network scaling (I doubt that one was trained on anime images).

Further on this, I tried scaling up some Doom textures and I have to say there's a noticeable difference, namely, waifu2x blurs colours a lot, especially at low contrast arear whereas the NVIDIA network keeps the image sharp, even though there's some notable ringing sometimes.
1

User is offline   MrFlibble 

  • 569

#32

Alrighty, following some feedback from the discussion in the NVIDIA GameWorks SuperResolution thread I'm trying to figure out how to counter the blur produced by waifu2x (other than attempting to retrain it using different images, I'm feeling ready to try that out yet).

The thing is that the NVIDIA nework is indeed capable of creating images that appear more or less redrawn at higher resolution by hand (check out a couple of comparisons I posted here), while waifu2x, while creating smooth curves, produces a generally blurry image. Adding noise only partially addresses this issue.

There are filter called Rock in IrfanView which creates a kinda-sorta emboss effect, accentuating edges of areas with different colours. I quickly ran this with a previous monster test:
Spoiler

The image was scaled up 4x with waifu2x and then the Rock filter was applied at 4x. I scaled it back down to 2x with Sinc3. Ignore the greenish halo at some of the sprites' edges, this was a quick test without the extra steps to remove those.

I'm not completely happy with the result though. Is there another way to get rid of the blur towards a pixel art-esque sharpening effect? Simply sharpening the image or applying unsharp mask filters doesn't quite cut it. A simple conversion of the resized image to the 8-bit palette also contributes very little to removing the blur.
0

User is offline   Phredreeke 

  • 222

#33

The green lines are caused by the surrounding pink background. To get around that I think you would need to upscale only the luma channel and use something else for color. Alternatively you could expand the image onto the background and then apply the original mask later.
1

User is offline   MrFlibble 

  • 569

#34

View PostPhredreeke, on 16 October 2018 - 11:23 AM, said:

Alternatively you could expand the image onto the background and then apply the original mask later.

Yes, this is about how I do this. I was too lazy to process the image above this way for the test purposes.

Anyway, concerning the Duke3D sprites, using the rock filter as described above doesn't seem to positively contribute to image quality. In fact the result is rather similar to what the original unsmoothed image gets when scaled up.

Another thing to note is that the results of waifu2x scaling with xBRZ smoothing on the sprites' edges do not appear much different from what you get if you plain scale up the same shape in xBRZ:
Spoiler

(waifu2x processing above, xBRZ below)

This is a bit disappointing since I was kinda hoping that the smoothed waifu2x would get better results with various curves and straight lines at odd angles, but it only seems to work with images baked into a background.
0

User is offline   Phredreeke 

  • 222

#35

still would like to see it in-game :P
0

User is online   MusicallyInspired 

  • 3,093

#36

Worst-case scenario you have to do a bit of pixel editing on the frames. It's a high order to get supreme results from mere filters alone anyway.

Roland SC-55 Music Packs
new! Heretic SC-55 Music Pack in FLAC, OGG, & MP3 with metadata loop tags (12/12/18)
Duke3D, Doom, Heretic, Descent, Hocus Pocus, and more...
Legacy of Grabbag Metal Medley
0

User is offline   MrFlibble 

  • 569

#37

 MrFlibble, on 04 October 2018 - 10:11 AM, said:

I tried scaling up Doom sprites, with the results broadly similar to what another user achieved with NVIDIA GameWorks Super Resolution neural network scaling (I doubt that one was trained on anime images).

 MrFlibble, on 09 October 2018 - 09:07 AM, said:

Further on this, I tried scaling up some Doom textures and I have to say there's a noticeable difference, namely, waifu2x blurs colours a lot, especially at low contrast arear whereas the NVIDIA network keeps the image sharp, even though there's some notable ringing sometimes.

hidfan who posted the original Doom scaling results explained that what he has is not a raw result of using NVIDIA GameWorks but a combination of several iterations created by different methods.

I just checked hidfan's sources, and apparently the results of simple NVIDIA texture scaling are pretty bland. The illusion of extra pixel detail apparently stems from the NVIDIA PhotoHallucination process, which to me looks some kind of artistic filter from Photoshop when applied to textures (it is my understanding that photohallucination is actually intended to add imaginary detail to photographs when upscaling, similar to what Let's Enhance offers).

By which I mean to say that it might be quite possible to achieve similar results without relying on NVIDIA software altogether.

In the meantime I used a slightly different approach and got some sprites that are arguably more similar to hidfan's results.
0

User is offline   leilei 

  • 483

#38

 Hendricks266, on 03 October 2018 - 04:23 PM, said:

I presume waifu2x has been trained on anime-like drawings, and I suspect this is why your images look like oil paintings. I would bet the result would be better if you trained the neural network with a custom data set.

Yes it's trained on manga illustrations. There's also a model trained on photographs but it seems to look too much like Lanczos scaling to be worth it. There are also denoising models involved which will kill off those details as well.

the whole "it's made-for-anime" is generally why i've never encouraged Waifu2x for sprites other than a sarcastic joke. It is designed for thin anti-aliased linework for illustrations around 500x500+ resolutions. If it makes anything else look good, it's just a lucky coincidence. Waifu2x is not a silver bullet.

Posted Image

This post has been edited by leilei: 20 October 2018 - 06:05 PM

1

User is offline   MrFlibble 

  • 569

#39

Well, the pre-rendered sprites look pretty decent at 2x. Stuff like this is pretty decent. Monster sprite upscale for Blood is a thing. Whether this is an intended effect or coincidence is largely irrelevant as long as such functionality has practical applications.

The thing is, to my knowledge there's no better alternative at this moment, and at any rate it is interesting to explore what can be done with existing tools. hidfan did some pretty cool stuff with the Doom textures, but they, too, are not a result of simply feeding original art to the NVIDIA neural networks and getting the output.
0

User is offline   MrFlibble 

  • 569

#40

Phredreeke gave me a good idea to experiment with blending layers, here's one result (4x scaling):
Posted Image
This was done by blending three layers:
  • sprites on black background, softened as described here, processed with waifu2x in Y-channel mode (2 passes, TTA4)
  • sprites on white background, also softened and processed with waifu2x in RBG mode (2 passes, TTA4)
  • sprites on bright green background from the Duke3D palette, scaled to 4x with xBRZ

I used the Blend [median] function in GIMP's G'MIC plugin to combine these. The black and white backgrounds cancel each other, leaving the green background from the third layer unaltered.

I then converted the result to the Duke3D palette using mtPaint with the Dithered (effect) dithering type. To achieve best results I set Colour space to RGB (the default is sRGB), Reduce colour bleed to Strongly, Error propagation at 85% and Selective error propagation set to Separate/Sum.

I then removed the green background colour from the image.

Running waifu2x with two passes results in a pronounced sharpening effect that accentuates detail, but also contributes to the emergence of black outlines on the sprite edges. I'm not sure I'm 100% happy with the result, but mind this is still WIP. At least this is a workable model for getting sprite edges processed properly with waifu2x without the need for previous combination methods.

Here's the same stuff as above with the sprite outline cropped by 1 pixel (I'm not sure this is a good solution but at least worth a try):
Posted Image
2

User is offline   Commando Nukem 

  • Judge Mental
  • 2,396

#41

A lot of these look quite good. I think if there was someone interested in actually going over these with a more fine hand once the process was done, and actually give them some more detail by hand it would be perfect. Some of the detail just doesn't come up much, but other parts almost look like the ol' 640x480 renders of the original models, which is pretty cool.

Has this been tried on the HUD weapons?

OPEN MAW PRODUCTIONS
Facebook Youtube and Twitter
2

User is offline   Phredreeke 

  • 222

#42

I think a 2x scale is the sweet spot as of now TBH. I do like the idea of having an artist give a final pass adding detail that didn't come through on the upscale.

The problem of how to deal with palswaps/PLUs still remain. The way I dealt with it for Blood results in duplicating sprites for each colour variant. At least Duke3D doesn't use them to as high extent.
2

User is offline   MrFlibble 

  • 569

#43

View PostCommando Nukem, on 22 November 2018 - 06:52 AM, said:

Has this been tried on the HUD weapons?

Not yet.

View PostPhredreeke, on 22 November 2018 - 07:37 AM, said:

I think a 2x scale is the sweet spot as of now TBH. I do like the idea of having an artist give a final pass adding detail that didn't come through on the upscale.

I agree with this.

On a side not, it turns out that someone else also came up with the xBRZ softening method:
https://github.com/n...mment-341915147

That discussion also reveals that if you do both upscaling and noise reduction you can get a pretty good result with the outlines at the cost of losing some detail, but this might actually be a good thing considering that 8-bit graphics have a lot of sharp contrast in neighbouring colours.
0

User is offline   MrFlibble 

  • 569

#44

In the meantime I gave a try at scaling pre-rendered images with noise reduction on, as suggested in the discussion at GitHub. Here's what I got (ignore the text part):
Posted Image
This is a blend of:
  • original 320x200 image (no softening or other edits) scaled in Y-channel mode with noise reduction to 4x, TTA2, noise level 1
  • same as above but with two passes
  • original 320x200 image scaled to 4x using xBR (not xBRZ) from the ScalerTest utility

The result was downscaled to 640x480 using Sinc3 in GIMP, then converted to the original palette in mtPaint with limited Stucki dithering. I only used the same colours as on the original image, not the full range of the palette (accomplished in mtPaint by first saving the 320x200 original as a 24 bit RGB image, then converting to indexed as exact match).

For comparison, here's the same image scaled to 4x by nearest neighbour and xBRZ, then converted to 640x480 8-bit image using the same steps as above:
Spoiler

0

User is offline   MrFlibble 

  • 569

#45

Can't edit my post already, so double posting (sorry).

Here's the loading screen and one frame of the Earth episodes tally screen animation. This time I used the RGB scaled image (with noise reduction) as the third layer instead of an xBR upscale, otherwise the steps are as described above. I also tried out two palette conversion modes (for parameters see this post): Stucki and DIthered (effect), both via mtPaint. I kinda like the Dithered version more.

Loading screen (dithered):
Posted Image

Stucki:
Posted Image

Tally screen (dithered):
Posted Image

Stucki:
Posted Image


This post has been edited by MrFlibble: 27 November 2018 - 06:36 AM

1

Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks are property of their respective owners. Instead of reading this text, you could be playing Ion Maiden! ;) © 2018 Voidpoint, LLC

Enter your sign in name and password


Sign in options