Difference between revisions of "Texture filtering"

From Emulation General Wiki
Jump to navigation Jump to search
(ce'd lead, added hatnote, and adjusted wikipedia link)
(26 intermediate revisions by 15 users not shown)
Line 1: Line 1:
[[File:Nearest_Neighbor_2x_versus_HQ2x.png|thumb|A comparison between nearest neighbor scaling and HQ2x scaling]]
+
[[File:Nearest_Neighbor_2x_versus_HQ2x.png|thumb|300px|A comparison between nearest neighbor scaling and HQ2x scaling]]
 +
:''This article is about smoothing techniques that may be present even on original hardware. For the process of replacing textures to improve their visual fidelity or other aesthetic reasons, see [[Texture Packs]].''
  
In computer graphics, '''texture filtering''' or texture smoothing is the method used to smooth textures used in 3D models. Some consoles use texture filtering.
+
'''[[wikipedia:Texture filtering|Texture filtering]]''' refers to the methods used to smooth the textures of a 3D model. Every home console after the [[Nintendo 64 emulators|Nintendo 64]] is able to do it, including every modern PC and Android device. This makes it useful in emulation, where it can be applied to emulators for consoles that did not originally have it through various emulators that support it.
 
 
In emulation, texture filtering can be applied even if the original console did not use it. Many emulators support such features.
 
  
 
==Consoles==
 
==Consoles==
{| class="wikitable"
+
{| class="wikitable" style="text-align:center;"
 
! scope="col"|Console
 
! scope="col"|Console
! scope="col" style="text-align: center;"|Texture Filtering
+
! scope="col"|Texture Filtering
! scope="col" style="text-align: center;"|Types of filtering
+
! scope="col"|Types of filtering
 
|-
 
|-
|[[Super Nintendo]]
+
| style="text-align:left;" |[[Super Nintendo emulators|Super Nintendo]]
| style="text-align: center;"|✗
+
|{{}}
| style="text-align: center;"|
+
|
 
|-
 
|-
|[[3DO]]
+
| style="text-align:left;" |[[3DO emulators|3DO]]
| style="text-align: center;"|✗
+
|{{}}
| style="text-align: center;"|?
+
|?
 
|-
 
|-
|[[Atari Jaguar]]
+
| style="text-align:left;" |[[Atari Jaguar emulators|Atari Jaguar]]
| style="text-align: center;"|✗
+
|{{}}
| style="text-align: center;"|
+
|
 
|-
 
|-
|[[Sega Saturn]]
+
| style="text-align:left;" |[[Sega Saturn emulators|Sega Saturn]]
| style="text-align: center;"|✗
+
|{{}}
| style="text-align: center;"|
+
|
 
|-
 
|-
|[[PlayStation]]
+
| style="text-align:left;" |[[PlayStation emulators|PlayStation]]
| style="text-align: center;"|✗
+
|{{}}
| style="text-align: center;"|
+
|
 
|-
 
|-
|[[Nintendo 64]]
+
| style="text-align:left;" |[[Nintendo 64 emulators|Nintendo 64]]
| style="text-align: center;"|✓
+
|{{}}
| style="text-align: center;"|Three-sample bilinear
+
|Three-sample
 
|-
 
|-
|[[Sega Dreamcast]]
+
| style="text-align:left;" |[[Sega Dreamcast emulators|Sega Dreamcast]]
| style="text-align: center;"|✓
+
|{{}}
| style="text-align: center;"|Bilinear, trilinear, anisotropic
+
|Bilinear, trilinear, anisotropic
 
|-
 
|-
|[[PlayStation 2]]
+
| style="text-align:left;" |[[PlayStation 2 emulators|PlayStation 2]]
| style="text-align: center;"|✓
+
|{{}}
| style="text-align: center;"|Bilinear, trilinear
+
|Bilinear, trilinear, Anisotropic
 
|-
 
|-
|[[Gamecube|GameCube]]
+
| style="text-align:left;" |[[GameCube emulators|GameCube]]
| style="text-align: center;"|✓
+
|{{}}
| style="text-align: center;"|Bilinear, trilinear, anisotropic
+
|Bilinear, trilinear, anisotropic
 
|-
 
|-
|[[Xbox]]
+
| style="text-align:left;" |[[Xbox emulators|Xbox]]
| style="text-align: center;"|✓
+
|{{}}
| style="text-align: center;"|Bilinear, trilinear, anisotropic
+
|Bilinear, trilinear, anisotropic
 
|-
 
|-
|[[Nintendo DS]]
+
| style="text-align:left;" |[[Nintendo DS emulators|Nintendo DS]]
| style="text-align: center;"|✗
+
|{{}}
| style="text-align: center;"|?
+
|?
 
|-
 
|-
|[[PlayStation Portable]]
+
| style="text-align:left;" |[[PlayStation Portable emulators|PlayStation Portable]]
| style="text-align: center;"|✓
+
|{{}}
| style="text-align: center;"|Bilinear, trilinear
+
|Bilinear, trilinear
 
|-
 
|-
|[[Wii]]
+
| style="text-align:left;" |[[Wii emulators|Wii]]
| style="text-align: center;"|✓
+
|{{}}
| style="text-align: center;"|Bilinear, trilinear, anisotropic
+
|Bilinear, trilinear, anisotropic
 
|}
 
|}
  
{| class="wikitable"
+
==Types of Texture Filtering==
|+Types of Texture Filtering
+
 
! scope="col" style="text-align: center;"|Filtering type
+
{| class="wikitable" style="text-align:center;"
! scope="col" style="text-align: center;"|What it does
+
! scope="col"|Filtering type
! scope="col" style="text-align: center;"|Pros
+
! scope="col"|What it does
! scope="col" style="text-align: center;"|Cons
+
! scope="col"|Pros
 +
! scope="col"|Cons
 
|-
 
|-
| style="text-align: center;"|'''Nearest neighbor'''
+
|'''Nearest neighbor'''
| style="text-align: center;"|Basically, it looks the exact same as having no filter whatsoever.
+
|This method sorts pixels into the nearest place relevant to its placement in the original resolution, in order to display the image at whatever resolution you specify.
| style="text-align: center;"|
+
|
 
*Very fast.  
 
*Very fast.  
*Looks good for 2D games if you want to keep the pixel art aesthetic.
+
*At integer values (eg, exactly double or quadruple resolution) it's practically "unfiltered".
| style="text-align: center;"|
+
|
*3D games look terrible.
+
*Unfiltered pixels tend to look odd, with some being thicker than others. This can result in pixel art losing clarity, and text may become hard to read.
*It's unfiltered pixels. You should know what to expect.
 
 
|-
 
|-
| style="text-align: center;"|'''Nearest Neighbor with Mipmapping'''
+
|'''Bilinear'''
| style="text-align: center;"|Exactly what it says on the tin: Nearest-neighbor filtering with mipmapping. Mipmapping is basically level of detail for textures. The farther away a texture is in a 3D space, the lower the resolution is. This can continue until the texture is completely flat.
+
|This linear filtering method uses color data from the pixels in a nearest-neighbor texture, and combines multiple bits of color data in order to replace some of the pixels with an averaged-out version of the colors, so that the colors gradually switch rather than jump to a new color.
| style="text-align: center;"|
+
|
*Even faster than regular nearest neighbor.
 
| style="text-align: center;"|
 
*3D games look terrible.
 
|-
 
| style="text-align: center;"|'''Bilinear'''
 
| style="text-align: center;"|This linear filtering method uses color data from the pixels in a nearest-neighbor texture, and combines multiple bits of color data in order to replace some of the pixels with an averaged-out version of the colors, so that the colors gradually switch rather than jump to a new color.
 
| style="text-align: center;"|
 
 
*Looks better than nearest neighbor for 3D games.
 
*Looks better than nearest neighbor for 3D games.
 
*It's the least system-intensive form of texture filtering/scaling.
 
*It's the least system-intensive form of texture filtering/scaling.
| style="text-align: center;"|
+
|
*2D games look atrocious.
+
*At low resolutions, 2D games tend to become very blurry.  This is especially noticeable in 2D games, and low res 3D games.
*If you have the specs to use them, every other filtering option is better.
+
*If you have the hardware to do so, look into more complex filtering methods to preserve clarity.
 
|-
 
|-
| style="text-align: center;"|'''Trilinear'''
+
|'''Trilinear'''
| style="text-align: center;"|This linear filtering method does the same thing as bilinear filtering, except it passes through twice, giving a smoother gradient.
+
|This linear filtering method does the same thing as bilinear filtering, except it passes through twice, giving a smoother gradient.
| style="text-align: center;"|
+
|
 
*Looks better than bilinear filtering for 3D games.
 
*Looks better than bilinear filtering for 3D games.
| style="text-align: center;"|
+
|
*2D games look atrocious.
+
*As with bilinear, low-resolution games will more than likely appear overly blurry using this method.
 
|-
 
|-
| style="text-align: center;"|'''Anisotropic'''
+
|'''HQx'''
| style="text-align: center;"|Uses oddly-shaped copies of texture parts in order to smooth out pixelated/blurred edges in nearest neighbor/linearly filtered images. Higher sample amounts (e.g. 4x, 8x, 16x) will shape the textures into more complex shapes as needed.
+
|A texture scaling algorithm. Scales up a nearest-neighbor version of the texture and fills in the gaps with copies of the pixels next to said gaps.
| style="text-align: center;"|
+
|
*Looks much better than just linear filtering for 3D games.
+
*While it is inherently destructive, some games (eg. Yoshi's Island) may benefit from this filter, as it preserves the cartoony look.
*Can be used alongside other filters and scaling algorithms for even smoother-looking textures.
+
|
| style="text-align: center;"|
 
*Very system-intensive.
 
*Not recommended for 2D games.
 
|-
 
| style="text-align: center;"|'''HQx'''
 
| style="text-align: center;"|A texture scaling algorithm. Scales up a nearest-neighbor version of the texture and fills in the gaps with copies of the pixels next to said gaps.
 
| style="text-align: center;"|
 
*Looks great for many 2D games.
 
| style="text-align: center;"|
 
 
*Artifacts are common.
 
*Artifacts are common.
*Curves and slopes that aren't 45­° slopes look very pixelated compared to everything else.
+
*Curves and slopes that aren't 45­° look jagged compared to everything else.
 
*The finer details of the textures/sprites might be obscured by bad edge detection.
 
*The finer details of the textures/sprites might be obscured by bad edge detection.
 
*Posterization is very common. There are deposterization filters in some emulators (e.g. PPSSPP) that can aid this, however.
 
*Posterization is very common. There are deposterization filters in some emulators (e.g. PPSSPP) that can aid this, however.
 
*Worse at some things that xBR excels at.
 
*Worse at some things that xBR excels at.
 
|-
 
|-
| style="text-align: center;"|'''2xSaI'''
+
|'''2xSaI'''
| style="text-align: center;"|A texture scaling algorithm. Scales the texture and fills edges in with a mixture of pixels from the source, and randomly-guessed colors.
+
|A texture scaling algorithm. Scales the texture and fills edges in with a mixture of pixels taken from the source and randomly-guessed colors.
| style="text-align: center;"|
+
|
 
*Less system-intensive than HQx and xBR.
 
*Less system-intensive than HQx and xBR.
*Good if it's the best option available (e.g. like in Pete's OpenGL2 plugin for PSX emulators).
+
*Adequate if it's the best option available (e.g. in Pete's OpenGL2 plugin for PSX emulators).
| style="text-align: center;"|
+
|
 
*Edge detection is horrible.
 
*Edge detection is horrible.
 
*Artifacts are common.
 
*Artifacts are common.
Line 134: Line 117:
 
*Archaic. The alternatives are much better.
 
*Archaic. The alternatives are much better.
 
|-
 
|-
| style="text-align: center;"|'''xBR'''
+
|'''xBR'''
| style="text-align: center;"|A modified version of HQx. It detects edges better, which works better for curved lines, or for slopes that are greater than/less than 45 degrees.
+
|A modified version of HQx. It detects edges better, which works better for curved lines, or for slopes that are greater than/less than 45 degrees.
| style="text-align: center;"|
+
|
 
*Looks great for many 2D games.
 
*Looks great for many 2D games.
 
*Edge detection is improved over HQx. This gives textures smoother curves and slopes, as well as fewer artifacts.
 
*Edge detection is improved over HQx. This gives textures smoother curves and slopes, as well as fewer artifacts.
 
*3D games look great with it as well.
 
*3D games look great with it as well.
| style="text-align: center;"|
+
|
 
*Posterization is common. There are deposterization filters in some emulators (e.g. PPSSPP) that can aid this, however.
 
*Posterization is common. There are deposterization filters in some emulators (e.g. PPSSPP) that can aid this, however.
 +
*The finer details of the textures/sprites might be obscured by bad edge detection.
 
*Worse at some things that HQx excels at.
 
*Worse at some things that HQx excels at.
 +
|-
 +
|'''xBRZ'''
 +
|A modified version of xBR, which is very similar except it's better at scaling up smaller features consisting of <10 pixels.
 +
|
 +
*Looks great for many 2D games.
 +
*Detects small features that get messed up by HQx and xBR.
 +
*3D games look great with it as well.
 +
|
 +
*Posterization is common. There are deposterization filters in some emulators (e.g. PPSSPP) that can aid this, however.
 +
*Worse at some things the other scalers excel at.
 
|}
 
|}
 +
 +
