Strange behavior of the imported flats

Discuss modding questions and implementation details.
User avatar
King of Worms
Posts: 550
Joined: Mon Oct 17, 2016 11:18 pm
Location: Scourg Barrow
Contact:

Strange behavior of the imported flats

Post by King of Worms » Sun Feb 11, 2018 5:27 pm

Why do some remade character flats have white shimmering around them?
(pls check the 2nd post as well)

From distance
bug.jpg
bug.jpg (130.66 KiB) Viewed 822 times
Close up
close.jpg
close.jpg (346.82 KiB) Viewed 822 times
Last edited by King of Worms on Sun Feb 11, 2018 6:24 pm, edited 3 times in total.

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

Re: Strange behavior of the imported flats

Post by King of Worms » Sun Feb 11, 2018 5:50 pm

Ok goddamnit... as soon as Ive posted this problem I tryed to solve for months, I found the reason behind it... well well well

The white shimmering is caused by the size of the sprite in terms of resolution. But pls continue reading

I downscaled the flat so it fits the native resolution of my monitor. Width was not a problem, but height was above 1200 (I use 1920*1200 monitor)

After adjusting the sprite so it has the height of 1200, this problem is gone.

So its something with a scaling of unity engine.

PICTURE
Left - "ABOVE full HD" sized flat
Right - flat fits the full HD standard
(look closely at the edges of sprites pls)
OK.jpg
OK.jpg (156.91 KiB) Viewed 816 times
NOW!!!
This is STILL a bug. Because if I fit my flats to HD standard, and someone plays the game with them installed on a laptop at lets say 900p, he will see the same shimmering around :( HELL, even if he plays at 1080p!!


So before I go thu all the flats and do the work, we should address this somehow. Is this a bug, feature, or? Can something be done about it?

THANKS!

User avatar
Interkarma
Posts: 2959
Joined: Sun Mar 22, 2015 1:51 am

Re: Strange behavior of the imported flats

Post by Interkarma » Mon Feb 12, 2018 12:55 am

White/black/grey borders around cutout billboards are usually down to filter mode sampling colour from the surrounding alpha pixels (RGB and A are considered independently in linear filtering). It's necessary to build a buffer zone around the outside of the sprite texture (using something like pixel dilation) so the correct colour is sampled at the transparent boundary.

This article in the Unity manual has an example of how to create this kind of dilation in Photoshop and merge to alpha channel. It's the same concept here.

Daggerfall Unity has built-in image processing code which does all of this automatically for classic sprites, but imported flats will need to have this buffer added to input image by artist. It's not so much a bug as just how filtering works on GPUs. Game dev can be awesome fun sometimes. :)

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

Re: Strange behavior of the imported flats

Post by King of Worms » Mon Feb 12, 2018 9:09 am

Thanks for a reply! This is crazy. Does this whole process even translate to the PNG file when I save it? They say to save to PSD... PSD keeps the layers separated, PNG is just a flat picture I think.

Question: will there be downsampling implemented at some point? I mean, running the game at higher resolution than your native resolution is? I can see those resolutions in the options, but when I click them, game runs at the native resolution only.

Because no, I cant do this process for all the flats. I cant even duplicate that process. because I miss the action “Dilate Many” which "all of sudden" they reffer to. They have it in a "alpha unity" subsection which I DOUBT is a standard in any photoshop release...

User avatar
Interkarma
Posts: 2959
Joined: Sun Mar 22, 2015 1:51 am

Re: Strange behavior of the imported flats

Post by Interkarma » Mon Feb 12, 2018 9:39 am

King of Worms wrote:Thanks for a reply! This is crazy. Does this whole process even translate to the PNG file when I save it? They say to save to PSD... PSD keeps the layers separated, PNG is just a flat picture I think.
Yes, you can save this to a PNG just fine - every pixel in a PNG has RGBA components. You just have to make sure the RGB components of the surrounding alpha pixels match the neighbouring non-alpha pixels. Simply put, your sprites should not have any coloured/white/black/gray background adjacent to the desired non-alpha parts, as that's what you're seeing blended into the visible area due to linear filtering.

King of Worms wrote: Question: will there be downsampling implemented at some point? I mean, running the game at higher resolution than your native resolution is? I can see those resolutions in the options, but when I click them, game runs at the native resolution only.
The resolution you select is the render target dimension. This is then stretched to fill display area as a standard fullscreen borderless window. The actual rendering is whatever you set it to. If you set 720p on a native 1080p display, the resulting render target is downsampled compared to native despite being fullscreen.

King of Worms wrote: Because no, I cant do this process for all the flats. I cant even duplicate that process. because I miss the action “Dilate Many” which "all of sudden" they reffer to. They have it in a "alpha unity" subsection which I DOUBT is a standard in any photoshop release...
Dilation is just one way of doing this (and you'll find an option/plugin for dilation in just about every decent paint package). You can also clone stamp the image in offset positions, stretch out the edges, etc. using something like a clamped gaussian blur effect.

The key is that the surrounding pixels are at least a few pixels thick, contain suitable colours in the RGB channels and 0 in the alpha channel. It's a standard problem with billboarding sprites going all the way back to the early days of realtime computer graphics and needs to be part of the asset pipeline if you want the sprites to look good with linear filtering.

Play with the concept first and come to grips with the problem and the solution. Then find a way to integrate this step into your pipeline with the tools you have available. :)

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

Re: Strange behavior of the imported flats

Post by King of Worms » Mon Feb 12, 2018 10:01 am

Got it, thanks, last question

You said:
"If you set 720p on a native 1080p display than..."

But downsampling (DSR - dynamic super resolution - downsampling ) term meaning is the other way

so setting 4k at 1080p display for example. I typically use downsampling from 1600p/1800p to my 1200p monitor. It works like a PERFECT antialiasing and more. And that is not working now - thats what I was asking about, sorry for confusion.

Is there a plan to make it work? That would solve all the problems I face now.

I can see the higher resolutions than my native in the options, which is a good start, but If I select them, they dont apply and game is rendered in native 1920*1200 anyway.
01.jpg
01.jpg (263.23 KiB) Viewed 705 times

User avatar
Interkarma
Posts: 2959
Joined: Sun Mar 22, 2015 1:51 am

Re: Strange behavior of the imported flats

Post by Interkarma » Mon Feb 12, 2018 10:21 am

Your problems are due to art pipeline missing the process I outlined above, nothing to do with resolution.

Just roll up your sleeves and experiment with the process. You'll become far more empowered by understanding the issue and finding your own solution. Everyone who creates sprites used in combination with linear filtering will face this same problem, you're not alone. I had to solve it myself for the classic art conversion pipeline. jman0war had to solve it for his foliage texture replacements.

There are plenty of resources online to help you understand and overcome it. And I'm happy to try and explain in more detail if you come back from research still needing more help. :)

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

Re: Strange behavior of the imported flats

Post by King of Worms » Mon Feb 12, 2018 10:38 am

Ive got it solved, thats why my right flat on a comparison does not have a white outline. Sorry, I guess you dont want to answer, I take it as it is. No DSR

EDIT: if I remember right, Jmanowar used feathering? I have it as well

User avatar
Interkarma
Posts: 2959
Joined: Sun Mar 22, 2015 1:51 am

Re: Strange behavior of the imported flats

Post by Interkarma » Mon Feb 12, 2018 10:48 am

Excuse me, but I have tried to answer you in great detail.

What you're asking about has no bearing on the solution, it's just a way of hiding the problem, which is not the same as fixing it properly.

Now, I'm happy to continue being helpful if that's something you wish to explore, otherwise I have nothing more to add.

User avatar
Interkarma
Posts: 2959
Joined: Sun Mar 22, 2015 1:51 am

Re: Strange behavior of the imported flats

Post by Interkarma » Mon Feb 12, 2018 10:54 am

King of Worms wrote:EDIT: if I remember right, Jmanowar used feathering? I have it as well
You're almost there then. :) Just keep in mind that Daggerfall Unity uses transparent cutouts (rather than smoothly alpha blended edges). In alpha cutouts, a pixel is either included or discarded based on the alpha, there's no partial transparency.

The trick is to create those feathered edges with with an alpha of 0 and the normal colour parts with an alpha of 1. This way the surrounding feathered RGB colours are blended in rather than the undesirable solid-colour parts of the image. This has much the same outcome as dilation, etc.

I'll see if I can find the thread where I discussed this with jman0war a while back.

Edit: here it is. I'm happy to continue discussing this here if you would like more details.

There's also a different shader setup used by foliage than interior billboards, which is where you might be facing extra challenges to jman0war. Maybe TheLacus would be able to offer some more advice here, as he's most involved with the asset injection side of things.

Post Reply