MathewWi / smsplus-gx

Automatically exported from code.google.com/p/smsplus-gx
0 stars 0 forks source link

Screen tearing in original mode when bilinear filtering is OFF #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Original video mode with bilinear filter turned off.
2.
3.

What is the expected output? What do you see instead?

Master System hardware displays the picture at 256x240, so the emulator
should try to reproduce this exact resolution using 256x240 (not sure if
Wii is really capable of use this one) or 512x240 (works with Direct3D -
not really sure about Wii). Anyway, the Virtual Console somehow manages to
reproduce that resolution.

It looks like to me that smsplus-gx right now is using 320x240 (or 640x240)
and scaling to fullscreen to get the proper aspect ratio, since it's
possible to see a lot of artifacts when the screen is scrolling (the first
town of Phantasy Star, for example). The only solution to eliminate this
problem is bilinear filter, but then the screen gets blurred.

What version of the product are you using? On what operating system?

Last public release version

Please provide any additional information below.

I compared Phantasy Star running from Virtual Console, smsplus-gx and PC
(running Kega Fusion at 256x240 with Soft15khz). The Virtual Console
version and my PC setup produces a similar picture. Unfortunately the
artifacts produced by smsplus-gx can't be ignored.

Original issue reported on code.google.com by thiagoalvesdealmeida@gmail.com on 13 Jan 2010 at 4:38

GoogleCodeExporter commented 9 years ago
The issue title is wrong. As explained in the genplus-gx issue page, I can't 
set the
output to 256 or 512 pixels because it is not correct: the SMS have a slower dot
clock than the Genesis so 256 SMS pixels will take the exact same width on a TV
screen than 320 genesis pixels. 

Now, remember the Wii has a fixed horizontal resolution (you can change the 
number of
'active' pixels but not their width), so yes, the 256 pixels have to be 
upscaled (it
would look completely wrong otherwise, i.e circle are not circle anymore and 
you have
big borders on left/right). Same happens for genesis emulation in 256x224 mode. 
And
so does the Virtual Console.

That's said, the way it is upscaled in smsplus-gx is actually more basic than in
genplus-gx, it could indeed be improved to reduce scroll screen tearing when
filtering is OFF. 

Original comment by ekeeke31@gmail.com on 14 Jan 2010 at 8:15

GoogleCodeExporter commented 9 years ago

Original comment by ekeeke31@gmail.com on 14 Jan 2010 at 8:16

GoogleCodeExporter commented 9 years ago
I don't understand why it is not correct if Virtual Console is using 256 or 512 
with
excellent results. Unlike smsplus-gx, the VC emu picture is sharp and don't have
flicker during screen scrolling. The aspect ratio also looks correct to me.

I'm sure you know that 256x240 will be "analog stretched" when displayed on a 
4:3 TV.
So, a perfect circle on a SMS (or NES and SNES) game looks oval on TV. That's 
how the
hardware of these system works. Some games take this into account, others not, 
and so on.

The solution seems simply to me: just use what VC is using (or at least an 
option for
that). No need for more complicated code. :)

Original comment by thiagoalvesdealmeida@gmail.com on 15 Jan 2010 at 4:43

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I think you misunderstood me, I'm perfectly aware the 256 pixels need to be 
stretched
to fit the screen and I agree that my current solution is introducing too much
filtering or tearing (when filtering is disabled).
I was just mentionning that saying it was a problem with the output resolution 
is
wrong: the 256 rendered pixels need to be scaled up to 640 output pixels and so 
does
the VC, just like smsplus-gx. There is no way 256 pixels can be "analog 
stretched" by
the Wii, remember that unlike your video card, the Wii pixel clock is FIXED 
(and so
is the resolution), stretching happens DIGITALLY, before the video signal is 
output.

As I said, the solution to reduce filtering/tearing is probably to do things 
similar
as in genesis plus gx (use the Video Hardware upscaling ability instead of GX) 
but I
have no idea if this would be as sharp as the VC. Unfortunately, nobody knows 
what VC
emulators are doing because the code is off course not publically available. 
Maybe
they have ways to configure the filtering which aren't documented for homebrew
developpers, who knows ?

