// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Core/Types/BaseTypes.h" /// /// GPU sampler filter modes. /// API_ENUM() enum class GPUSamplerFilter { /// Filter using the nearest found pixel. Texture appears pixelated. Point = 0, /// Filter using the linear average of the nearby pixels. Texture appears blurry. Bilinear = 1, /// Filter using the linear average of the nearby pixels and nearby mipmaps. Texture appears blurry. Trilinear = 2, /// Filter using the anisotropic filtering that improves quality when viewing textures at a steep angles. Texture appears sharp at extreme viewing angles. Anisotropic = 3, API_ENUM(Attributes="HideInEditor") MAX }; /// /// GPU sampler address modes. /// API_ENUM() enum class GPUSamplerAddressMode { /// Texture coordinates wrap back to the valid range. Wrap = 0, /// Texture coordinates are clamped within the valid range. Clamp = 1, /// Texture coordinates flip every time the size of the valid range is passed. Mirror = 2, /// Texture coordinates outside of the valid range will return a separately set border color. Border = 3, API_ENUM(Attributes="HideInEditor") MAX }; /// /// GPU sampler comparision function types. /// API_ENUM() enum class GPUSamplerCompareFunction { /// Never pass the comparison. Never = 0, /// If the source data is less than the destination data, the comparison passes. Less = 1, API_ENUM(Attributes="HideInEditor") MAX }; /// /// GPU sampler border color types. /// API_ENUM() enum class GPUSamplerBorderColor { /// /// Indicates black, with the alpha component as fully transparent. /// TransparentBlack = 0, /// /// Indicates black, with the alpha component as fully opaque. /// OpaqueBlack = 1, /// /// Indicates white, with the alpha component as fully opaque. /// OpaqueWhite = 2, API_ENUM(Attributes="HideInEditor") MAX }; /// /// A common description for all samplers. /// API_STRUCT() struct FLAXENGINE_API GPUSamplerDescription { DECLARE_SCRIPTING_TYPE_MINIMAL(GPUSamplerDescription); /// /// The filtering method to use when sampling a texture. /// API_FIELD() GPUSamplerFilter Filter; /// /// The addressing mode for outside [0..1] range for U coordinate. /// API_FIELD() GPUSamplerAddressMode AddressU; /// /// The addressing mode for outside [0..1] range for V coordinate. /// API_FIELD() GPUSamplerAddressMode AddressV; /// /// The addressing mode for outside [0..1] range for W coordinate. /// API_FIELD() GPUSamplerAddressMode AddressW; /// /// The mip bias to be added to mipmap LOD calculation. /// API_FIELD() float MipBias; /// /// The minimum mip map level that will be used, where 0 is the highest resolution mip level. /// API_FIELD() float MinMipLevel; /// /// The maximum mip map level that will be used, where 0 is the highest resolution mip level. To have no upper limit on LOD set this to a large value such as MAX_float. /// API_FIELD() float MaxMipLevel; /// /// The maximum number of samples that can be used to improve the quality of sample footprints that are anisotropic. /// API_FIELD() int32 MaxAnisotropy; /// /// The border color to use if Border is specified for AddressU, AddressV, or AddressW. /// API_FIELD() GPUSamplerBorderColor BorderColor; /// /// A function that compares sampled data against existing sampled data. /// API_FIELD() GPUSamplerCompareFunction ComparisonFunction; public: /// /// Creates a new with default settings. /// /// The filtering method. /// The addressing mode. /// A new instance of class. static GPUSamplerDescription New(GPUSamplerFilter filter = GPUSamplerFilter::Point, GPUSamplerAddressMode addressMode = GPUSamplerAddressMode::Wrap); public: void Clear(); bool Equals(const GPUSamplerDescription& other) const; String ToString() const; public: FORCE_INLINE bool operator==(const GPUSamplerDescription& other) const { return Equals(other); } FORCE_INLINE bool operator!=(const GPUSamplerDescription& other) const { return !Equals(other); } }; uint32 GetHash(const GPUSamplerDescription& key);