> For the complete documentation index, see [llms.txt](https://docs.flatredball.com/flatredball/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flatredball.com/flatredball/api/flatredball/graphics/graphicsoptions/filtering.md).

# Filtering

### What is Filtering?

Filtering is a process to reduce the pixellated look of textures when viewed from up close. Without filtering, each pixel represents a rectangular area of a solid color on a Sprite. For example, the following image shows the redball.bmp graphic without filtering. ![RedballUnfiltered.png](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-76492935b8f2db646259bf15bb50907f9e99fc7a%2Fmigrated_media-RedballUnfiltered.png?alt=media) Here is a black and white checkered image. It has been enlarged so that the checkered image is clearly visible: ![CheckersUnfiltered.png](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-2c4d175b5aa135641662009b6e5432118aeec7d6%2Fmigrated_media-CheckersUnfiltered.png?alt=media) With filtering, each pixel represents a color at just one point. When a texture is displayed on the screen, the color for each pixel on the screen is determined through an interpolation between the nearest pixels. The following image shows the redball.bmp graphic with filtering. ![RedballFiltered.png](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-24a853cf8b9aa1711215e3b20aea38c0b0da3d41%2Fmigrated_media-RedballFiltered.png?alt=media) Here is another example of how filtering affects a 16X16 black and white checkered image (again, enlarged to show detail): ![CheckersFiltered.png](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-ab336e5f479d132601323b69a042dc339e8884e9%2Fmigrated_media-CheckersFiltered.png?alt=media) Filtering not only "blurs" the color of each pixel from the source image, but also the transparency. Therefore, rather than having a solid edge, the edge pixels will gradient to transparency. Filtering can be a beneficial technique for reducing visible pixels, but can cause problems as explained in the following section.

### Turning Filtering On/Off

For more information on how to enable and disable Filtering in your FlatRedBall project, see: [GraphicsOption's Filtering property](https://github.com/flatredball/FlatRedBallDocs/tree/main/frb/docs/index.php)

### Filtering Halo

Although Filtering can greatly improve the appearance of a Sprite, it can also cause problems. Consider the following situation. You are interested in creating a white sphere. You create a .png with the center white and fully opaque and the borders transparent. In your image editing program, everything looks great. However, when you load the white sphere in the SpriteEditor or other FlatRedBall application with filtering turned on, you notice a dark border around your white Sprite. The following image shows some simple colored shapes with a dark filtering halo over a white background. ![DarkFilteringHalo.png](https://951240982-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-M_fye9Ufg3vzJxwX5Hk%2Fuploads%2Fgit-blob-b4756e6b418c0a3844b05ad3852d8a9fa7dbb901%2Fmigrated_media-DarkFilteringHalo.png?alt=media) The reason this occurs is because the color of the transparent pixels are "averaged" or interpolated at points which display the Sprite. That is, the edge point on a Sprite may have an RGB value of (255,255,255) - white. Its alpha may also be 255 - fully opaque. Its neighboring pixel may have an alpha of 0 - fully transparent. However, its color value still exists. In the image shown above, the transparent pixels have an RGB value of (0,0,0) - black. Therefore, any point that is "between" the fully transparent and fully opaque pixels will have an averaged color. That is, the point on the screen which is halfway between the opaque and transparent pixel will have an alpha value of around 127 - half transparent; however, its color value will be the average of (0,0,0) and (255, 255, 255) which is around (127, 127, 127) - gray. This is often a problem which arises when games use transparent pixels and filtering. This can be solved manually by coloring the transparent pixels the same color as any opaque pixels. For example, consider the white ball presented previously. To solve the filtering halo, all transparent pixels should be white. After the change, the only difference between the transparent pixels and the white pixels should be the alpha value.

### Solving filtering halo with FilteringHaloRemover

Kao Martin provided a wonderful tool for removing filtering halo from files. It can be found [here](https://github.com/flatredball/FlatRedBallDocs/tree/main/content/Resources/FilteringHaloRemover.exe).

### Solving filtering halo with The GIMP

An excellent feature of The GIMP is that the eyedropper tool gives you both the color of the current pixel considering alpha and also ignoring trancparency. This allows you to easily see the color of pixels which are transparent and helps identify problems related to halo filtering. To fix the filtering, first, identify the location which is causing problems using the eyedropper. Once you have spotted a point where a fully transparent pixel is touching a fully opaque pixel but their colors do not match, use the eyedropper to select the color of the neighboring opaque pixel. Next, simply paint the transparent pixel the color of the opaque pixel - this will make the transparent pixel opaque. Finally, erase the newly-painted pixel so that it is transparent once again. Notice that if you select the pixel with the eyedropper, the color matches the opaque pixel. One way to do this a little faster is to use the "Fuzzy Select" (also known as the magic wand in Photoshop) to select the transparent area and paint multiple pixels at once without modifying the transparent pixels.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flatredball.com/flatredball/api/flatredball/graphics/graphicsoptions/filtering.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