Original comment by ekeeke31@gmail.com on 16 Jan 2010 at 12:42

GoogleCodeExporter commented 9 years ago
So, the horizontal resolution of Wii is really fixed at 640? There is no other 
240p
resolution available besides 640x240?

I'm almost sure that VC is using for SMS, NES and SNES games a resolution of 
256x240
or 512x240 (512x240 scaled to fullscreen instead of just using 256x240 makes no
difference in the picture. The images will look exactly the same). It's totally
obvious to my eyes, since I did a side by side comparison between VC and my 
video
card running those games at 256x240.

I thought it was something very trivial: just go to the video settings of the 
source
code and replace 640x240 to 512x240. But it's not like that, right? 

I'm sure Nintendo is using a horizontal resolution of 256 or 512 - but how they 
are
doing it is still unknown? 

Original comment by thiagoalvesdealmeida@gmail.com on 16 Jan 2010 at 3:12

GoogleCodeExporter commented 9 years ago
The facts it "looks" the same means not much regarding to technical species: I'm
pretty confident the Wii can NOT output a native 256 or 512 pixels wide signal, 
its
horizontal resolution is 720 pixels, which is fixed by the video hardware dot 
clock
and which can not be changed, this is clearly presented like this in all 
official
documents I've read.

This does not mean there is no chances it can be changed  but if you think 
about it,
there isn't much need when you have hardware that can upscale with very good 
quality
(also consider the Wii shares the same hardware as the Gamecube and was not 
designed
to run NES or SMS games but games at 640x480).

Now sure, you can setup the screen size to any size you want up to 720 pixels, 
256 or
512 pixels if you want but it would make the screen unstretched and centered. 
This is
not what the VC is doing, they are probably upscaling/doubling to 512 pixels 
using GX
(rendering hardware) with no filtering then let the Video hardware upscale to 
the
standard screen width (i.e 640 pixels which is standard fullscreen width for 
TV).
This introduces very little and not so noticable filtering (similar to genesis 
plus
gx when borders are disabled or when running games that use the 256 pixels 
mode).

Anyway, you will see when I improve this part in SMS Plus GX and you tell me 
how it
looks compared to VC, this is as simple of that.  If VC still looks sharper 
then it
means that they have an unnown way to configure hardware filtering so it fits 
better
to specific scaling ratio, not that they 

Original comment by ekeeke31@gmail.com on 16 Jan 2010 at 3:58

GoogleCodeExporter commented 9 years ago
Sorry, but Wii horizontal resolution is fixed at 640 or 720? Which one?

Your theory about VC is interesting. I still need to do a more precise 
comparison
between games that use 256x240 to see if I can spot any signal of what are you
talking about.

I tried to reproduce some NES games using 640x240 scaled to fullscreen with my 
PC,
but I got exactly the same flickering that I see on the NES emulator for Wii. I 
still
think it's not possible to eliminate these upscaling artifacts and, at the same 
time,
keep the picture free of interpolation (like VC), without using the original
resolution. But I hope I'm wrong. :)

Original comment by thiagoalvesdealmeida@gmail.com on 17 Jan 2010 at 5:32

GoogleCodeExporter commented 9 years ago
Wii horizontal resolution is 720 pixels, game can setup a screen size of any 
width up
to 720 pixels, most of them use 640 pixels because it's what most TV let you see
(dunno about widescreen TV).

Also remember your PC is not the same as Wii hardware.
You got artefact because of improper pixel interpolation, that's generally what
happen without filtering.
The fact you see a sharp image with VC does not mean there isn't any filtering, 
it
just mean that the filtering is not so noticeable. Even analog signals are 
somehow
filtered, depends on the quality of the electronic on both video encoding & 
decoding
sides, as well as active/passive components in the internal circuitry. 

Original comment by ekeeke31@gmail.com on 17 Jan 2010 at 10:58

GoogleCodeExporter commented 9 years ago
If the horizontal resolution is fixed at 720 and most games use 640 - what 
about the
80 lines difference between each resolution? Are you sure there isn't a 640x480 
video
mode?

