More cleanups.

This commit is contained in:
Tim Allen 2017-08-26 15:17:15 +10:00
parent afa8ea61c5
commit c273297577
3 changed files with 136 additions and 146 deletions

View File

@ -1,29 +1,41 @@
Most of the consoles higan emulates Most of the consoles higan emulates
were designed for the low resolution of NTSC televisions, were designed for low resolution NTSC televisions,
and their video output is often chunky and blocky and their video output is chunky and blocky
by today's standards. by today's standards.
Shaders customise how a console's video output Video shaders customise how a console's video output
is drawn to the computer screen, is drawn to the computer screen,
and can apply just about any effect you can imagine. and can clean up and smooth out the original video,
reproduce the scanlines and blurring of the original display,
or any other visual effect.
Most [drivers](drivers.md) The available video shaders are listed in
only support these shaders the "Video Shaders" submenu of
(some only support one or the other): [the Settings menu](../interface/higan.md#the-settings-menu).
Which shaders are available depends on
[video driver](drivers.md#video) higan is configured to use.
Most drivers only support these shaders:
- **None** draws each computer pixel - **None**
in the same colour as the nearest console pixel. draws each computer pixel according to
This is sometimes called "nearest neighbour scaling", the colour of the single nearest console pixel,
and produces crisp, blocky output. sometimes called "nearest neighbour" scaling.
- **Blur** draws each computer pixel This produces unnaturally crisp and blocky images.
as the weighted average colour - If you use [aspect correction or non-integral scaling][ac],
neighbouring console pixels may be drawn
with a different number of computer pixels due to rounding errors,
causing a distracting rippling effect.
- **Blur**
draws each computer pixel according to
the weighted average colour
of the four nearest console pixels. of the four nearest console pixels.
This is sometimes called "bilinear scaling", averaging the colours of the four nearest console pixels,
and hides some of the blockiness sometimes called "bilinear" scaling.
at the expense of blurring edges. This produces unnaturally blurry images.
However, [ac]: ../interface/higan-settings.md#video
the OpenGL driver supports custom shaders,
in addition to the above. In addition to those,
the OpenGL driver also supports custom shaders.
**Note:** **Note:**
For technical reasons, For technical reasons,
@ -32,9 +44,12 @@ can produce surprising behaviour
in certain shaders, in certain shaders,
particularly shaders that compare each console pixel particularly shaders that compare each console pixel
with its neigbours. with its neigbours.
See [Console-specific Notes](../notes.md) for details. See [Video Shaders and TV-based consoles][vstv] for details.
# Where to get shaders [vstv]: #video-shaders-and-tv-based-consoles
Where to get custom shaders
---------------------------
- higan includes some simple example shaders. - higan includes some simple example shaders.
If your copy of higan did not come with shaders, If your copy of higan did not come with shaders,
@ -44,7 +59,8 @@ See [Console-specific Notes](../notes.md) for details.
contains many high-quality shaders for use with higan. contains many high-quality shaders for use with higan.
- You can write your own. - You can write your own.
# How to install shaders How to install custom shaders
-----------------------------
Make sure the shader you want to install Make sure the shader you want to install
is in the correct format: is in the correct format:
@ -68,10 +84,10 @@ Launch higan,
open the Settings menu, open the Settings menu,
and choose "Advanced ..." and choose "Advanced ..."
to open [the Advanced tab](../interface/higan-settings.md#advanced) to open [the Advanced tab](../interface/higan-settings.md#advanced)
of the Settings dialog. of the Settings window.
Under "Driver Selection", Under "Driver Selection",
make sure "Video" is set to "OpenGL". make sure "Video" is set to "OpenGL".
If you changed the video driver, If it wasn't already set that way,
you'll need to restart higan you'll need to restart higan
for the change to take effect. for the change to take effect.
@ -81,31 +97,27 @@ and now the shaders you installed
should be listed at the bottom of the menu. should be listed at the bottom of the menu.
Load a game Load a game
(so you can see the results) (so you can see the results),
and switch between shaders switch between shaders
to see what they do to see what they do,
and pick your favourite! and pick your favourite!
# Notable examples Notable examples
----------------
The quark-shaders repository The quark-shaders repository mentioned above
contains lots of carefully-crafted shaders, contains lots of carefully-crafted shaders,
but some are particularly noteworthy: but some are particularly noteworthy:
- **AANN** implements "anti-aliased nearest neighbour" scaling. - **AANN** implements "anti-aliased nearest neighbour" scaling.
If the console's video is not displayed This uses anti-aliasing to hide
at an exact multple of the console's native resolution, the rounding errors often introduced by
rounding errors cause normal nearest-neighbour scaling aspect ratio correction
to draw some rows and columns wider than others, and non-integral scaling,
which many people find ugly and distracting. producing an image nearly as crisp as the "None" shader,
This is very common when but without the distracting ripple effect.
higan's aspect-ratio correction mode - **Gameboy** emulates the squarish aspect-ratio,
is enabled. greenish-colours,
AANN uses very slight anti-aliasing
to hide the rounding errors,
leaving the overall image as crisp as nearest-neighbour.
- **Gameboy** emulates the squarish aspect-ratio
greenish-colours
and limited palette and limited palette
of the original Game Boy. of the original Game Boy.
At larger scales, At larger scales,
@ -120,7 +132,85 @@ but some are particularly noteworthy:
and shimmer and shimmer
that most game players would have seen that most game players would have seen
on real televisions. on real televisions.
This is important because Some games depend on NTSC artifacts
some games depended on NTSC artifacts
to display colours outside the console's official palette to display colours outside the console's official palette
or to create effects like transparency. or to create effects like transparency.
Video Shaders and TV-based consoles
-----------------------------------
Simple shaders
(like "None"
and the third-party "AANN" shader)
just blindly scale up the images they're given,
but sophisticated shaders
(such as the third-party "xBR" shader)
try to produce higher-quality output
by recognising particular patterns,
like taking three diagonal pixels
and turning that into a smooth diagonal line.
These shaders assume that
each pixel drawn by the game's artists
becomes a single pixel in the video output they analyze.
The hand-held consoles that higan emulates
(and also the Famicom)
can only output video at one specific resolution,
so this "one pixel equals one pixel" rule holds true,
and pattern-based shaders like "xBR" work just fine.
Unfortunately,
this is not true for most of the TV-based consoles
that higan supports.
The Super Famicom's "normal" video mode
draws 256 pixels across the width of the screen,
but the "high resolution" mode draws 512.
Since Super Famicom games can enable hi-res mode at any time
(even halfway through a frame),
higan always renders Super Famicom video output 512 pixels wide,
just in case.
This means that in "normal" mode,
each pixel drawn by the game's artists
becomes two pixels in the video output,
breaking the assumption
that pattern-based shaders are based on.
The Super Famicom has a similar issue in the vertical direction:
normally,
an NTSC-based Super Famicom draws about 240 rows of output every frame,
sometimes referred to as "240p" video.
When a game turns on "interlaced" mode,
it draws the 240 odd-numbered lines of one frame,
then the 240 even-numbered lines of the next,
and so forth.
This is sometimes referred to as "480i" video.
Although interlaced mode cannot be enabled mid-frame
like high-resolution mode,
resolution switching is still complex,
so higan always draws all 480 lines of video output.
This means for a normal, non-interlaced game,
each pixel drawn by the game's artists
becomes four pixels in the video output
(two horizontally and two vertically)
making pattern-based shaders even less useful.
It also breaks most scanline-emulation shaders,
since they typically draw a scanline
for each row of pixels in the video output.
The Mega Drive has similar problems
to the Super Famicom.
It has the same behaviour with interlacing,
but its high-resolution mode switches
from 256 pixels across to 320 pixels across.
Therefore in normal mode,
each pixel drawn by the game's artists
becomes five pixels in the video output,
while in high-resolution mode,
each pixel drawn by the game's artists
becomes four pixels in the video output
(or 10 and 8 pixels in non-interlaced mode).
The PC Engine does not support an interlaced mode,
but its horizontal resolution is much more flexible
than the Super Famicom or Mega Drive,
and so it has the same problems with shaders as those consoles.

View File

@ -144,27 +144,8 @@ that aren't technically part of the console itself:
**Video Shader** controls **Video Shader** controls
how the low-resolution video output of the emulated console how the low-resolution video output of the emulated console
is scaled up to suit modern high-resolution displays. is scaled up to suit modern high-resolution displays.
The availability of items in this submenu depends on [Using video shaders](../guides/shaders.md)
which video driver higan is using, describes all the options in this submenu.
so see [Choosing drivers](../guides/drivers.md) for more information.
- **None**
draws each output pixel according to
the colour of the single nearest input pixel,
sometimes called "nearest neighbour" scaling.
This produces unnaturally crisp and blocky images.
- **Blur**
draws each output pixel by
averaging the colours of the four nearest input pixels,
sometimes called "bilinear" scaling.
This produces unnaturally blurry images.
- When using the OpenGL driver,
an additional item appears in this menu for
each installed shader.
See [Using video shaders](../guides/shaders.md)
for details.
**Synchronize Audio** **Synchronize Audio**
causes higan to wait for audio playback to complete causes higan to wait for audio playback to complete

View File

@ -3,87 +3,6 @@ are similar in many ways,
but some of them do have particular quirks but some of them do have particular quirks
that you should be aware of. that you should be aware of.
Video Shaders and TV-based consoles
-----------------------------------
[Video Shaders](guides/shaders.md)
customize how higan scales
the low-resolution video of the emulated console
up to the high-resolution of the computer display.
Simple shaders
(like "None"
and the third-party "AANN" shader)
just blindly scale up the images they're given,
but sophisticated shaders
(such as the third-party "xBR" shader)
try to produce higher-quality output
by recognising particular patterns of pixel,
like taking three diagonal pixels
and turning that into a smooth diagonal line.
These shaders assume that
each pixel drawn by the game's artists
becomes a single pixel in the video output they analyze.
Many of the consoles higan emulates
can only output video at one specific resolution,
so this "one pixel equals one pixel" rule holds true,
and pattern-based shaders like "xBR" work just fine.
Unfortunately,
this is not the case for the Super Famicom.
The "normal" video mode
draws 256 pixels across the width of the screen,
but the "high resolution" mode draws 512.
Since Super Famicom games can enable hi-res mode at any time
(even halfway through a frame),
higan always renders Super Famicom video output 512 pixels wide,
just in case.
This means that in "normal" mode,
each pixel drawn by the game's artists
becomes two pixels in the video output,
breaking the assumption
that pattern-based shaders are based on.
The Super Famicom has a similar issue in the vertical direction:
normally,
an NTSC-based Super Famicom draws about 240 rows of output every frame,
sometimes referred to as "240p" video.
When a game turns on "interlaced" mode,
it draws the 240 odd-numbered lines of one frame,
then the 240 even-numbered lines of the next,
and so forth.
This is sometimes referred to as "480i" video.
Although interlaced mode cannot be enabled mid-frame
like high-resolution mode,
resolution switching is still complex,
so higan always draws all 480 lines of video output.
This means for a normal, non-interlaced game,
each pixel drawn by the game's artists
becomes four pixels in the video output
(two horizontally and two vertically)
making pattern-based shaders even less useful.
It also breaks most scanline-emulation shaders,
since they typically draw a scanline
for each row of pixels in the video output.
The Mega Drive has similar problems
to the Super Famicom.
It has the same behaviour with interlacing,
but its high-resolution mode switches
from 256 pixels across to 320 pixels across.
Therefore in normal mode,
each pixel drawn by the game's artists
becomes five pixels in the video output,
while in high-resolution mode,
each pixel drawn by the game's artists
becomes four pixels in the video output
(or 10 and 8 pixels in non-interlaced mode).
The PC Engine does not support an interlaced mode,
but its horizontal resolution is much more flexible
than the Super Famicom or Mega Drive,
and so it has the same problems with shaders.
Music and Sound Effect Volume on the Mega Drive Music and Sound Effect Volume on the Mega Drive
----------------------------------------------- -----------------------------------------------