==Durante's Hybrid and Deposterization Filters for PPSSPP==
 +
 +
PPSSPP has a scaling option known as "Hybrid." There's also an option called "Deposterize." Posterization, meaning a sharp contrast in hue from one pixel to another (very common in low-quality gifs) has been a problem plaguing texture scaling algorithms for quite some time. Durante's filter switches between xBR and bilinear/bicubic filtering depending on the texture information. On top of this, the "Deposterize" option tackles posterization edges in compressed textures, allowing for a smooth gradient rather than a sharp transition. Although it's not perfect (a perfect scaler sadly isn't possible with today's computing power) it's still great and it's recommended to use for PPSSPP if you have the specs.
  
 
==Images==
 
==Images==
 
<gallery captionalign="center" position="center">
 
<gallery captionalign="center" position="center">
 
Psp-linear2.jpg|PSP game with linear filtering
 
Psp-linear2.jpg|PSP game with linear filtering
Psp-nearest2.jpg|PSP game with nearest neighbor upscaling
+
Psp-nearest2.jpg|PSP game with nearest neighbor
Psp-xbr2.jpg|PSP game with 3xBR filtering
+
Psp-xbr2.jpg|PSP game with 3xBR texture scaling
 
</gallery>
 
</gallery>
 
<gallery position="center" bordersize="none" captionalign="center">
 
