/// <summary> /// Unpacks the texture minification filter. /// This defines the filtering used when the texture covers an area on the screen /// that is smaller than the texture size. /// </summary> /// <returns>The minification filter</returns> public MinFilter UnpackMinFilter() { SamplerMinFilter minFilter = (SamplerMinFilter)((Word1 >> 4) & 3); SamplerMipFilter mipFilter = (SamplerMipFilter)((Word1 >> 6) & 3); return(ConvertFilter(minFilter, mipFilter)); }
/// <summary> /// Converts two minification and filter enum, to a single minification enum, /// including mipmap filtering information, as expected from the host API. /// </summary> /// <param name="minFilter">The minification filter</param> /// <param name="mipFilter">The mipmap level filter</param> /// <returns>The combined, host API compatible filter enum</returns> private static MinFilter ConvertFilter(SamplerMinFilter minFilter, SamplerMipFilter mipFilter) { switch (mipFilter) { case SamplerMipFilter.None: switch (minFilter) { case SamplerMinFilter.Nearest: return(MinFilter.Nearest); case SamplerMinFilter.Linear: return(MinFilter.Linear); } break; case SamplerMipFilter.Nearest: switch (minFilter) { case SamplerMinFilter.Nearest: return(MinFilter.NearestMipmapNearest); case SamplerMinFilter.Linear: return(MinFilter.LinearMipmapNearest); } break; case SamplerMipFilter.Linear: switch (minFilter) { case SamplerMinFilter.Nearest: return(MinFilter.NearestMipmapLinear); case SamplerMinFilter.Linear: return(MinFilter.LinearMipmapLinear); } break; } return(MinFilter.Nearest); }
/// <summary> /// Default SamplerStateDescription values. /// </summary> public void SetDefault() { AddressModeU = SamplerAddressMode.ClampToEdge; AddressModeV = SamplerAddressMode.ClampToEdge; AddressModeW = SamplerAddressMode.ClampToEdge; MagFilter = SamplerMinMagFilter.Nearest; MinFilter = SamplerMinMagFilter.Nearest; MipmapFilter = SamplerMipFilter.Nearest; MaxAnisotropy = 1; LodMinClamp = 0.0f; LodMaxClamp = float.MaxValue; CompareFunction = CompareFunction.Never; BorderColor = SamplerBorderColor.TransparentBlack; }