From bfdc99601e567c028f81df1e2c85f1a7fa5c4258 Mon Sep 17 00:00:00 2001 From: cosmonaut Date: Wed, 27 Jan 2021 13:05:19 -0800 Subject: [PATCH] more detailed sampler section --- content/Graphics/Resources/Sampler.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/content/Graphics/Resources/Sampler.md b/content/Graphics/Resources/Sampler.md index 217d5aa..85013de 100644 --- a/content/Graphics/Resources/Sampler.md +++ b/content/Graphics/Resources/Sampler.md @@ -29,6 +29,16 @@ var mySamplerState = new SamplerState var mySampler = new Sampler(GraphicsDevice, mySamplerState); ``` -The same sampler can be used in conjunction with as many different textures as you like. We will discuss this more when we get into command buffers. +There are three kinds of sample filters: Nearest, Linear, and Cubic. Nearest is the cheapest and doesn't do any kind of filtering. This filter is ideal for upscaling pixel games - Linear will make your pixel art look terrible. Cubic is the most expensive filter but upscales and downscales in decent quality. + +MinFilter describes which filter to use when the result image is smaller than the sampled image - MagFilter, likewise, is used when the result image is larger. + +Anisotropic filtering can be used in conjunction with mipmaps to reduce aliasing and blur on obliquely-rendered textures. Explaning this is beyond the scope of this tutorial but I encourage you to look into the technique if you are planning to make 3D games. + +When you look up pixels using a sampler, you generally look them up using coordinates in the range of [0, 1]. This coordinate space is often referred to as "texture coordinate space" or "UV space". SamplerAddressMode refers to the behavior that will occur if the texture is sampled *outside* of [0, 1] coordinates. ClampToEdge will just take the pixel at the nearest edge. Repeat will loop the image, and MirroredRepeat will mirror the image. + +U-coordinates are horizontal, V-coordinates are vertical, and W-coordinates correspond to depth. You can use different address spaces for each of these directions. + +The same sampler can be used in conjunction with as many different textures as you like. We will discuss this more when we get into "binding" resources using command buffers. There are some common `SamplerState`s that are provided for you, for example `SamplerState.PointClamp`. Have a look at the `SamplerState` definition to see them all.