Original comment by thiagoalvesdealmeida@gmail.com on 17 Jan 2010 at 12:00

GoogleCodeExporter commented 9 years ago
No there isn't, this part is pretty well documented in docs I've seen ;-)

By 80 lines you mean 80 pixels ? In that case, there are 640 pixels centered on 
a 720
pixels line and the surrounding area are black pixels (you can see them on lot 
of
homebrew if your TV let you do it). Most TV only shows a limited portion of 
this 720
pixels anyway, the active period of a video signal is fixed but there is a 
duration
defined for 'safe area', this period corresponds approximately to 640 Wii 
pixels.

Anyway, what I wanted to say was that most games are rendering stuff internally 
at
640 pixels (because GX hardware buffer is 640 pixels wide max) then can 
configure the
screen width up to 720 pixels. When the screen width is larger than the 
framebuffer
width, horizontal scaling happens in Video Hardware. They could also render the
screen in several passes into a framebuffer inside main memory, for a true 720 
pixels
resolution (no upscaling). This is probably what is done in games that have true
widescreen support.

In fact, I should say the video width is generally set larger than 640 pixels to
better fit the screen on modern TVs (this is what "widescreen fix" in some 
homebrew
applications is doing). Still, you don't see very much blurring because the 
filtering
hardware is good quality.

Original comment by ekeeke31@gmail.com on 17 Jan 2010 at 1:09

GoogleCodeExporter commented 9 years ago
Yes. I'm talking about pixels. And I wonder how these 80 black pixels are not 
visible
on TV. Just TV overscan can't cover this whole area. Looks like it works very
different than a normal PC hardware.

So, using 640x240 on Genesis Plus (without borders) will display this resolution
centered on a 720x240 screen with black borders or what?

Original comment by thiagoalvesdealmeida@gmail.com on 18 Jan 2010 at 2:00

GoogleCodeExporter commented 9 years ago
This depends on the TV you are using. And yes, SDTV (don't know about HDTV) 
works
very differently than computer screen, this is because NTSC/PAL video signal is
different than VGA/SVGA/etc standards.

You might want to read some documentation about that because I'm a little tired 
of
explanations and I think I pretty much already explained everything I could 
anyway ;-)

here:
http://en.wikipedia.org/wiki/Overscan
http://en.wikipedia.org/wiki/Safe_area

For example, my TV (an old Sony Trinitron 16:9) shows a little more than 640 
Wii/GCN
pixels but not much more. If I don't emulate genesis borders and only output 640
pixels without upcaling, I see a few unpaint pixels on both side (depends how 
the
screen is centered).

HDTV (LCD or Plasma stuff) probably can show much more if not all 720 pixels: 
that's
why people were requesting widescreen fixes for homebrew, because they were all 
usind
default 640x480 mode at first. 

Anyway, we are talking about homebrew stuff here, official games probably take 
care
of that by displaying a 720 pixels wide image (background) but keeping a "safe 
area"
so you can see all important stuff on any TV setup still without having any 
"black"
borders becase the whole width is used.

Original comment by ekeeke31@gmail.com on 18 Jan 2010 at 4:59

GoogleCodeExporter commented 9 years ago
Well, I was not talking exactly about TV vs computer screen. I know they are 
different. 

Displaying a native 640x480 game using 720x480 looks like this on my TV...

http://img210.imageshack.us/img210/4650/ridgeracerw.jpg

So, even with overscan, you can still see the black borders. I'm just wondering 
why
it doesn't happen with (most) Wii games.

Original comment by thiagoalvesdealmeida@gmail.com on 18 Jan 2010 at 6:29

GoogleCodeExporter commented 9 years ago
Huh... Didn't you read any of my previous posts ?
because the Wii can output up to 720 pixels (which is the max any TV can 
display) so
most games either upscale a 640 pixels rendered image or render up to 720 
pixels in
multiple passes, to have a fullscreen image without borders.

sorry but I feel like running in circle here, last time I come back it will be 
to
close this issue because i  fixed it.

Original comment by ekeeke31@gmail.com on 18 Jan 2010 at 9:22

