43 _diffuse =
Color(1.0f, 1.0f, 1.0f, 1.0f);
44 _diffuseMap =
nullptr;
45 _specular =
Color(0.0f, 0.0f, 0.0f, 1.0f);
48 _metalnessMap =
nullptr;
52 _emissive =
Color(0.0f, 0.0f, 0.0f, 1.0f);
53 _emissiveIntensity = 1.0f;
54 _emissiveMap =
nullptr;
58 _heightMapFactor = 0.05f;
60 _transmissionFactor = 0.0f;
61 _refractionIndex = 1.5f;
64 _opacityMap =
nullptr;
67 _diffuseMapTiling =
Vector2(1.0f, 1.0f);
68 _diffuseMapOffset =
Vector2(0.0f, 0.0f);
69 _diffuseMapRotation = 0.0f;
70 _normalMapTiling =
Vector2(1.0f, 1.0f);
71 _normalMapOffset =
Vector2(0.0f, 0.0f);
72 _normalMapRotation = 0.0f;
73 _metalnessMapTiling =
Vector2(1.0f, 1.0f);
74 _metalnessMapOffset =
Vector2(0.0f, 0.0f);
75 _metalnessMapRotation = 0.0f;
76 _aoMapTiling =
Vector2(1.0f, 1.0f);
77 _aoMapOffset =
Vector2(0.0f, 0.0f);
78 _aoMapRotation = 0.0f;
79 _emissiveMapTiling =
Vector2(1.0f, 1.0f);
80 _emissiveMapOffset =
Vector2(0.0f, 0.0f);
81 _emissiveMapRotation = 0.0f;
83 _reflectionMap =
nullptr;
85 _clearCoatGloss = 1.0f;
86 _clearCoatGlossInvert =
false;
87 _clearCoatBumpiness = 1.0f;
88 _clearCoatMap =
nullptr;
89 _clearCoatGlossMap =
nullptr;
90 _clearCoatNormalMap =
nullptr;
92 _sheenColor =
Color(0.0f, 0.0f, 0.0f, 1.0f);
93 _sheenRoughness = 0.0f;
95 _iridescenceIntensity = 0.0f;
96 _iridescenceIOR = 1.3f;
97 _iridescenceThicknessMin = 100.0f;
98 _iridescenceThicknessMax = 400.0f;
99 _iridescenceMap =
nullptr;
100 _iridescenceThicknessMap =
nullptr;
101 _specularColor =
Color(1.0f, 1.0f, 1.0f, 1.0f);
103 _specGlossMap =
nullptr;
104 _detailNormalScale = 1.0f;
105 _detailNormalMap =
nullptr;
107 _displacementScale = 0.0f;
108 _displacementBias = 0.5f;
109 _displacementMap =
nullptr;
110 _useOrenNayar =
false;
115 _twoSidedLighting =
false;
131 self->setBaseColorTransform({_diffuseMapTiling, _diffuseMapOffset, _diffuseMapRotation});
132 self->setNormalTransform({_normalMapTiling, _normalMapOffset, _normalMapRotation});
133 self->setMetalRoughTransform({_metalnessMapTiling, _metalnessMapOffset, _metalnessMapRotation});
134 self->setOcclusionTransform({_aoMapTiling, _aoMapOffset, _aoMapRotation});
135 self->setEmissiveTransform({_emissiveMapTiling, _emissiveMapOffset, _emissiveMapRotation});
160 uniforms.
emissiveColor[0] = _emissive.r * _emissiveIntensity;
161 uniforms.
emissiveColor[1] = _emissive.g * _emissiveIntensity;
162 uniforms.
emissiveColor[2] = _emissive.b * _emissiveIntensity;
167 if (_twoSidedLighting) {
168 uniforms.
flags |= (1u << 3);
172 if (_diffuseMap) uniforms.
flags |= 1u;
173 if (_normalMap) uniforms.
flags |= (1u << 2);
174 if (_metalnessMap) uniforms.
flags |= (1u << 6);
175 if (_aoMap) uniforms.
flags |= (1u << 9);
176 if (_emissiveMap) uniforms.
flags |= (1u << 11);
189 uniforms.
flags |= (1u << 17);
193 if (_clearCoat > 0.0f) {
195 const float ccGloss = _clearCoatGlossInvert ? (1.0f - _clearCoatGloss) : _clearCoatGloss;
198 if (_clearCoatMap) uniforms.
flags |= (1u << 14);
199 if (_clearCoatGlossMap) uniforms.
flags |= (1u << 15);
200 if (_clearCoatNormalMap) uniforms.
flags |= (1u << 16);
208 if (_sheenMap) uniforms.
flags |= (1u << 18);
215 if (_iridescenceMap) uniforms.
flags |= (1u << 19);
216 if (_iridescenceThicknessMap) uniforms.
flags |= (1u << 20);
223 if (_specGlossMap) uniforms.
flags |= (1u << 21);
230 if (_detailNormalMap) {
231 uniforms.
flags |= (1u << 22);
234 if (_displacementMap) uniforms.
flags |= (1u << 24);
243 auto overrideSlot = [&](
int slotIndex,
Texture* texture) {
247 for (
auto& [slot, tex] : slots) {
248 if (slot == slotIndex) {
253 slots.push_back({slotIndex, texture});
255 overrideSlot(0, _diffuseMap);
256 overrideSlot(1, _normalMap);
257 overrideSlot(3, _metalnessMap);
258 overrideSlot(4, _aoMap);
259 overrideSlot(5, _emissiveMap);
260 overrideSlot(7, _clearCoatMap);
261 overrideSlot(9, _reflectionMap);
262 overrideSlot(13, _clearCoatGlossMap);
263 overrideSlot(14, _clearCoatNormalMap);
264 overrideSlot(17, _heightMap);
265 overrideSlot(18, _sheenMap);
266 overrideSlot(19, _iridescenceMap);
267 overrideSlot(20, _iridescenceThicknessMap);
268 overrideSlot(21, _specGlossMap);
269 overrideSlot(22, _detailNormalMap);
270 overrideSlot(23, _displacementMap);
GPU texture resource supporting 2D, cubemap, volume, and array formats with mipmap management.