载入中...
搜索中...
未找到
TextureSampler.h
浏览该文件的文档.
1#pragma once
2
3#include <algorithm>
4#include <cmath>
5#include <cstdint>
6#include <string>
7
8namespace eve::graphics {
9
11enum class FilterMode {
12 Nearest,
13 Linear,
14};
15
17enum class MipmapMode {
19 Nearest,
20 Linear,
21};
22
31 bool repeatU = false;
32 bool repeatV = false;
33 bool repeatW = false;
35 float maxAnisotropy = 1.f;
36 float lodBias = 0.f;
37 float minLod = 0.f;
39 float maxLod = 1000.f;
40
45 s.mipmap = MipmapMode::Disabled;
46 return s;
47 }
48
53 s.mipmap = MipmapMode::Disabled;
54 return s;
55 }
56
62 s.mipmap = MipmapMode::Linear;
63 return s;
64 }
65
67 static TextureSampler anisotropic(float maxAniso = 16.f) {
69 s.maxAnisotropy = maxAniso;
70 return s;
71 }
72
73 static FilterMode parseFilter(const std::string &name) {
74 if (name == "nearest" || name == "Nearest" || name == "NEAREST") return FilterMode::Nearest;
75 return FilterMode::Linear;
76 }
77
78 static MipmapMode parseMipmap(const std::string &name) {
79 if (name == "none" || name == "None" || name == "NONE" || name.empty()) return MipmapMode::Disabled;
80 if (name == "nearest" || name == "Nearest" || name == "NEAREST") return MipmapMode::Nearest;
81 return MipmapMode::Linear;
82 }
83
84 static const char *filterName(FilterMode m) {
85 return m == FilterMode::Nearest ? "nearest" : "linear";
86 }
87
88 static const char *mipmapName(MipmapMode m) {
89 switch (m) {
91 return "none";
93 return "nearest";
94 default:
95 return "linear";
96 }
97 }
98};
99
106 bool generateMipmaps = false;
107
108 static TextureCreateInfo defaults() { return {}; }
109
110 static TextureCreateInfo withMipmaps(bool aniso = true, float maxAniso = 16.f) {
112 info.generateMipmaps = true;
114 return info;
115 }
116};
117
119inline int mipmapCountForSize(int width, int height) {
120 if (width <= 0 || height <= 0) return 1;
121 const int m = std::max(width, height);
122 return static_cast<int>(std::floor(std::log2(static_cast<double>(m)))) + 1;
123}
124
125} // namespace eve::graphics
float height
Definition Grass.cpp:235
int width
const char * name
Definition RockMesh.cpp:21
float m[16]
uint32_t s
Definition Weather.cpp:28
卡牌游戏 UI 工具模块:工厂 + 脚本绑定入口。 功能参考 ycarowr/UiCard:扇形手牌布局、抽牌/洗牌、悬浮放大、拖拽到落牌区、 敌方手牌(背面/偷看)、费用不足置灰,以及可实时调节的布局...
Definition AnimTrail.h:6
FilterMode
Mag/min filter for texture sampling.
MipmapMode
Mipmap filter; Disabled turns off mip sampling (maxLod clamped to 0).
int mipmapCountForSize(int width, int height)
Full mip chain count for a 2D image (including base level).
Options for Graphics::newTexture / newCubemap. When generateMipmaps is true and sampler....
static TextureCreateInfo defaults()
static TextureCreateInfo withMipmaps(bool aniso=true, float maxAniso=16.f)
Sampler state for a Texture (filter, wrap, mip LOD, anisotropy). Defaults match historical engine beh...
static TextureSampler anisotropic(float maxAniso=16.f)
Trilinear + anisotropic filtering (capped by device limits at bind time).
static TextureSampler nearest()
static TextureSampler linear()
static const char * mipmapName(MipmapMode m)
float maxAnisotropy
1 = off; values >1 enable anisotropic filtering when the device supports it.
static const char * filterName(FilterMode m)
static TextureSampler linearMipmap()
Trilinear (linear + linear mips). Caller should create the texture with generateMipmaps.
static FilterMode parseFilter(const std::string &name)
float maxLod
Inclusive upper LOD clamp. Large values mean "use all available mips".
static MipmapMode parseMipmap(const std::string &name)