GoogleCodeExporter commented 9 years ago
OK. I was just saying that 640 pixels centered on a 720 screen without scaling 
would
give very visible black borders. In that case, most Wii games could just 
upscale to
720, yes - but talking only about homebrew emulators (more especially, genesis 
plus
without borders), I don't see how 640x240 centered on a 720 screen can give a
fullscreen without (horizontal) borders not using upscale.

Original comment by thiagoalvesdealmeida@gmail.com on 18 Jan 2010 at 10:38

GoogleCodeExporter commented 9 years ago
No, you were clearly  asking about Wii games, and I answered you. Now you're 
back to
genesis plus gx (talking about running in circles lol).

Who said there wasn't any upscaling when borders are disabled ?
http://code.google.com/p/genplus-gx/issues/detail?id=62#c3

If you want to see what it does without any upscaling at all, I repeat, disable
borders & bilinear filtering then set Aspect to STRETCHED with xscale = 0.

Original comment by ekeeke31@gmail.com on 19 Jan 2010 at 7:56

GoogleCodeExporter commented 9 years ago
Yeah. There is upscaling when borders are disabled, but not to 720 (like you 
said). 

Anyway, this resolution talk is starting to become very confused. 

I was reading this post above...

http://forums.sonicretro.org/index.php?s=e2dc7c62ee67a58b7344c9ccab9b9ab9&showto
pic=17918&view=findpost&p=366063

...and I guess VC is really running NES games at 640x240. So, there is probably 
some
smart upscaling involved.

Original comment by thiagoalvesdealmeida@gmail.com on 19 Jan 2010 at 2:12

GoogleCodeExporter commented 9 years ago
Once again, I never said that, read my linked post again: it is upscaled to 720
pixels when borders are enabled and 654 pixels when they are disabled (320/654 =
352/720).

I don't deny those tech talk can be a little confusing, especially since there 
are
also lot of misbeliefs spreaded about those resolution stuffs, that's why I 
took the
time to explain how it really works.

Original comment by ekeeke31@gmail.com on 19 Jan 2010 at 3:03

GoogleCodeExporter commented 9 years ago
Well, that was my interpretation. You said that Wii resolution is fixed at 720. 
So, I
assume that if you want to use 640 and fill the whole screen there is only one
option: upscale the picture up to 720. 

The other option is adding black bars where necessary to make up for the pixel
disparity. The problem is that until know I thought these black bars would be 
very
visible on TV (even with overscan). But since using Genesis Plus with borders 
turned
on these horizontal borders are not visible to me, I guess that the Wii 
resolution is
calibrated to get this final result, for example: 

A game that's internally rendered at 640x448 can be displayed into a 720x480 
video
mode just using black bars (without upscale) and these black bars would still be
hidden on a SDTV (not visible).

That makes much more sense to me.

Original comment by thiagoalvesdealmeida@gmail.com on 19 Jan 2010 at 4:49

GoogleCodeExporter commented 9 years ago
And to tell the true, I still don't understand the reason why the horizontal
resolution is fixed at 720, since there is no technical reason to not be able 
to do
different horizontal resolutions. PS2, for example, was able to do 256, 320, 
384, 512
and 640 in the x axis. Xbox 1 also could do 640, 720 or even 1280x720p.

Maybe it's a limitation in the SDK but not in the hardware? Probably directly
adressing the hardware would allow coders to choose whatever resolution they 
want.

Original comment by thiagoalvesdealmeida@gmail.com on 19 Jan 2010 at 9:51

GoogleCodeExporter commented 9 years ago
Thing is, there is no mention of that even in the official SDK and gamecube 
video
hardware registers have been reverse-engineered long time ago:
http://hitmen.c02.at/files/yagcd/yagcd/index.html. 

The technical reason is the pixel clock, which is generally divided from the 
main
clock. Having a variable and configurable pixel clock would cost additional 
hardware,
cost vs usefulness, it's simple as that.

So pixel clock was fixed (divided from the video clock) on the Gamecube. Maybe 
the
Wii had some evolution which have not been discovered yet (I think Marcan have 
done
some research about the Video encoder, you should ask him directly) but I 
highely
doubt they would have added this costly feature just for VC (especially when VC
emulators apparently all use upscaling). 