<gallery position="center" bordersize="none" captionalign="center">
Line 156: Line 154:
 
N64-nearest.png|N64 game upscaled with nearest neighbor (using Glide64 plugin)
 
N64-nearest.png|N64 game upscaled with nearest neighbor (using Glide64 plugin)
 
</gallery><gallery columns="2" captionalign="center" widths="180" position="center" bordersize="none">
 
</gallery><gallery columns="2" captionalign="center" widths="180" position="center" bordersize="none">
Snes-nearest.png|SNES game with nearest neighbor upscaling
+
Snes-nearest.png|SNES game with nearest neighbor
 
Snes-linear.png|SNES game with linear filtering
 
Snes-linear.png|SNES game with linear filtering
 +
</gallery><gallery columns="2" captionalign="center" widths="180" position="center" bordersize="none">
 +
Super_Mario_All-Stars_with_nearest_neighbor.png|SNES game with nearest neighbor
 +
Super_Mario_All-Stars_with_hq4x.png|SNES game with HQ4x texture scaling
 +
Super_Mario_All-Stars_with_5xBR.png|SNES game with 5xBR texture scaling
 
</gallery>
 
</gallery>
 
  
 
==Further reading==
 
==Further reading==
 
+
* [https://web.archive.org/web/20140904180543/http://board.byuu.org/viewtopic.php?f=10&t=2248 Forum post from the creator of xBR, explaining how the algorithm works] (Warning: is slightly hard to read due to the amount of jargon and big words)
[http://en.wikipedia.org/wiki/Texture_filtering Wikipedia's entry on Texture Filtering]
+
* [http://blog.metaclassofnil.com/?p=306 A blog entry by Durante on creating a hybrid texture filter for PPSSPP.]
 
 
[http://board.byuu.org/viewtopic.php?f=10&t=2248 Forum post from the creator of xBR, explaining how the algorithm works] (Warning: is slightly hard to read due to the amount of jargon and big words)
 
 
 
[http://blog.metaclassofnil.com/?p=306 A blog entry on creating a hybrid texture filter for PPSSPP.]
 
  
 
[[Category:FAQs]]
 
[[Category:FAQs]]

Revision as of 19:25, 16 March 2020

A comparison between nearest neighbor scaling and HQ2x scaling
This article is about smoothing techniques that may be present even on original hardware. For the process of replacing textures to improve their visual fidelity or other aesthetic reasons, see Texture Packs.

Texture filtering refers to the methods used to smooth the textures of a 3D model. Every home console after the Nintendo 64 is able to do it, including every modern PC and Android device. This makes it useful in emulation, where it can be applied to emulators for consoles that did not originally have it through various emulators that support it.

Consoles

Console Texture Filtering Types of filtering
Super Nintendo
3DO ?
Atari Jaguar
Sega Saturn
PlayStation
Nintendo 64 Three-sample
Sega Dreamcast Bilinear, trilinear, anisotropic
PlayStation 2 Bilinear, trilinear, Anisotropic
GameCube Bilinear, trilinear, anisotropic
Xbox Bilinear, trilinear, anisotropic
Nintendo DS ?
PlayStation Portable Bilinear, trilinear
Wii Bilinear, trilinear, anisotropic

Types of Texture Filtering

Filtering type What it does Pros Cons
Nearest neighbor This method sorts pixels into the nearest place relevant to its placement in the original resolution, in order to display the image at whatever resolution you specify.
  • Very fast.
  • At integer values (eg, exactly double or quadruple resolution) it's practically "unfiltered".
  • Unfiltered pixels tend to look odd, with some being thicker than others. This can result in pixel art losing clarity, and text may become hard to read.
Bilinear This linear filtering method uses color data from the pixels in a nearest-neighbor texture, and combines multiple bits of color data in order to replace some of the pixels with an averaged-out version of the colors, so that the colors gradually switch rather than jump to a new color.
  • Looks better than nearest neighbor for 3D games.
  • It's the least system-intensive form of texture filtering/scaling.
  • At low resolutions, 2D games tend to become very blurry. This is especially noticeable in 2D games, and low res 3D games.
  • If you have the hardware to do so, look into more complex filtering methods to preserve clarity.
Trilinear This linear filtering method does the same thing as bilinear filtering, except it passes through twice, giving a smoother gradient.
  • Looks better than bilinear filtering for 3D games.
  • As with bilinear, low-resolution games will more than likely appear overly blurry using this method.
HQx A texture scaling algorithm. Scales up a nearest-neighbor version of the texture and fills in the gaps with copies of the pixels next to said gaps.
  • While it is inherently destructive, some games (eg. Yoshi's Island) may benefit from this filter, as it preserves the cartoony look.
  • Artifacts are common.
  • Curves and slopes that aren't 45­° look jagged compared to everything else.
  • The finer details of the textures/sprites might be obscured by bad edge detection.
  • Posterization is very common. There are deposterization filters in some emulators (e.g. PPSSPP) that can aid this, however.
  • Worse at some things that xBR excels at.
2xSaI A texture scaling algorithm. Scales the texture and fills edges in with a mixture of pixels taken from the source and randomly-guessed colors.
  • Less system-intensive than HQx and xBR.
  • Adequate if it's the best option available (e.g. in Pete's OpenGL2 plugin for PSX emulators).
  • Edge detection is horrible.
  • Artifacts are common.
  • Posterization is very common.
  • Archaic. The alternatives are much better.
xBR A modified version of HQx. It detects edges better, which works better for curved lines, or for slopes that are greater than/less than 45 degrees.
  • Looks great for many 2D games.
  • Edge detection is improved over HQx. This gives textures smoother curves and slopes, as well as fewer artifacts.
  • 3D games look great with it as well.
  • Posterization is common. There are deposterization filters in some emulators (e.g. PPSSPP) that can aid this, however.
  • The finer details of the textures/sprites might be obscured by bad edge detection.
  • Worse at some things that HQx excels at.
xBRZ A modified version of xBR, which is very similar except it's better at scaling up smaller features consisting of <10 pixels.
  • Looks great for many 2D games.
  • Detects small features that get messed up by HQx and xBR.
  • 3D games look great with it as well.
  • Posterization is common. There are deposterization filters in some emulators (e.g. PPSSPP) that can aid this, however.
  • Worse at some things the other scalers excel at.

Durante's Hybrid and Deposterization Filters for PPSSPP

PPSSPP has a scaling option known as "Hybrid." There's also an option called "Deposterize." Posterization, meaning a sharp contrast in hue from one pixel to another (very common in low-quality gifs) has been a problem plaguing texture scaling algorithms for quite some time. Durante's filter switches between xBR and bilinear/bicubic filtering depending on the texture information. On top of this, the "Deposterize" option tackles posterization edges in compressed textures, allowing for a smooth gradient rather than a sharp transition. Although it's not perfect (a perfect scaler sadly isn't possible with today's computing power) it's still great and it's recommended to use for PPSSPP if you have the specs.

Images

Further reading