It is currently Fri Nov 24, 2017 7:47 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2
Author Message
PostPosted: Tue Dec 24, 2013 7:46 am 
Offline
User avatar

Joined: Sat Jan 22, 2005 8:51 am
Posts: 427
Location: Chicago, IL
I spent a few minutes trying to fix it, but didn't have much luck. I'll try again later. In the meantime, here's a comparison of the two shaders in scale mode:

pixellate
Image

fbi
Image

_________________
get nemulator
http://nemulator.com


Top
 Profile  
 
PostPosted: Tue Dec 24, 2013 9:46 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19254
Location: NE Indiana, USA (NTSC)
According to that screenshot, pixellate is equivalent to FBI with an interp_adjust_y equal to 0.5, that is, full nearest-neighbor vertically.

Some level of blurring is unavoidable unless you redraw everything as vector graphics.


Top
 Profile  
 
PostPosted: Tue Dec 24, 2013 11:26 am 
Offline

Joined: Mon Mar 27, 2006 5:23 pm
Posts: 1339
Yeah, I believe the reason pixellate works that way is that higan tries to maintain even multiples in scaling by default.

It is primarily meant to help ease the pain of aspect ratio correction, which is done by changing only the width of the image.

If I recall, SNES Mega Man's energy bar was always the most extreme example of the downside of vertical interpolation. Damn near impossible to make that thing look nice at arbitrary scale factors. And yes I'm aware you could rotate that energy bar 90 degrees and have the same issue with horizontal interpolation (and you could correct aspect by stretching only the height by an uneven multiple.)


Top
 Profile  
 
PostPosted: Tue Dec 24, 2013 4:16 pm 
Offline
User avatar

Joined: Sun May 27, 2012 8:43 pm
Posts: 1311
One thing doesn't look right in both; it gets dark between the left edge of mario's hat and the background green.


Top
 Profile  
 
PostPosted: Tue Dec 24, 2013 4:33 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
Hah, I wonder if that's due to not converting to a linear RGB space before mixing.


Top
 Profile  
 
PostPosted: Tue Dec 24, 2013 5:03 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19254
Location: NE Indiana, USA (NTSC)
The TVs of the time didn't convert to a linear RGB space either.


Top
 Profile  
 
PostPosted: Tue Dec 24, 2013 6:10 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
I didn't think we were simulating TVs here. I thought we were trying to expand a hard-edged pixel image to a non-integer scaling without some pixels being one unit wider/taller than others. When two different-color pixel edges fall next to each other and there's no mixing, it should look similar to when two fall half way across an output pixel such that they are mixed half and half. If this mixing is done in sRGB, the mixed version will look overly dark, which I think is what is happening here.

EDIT: indeed, that was the cause of that unexplained darkness (darker is naive mixing, lighter is correct mixing):

Image


Top
 Profile  
 
PostPosted: Fri Dec 27, 2013 6:52 pm 
Offline
User avatar

Joined: Sat Jan 22, 2005 8:51 am
Posts: 427
Location: Chicago, IL
mikejmoffitt wrote:
One thing doesn't look right in both; it gets dark between the left edge of mario's hat and the background green.

blargg wrote:
If this mixing is done in sRGB, the mixed version will look overly dark...EDIT: indeed, that was the cause of that unexplained darkness (darker is naive mixing, lighter is correct mixing):

Thanks, guys. Fixed in the WIP version of nemulator.

_________________
get nemulator
http://nemulator.com


Top
 Profile  
 
PostPosted: Sat Dec 28, 2013 10:50 am 
Offline
User avatar

Joined: Sun May 27, 2012 8:43 pm
Posts: 1311
tepples wrote:
The TVs of the time didn't convert to a linear RGB space either.


Fortunately, we're discussing scaling and filtering algorithms, not how televisions displayed. What a television does is absolutely irrelevant here.

As long as we're mentioning TVs, though, it should be pointed out that a lot of televisions do seem to implement this incorrect edge mixing that produces dark borders when any upscaling is being performed.


Top
 Profile  
 
PostPosted: Tue Jan 07, 2014 8:58 pm 
Offline
User avatar

Joined: Tue Jan 07, 2014 8:30 pm
Posts: 1
James wrote:
Thanks, guys. Fixed in the WIP version of nemulator.


Hey James, thanks for this!

Would you be kind enough to open source your shader + the latest fixes so that I can see it gets ported to Cg and other formats for cross-platform use in OpenEmu or RetroArch?

There's a pretty good community built around the Cg format (https://github.com/libretro/common-shaders) and your shader looks very nice.


Top
 Profile  
 
PostPosted: Tue Jan 07, 2014 11:34 pm 
Offline
User avatar

Joined: Sat Jan 22, 2005 8:51 am
Posts: 427
Location: Chicago, IL
Hi clobber,

clobber wrote:
your shader looks very nice.

Thanks!

clobber wrote:
Would you be kind enough to open source your shader

Sure. I've updated the code in the first post of this thread. Have at it.

re: sRGB stuff -- that fix is implementation dependent. You can specify that your texture and back buffer are in sRGB color space and let DirectX/OpenGL handle the conversion to/from linear color space. I don't think you can fix this within the shader itself unless you write your own texture sampler.

_________________
get nemulator
http://nemulator.com


Top
 Profile  
 
PostPosted: Tue Jan 07, 2014 11:51 pm 
Offline
User avatar

Joined: Mon Sep 27, 2004 8:33 am
Posts: 3715
Location: Central Texas, USA
I know nothing about shaders, but if you can apply a power function (gamma), do 2.2, mix, then 1/2.2. This will work for sRGB. If things are calculated in more than 8 bits per component, this won't cause any banding.


Top
 Profile  
 
PostPosted: Wed Jan 08, 2014 12:12 am 
Offline
User avatar

Joined: Sat Jan 22, 2005 8:51 am
Posts: 427
Location: Chicago, IL
blargg wrote:
if you can apply a power function (gamma), do 2.2, mix, then 1/2.2.

Yeah, this is what I was referring to when I said you'd need to write your own texture sampler. If you wanted to do this, you wouldn't be able to use the built-in linear sampler because you can't modify the pre-interpolation values. You'd have to point sample the texture, apply gamma corrections, and manually interpolate.

_________________
get nemulator
http://nemulator.com


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 28 posts ]  Go to page Previous  1, 2

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group