Sure, you can still speculate but it won't be based on anything serious, the 
fact it
was possible on older generation of consoles does not mean anything.

Original comment by ekeeke31@gmail.com on 20 Jan 2010 at 7:39

GoogleCodeExporter commented 9 years ago
Thank you very much for sharing all this information. I'm sure you can improve 
your
emulator to achieve the best possible results.

Original comment by thiagoalvesdealmeida@gmail.com on 21 Jan 2010 at 12:40

GoogleCodeExporter commented 9 years ago

Original comment by ekeeke31@gmail.com on 4 Feb 2010 at 2:59

GoogleCodeExporter commented 9 years ago
Hi,

Sorry to bring this subject again.

I tested genplus-gx with games that originally runs at 256x224 and the picture 
looks
perfect to me (compared to the same game running at real 256x240 resolution, 
although
Wii is using 640x240).

I also compared snes9x-gx to the real thing, with the same perfect results. 
Oddly,
fceugc (NES emulator from the same author), just like smsplus-gx, shows flicker
during screen scrolling.

You said the reason is because, unlike genplus-gx, smsplus is not using the 
video
hardware upscaling ability. 

Could the same be true for fceugc? Or is there any other reason these 8 bits 
systems
looks like that.

Please, comment.

Thanks.

Original comment by thiagoalvesdealmeida@gmail.com on 26 Apr 2010 at 4:19

GoogleCodeExporter commented 9 years ago
Just an addendum to my last post...

I also noticed that commercial games like Megaman 9 (runs at 480i) or the 
Virtual
Console version of Castlevania: Rondo of Blood (runs at 240p) have this flicker 
problem.

Could this be easily avoided with better upscaling like genplus-gx does?

Original comment by thiagoalvesdealmeida@gmail.com on 26 Apr 2010 at 4:33

GoogleCodeExporter commented 9 years ago
if it happens in the VC release also and not in all games then it's probably an 
issue
with the game and how it was originally programmed. I didn't followed 
snes9xgx/fceugc
changes recently so I can't tell much about it.

Original comment by ekeeke31@gmail.com on 26 Apr 2010 at 10:33

GoogleCodeExporter commented 9 years ago
Today I compiled the source code of smsplus and I'm really glad to see that 
this 
problem is now fixed (as you said before).

The picture is really great (just like the VC version). Can't thank you enough. 
It 
is so nice to see people like yourself concerned with video emulation accuracy. 

About snes9xgx and fceugc, there isn't any recent change in the video output 
method. 
Older versions shows the same problem: the original video mode looks wrong on 
fceugc, but not on snes9xgx.

If I remember well, you helped dborth (emu author) on this subject.

Unfortunately, dborth don't recognize this as a problem (see above)

http://code.google.com/p/fceugc/issues/detail?id=175
http://code.google.com/p/fceugc/issues/detail?id=123

So, since you fixed the original video mode in smsplus, is it possible to share 
this 
information with him? 

If not, how difficult it would be to fix this problem? Is this something that 
could 
be easily implemented with a few lines of code or it's more complex? I would 
love to 
compile a version of fceugc with better upscaling, since you can't even use 
bilinear 
filter when using the original video mode (unlike smsplus).

Thanks!

Original comment by thiagoalvesdealmeida@gmail.com on 26 Apr 2010 at 11:19

GoogleCodeExporter commented 9 years ago
I don't know how difficult it would be and I unfortunately have no no time 
neither
interest in looking into this. If dborth (tantric) said he doesn't want to fix 
this,
it's his choice and you should respect that, remember we all work during our 
free
time and not necessarely share the same priority.

Original comment by ekeeke31@gmail.com on 27 Apr 2010 at 6:17

GoogleCodeExporter commented 9 years ago
Actually, I fixed this problem changing the source code and using 512 instead 
of 640
as the default resolution for the original video mode.

I hope dborth fix this problem in the official version, futurely.

I'm sorry for bothering you. Thanks.

Original comment by thiagoalvesdealmeida@gmail.com on 16 May 2010 at 2:46