Repository navigation
Expand file tree
/
Copy pathApplicationData.h
More file actions
264 lines (230 loc) · 14.7 KB
/
Copy pathApplicationData.h
File metadata and controls
264 lines (230 loc) · 14.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
/**
* @file ApplicationData.h
* @brief This header file keeps user-provided application data (vertices, indices etc.).
* @author Mustafa Yemural (myemural)
* @date 30.09.2026
*
* Copyright (c) 2025 Mustafa Yemural - www.mustafayemural.com
* Released under the MIT License
* https://opensource.org/licenses/MIT
*/
#pragma once
#include <glm/glm.hpp>
#include "AppConfig.h"
#include "BuiltinPrimitives.h"
#include "Material.h"
#include "MathUtils.h"
#include "SceneConfig.h"
namespace examples::post_processing_effects::exposure_and_adaptation::histogram_based_auto_exposure
{
inline const std::vector enabledMaterialComponents{
common::scene::MaterialComponent::ALBEDO_COLOR_VEC4, common::scene::MaterialComponent::ROUGHNESS_FLOAT,
common::scene::MaterialComponent::METALLIC_FLOAT, common::scene::MaterialComponent::UV_SCALE_FLOAT,
common::scene::MaterialComponent::ALBEDO_MAP_TEXTURE, common::scene::MaterialComponent::ROUGHNESS_MAP_TEXTURE,
common::scene::MaterialComponent::METALLIC_MAP_TEXTURE, common::scene::MaterialComponent::NORMAL_MAP_TEXTURE};
inline const std::vector attributeLayouts{
std::pair(common::scene::AttributeType::POSITION, common::scene::AccessorType::VEC3),
std::pair(common::scene::AttributeType::TEXCOORD, common::scene::AccessorType::VEC2),
std::pair(common::scene::AttributeType::NORMAL, common::scene::AccessorType::VEC3),
std::pair(common::scene::AttributeType::TANGENT, common::scene::AccessorType::VEC4)};
enum class ToneMappingMode : std::uint32_t
{
REINHARD = 0U, // Simple Reinhard (Default)
ACES, // ACES (Narkowicz fit)
UCHIMURA, // Uchimura (Gran Turismo style)
AGX // AgX (fast approximation)
};
// Constants
inline constexpr auto kAutoExposureKeyValue = 0.18f;
inline constexpr auto kAutoExposureMinEv = -8.0f;
inline constexpr auto kAutoExposureMaxEv = 8.0f;
inline constexpr auto kHistogramThreadCount = 16U;
inline constexpr auto kHistogramBinCount = 256U;
inline constexpr auto kHistogramMinLogLuminance = -10.0f;
inline constexpr auto kHistogramMaxLogLuminance = 8.0f;
inline constexpr auto kHistogramLowPercentile = 0.1f;
inline constexpr auto kHistogramHighPercentile = 0.9f;
struct alignas(16) PointLightGpuData
{
glm::vec4 lightPosition; // xyz = Light Position (View-Space)
glm::vec4 lightColorIntensity; // xyz = Light Color, w = Color Intensity
};
struct alignas(16) AutoExposureGpuData
{
float averageLuminance;
float exposureEv;
};
struct MeshPushConstants
{
glm::mat4 view;
glm::mat4 projection;
std::uint32_t objectId;
};
struct LightingPushConstants
{
std::uint32_t lightCount;
};
struct AutoExposurePushConstants
{
float minLogLuminance;
float logLuminanceRange;
float lowPercentile;
float highPercentile;
float keyValue;
float minExposureEv;
float maxExposureEv;
};
struct ToneMappingPushConstants
{
std::uint32_t toneMappingMode;
};
struct TextureAssetDesc
{
std::string textureName;
std::string texturePath;
VkFormat format = VK_FORMAT_R8G8B8A8_SRGB;
};
struct MaterialDesc
{
std::string materialName;
glm::vec4 albedoColor = glm::vec4(1.0f);
std::string albedoTextureName;
float roughness = 0.5f;
std::string roughnessTextureName;
float metallic = 0.5f;
std::string metallicTextureName;
std::string normalTextureName;
float uvScale = 1.0f;
};
struct SceneObjectDesc
{
common::scene::BuiltinMeshType meshType;
glm::vec3 position;
glm::vec3 eulerAngles;
glm::vec3 scale;
std::string materialName;
};
// All textures in the scene
// clang-format off
inline const std::vector<TextureAssetDesc> textureAssets{
{constants::kFloorTexture, constants::kFloorTexturePath},
{constants::kFloorNormalTexture, constants::kFloorNormalTexturePath, VK_FORMAT_R8G8B8A8_UNORM},
{constants::kFloorRoughnessTexture, constants::kFloorRoughnessTexturePath, VK_FORMAT_R8G8B8A8_UNORM},
{constants::kMetalDamagedAlbedoTexture, constants::kMetalDamagedAlbedoTexturePath},
{constants::kMetalDamagedNormalTexture, constants::kMetalDamagedNormalTexturePath, VK_FORMAT_R8G8B8A8_UNORM},
{constants::kMetalDamagedRoughnessTexture, constants::kMetalDamagedRoughnessTexturePath, VK_FORMAT_R8G8B8A8_UNORM},
{constants::kMetalDamagedMetallicTexture, constants::kMetalDamagedMetallicTexturePath, VK_FORMAT_R8G8B8A8_UNORM}
};
// clang-format on
// All materials in the scene
// clang-format off
inline const std::vector<MaterialDesc> materials{
{constants::kFloorMaterial, glm::vec4(1.0f), constants::kFloorTexture,
1.0f, constants::kFloorRoughnessTexture, 0.0f, "", constants::kFloorNormalTexture, 5.0f},
{constants::kGreenWallMaterial, glm::vec4(0.0f, 1.0f, 0.0f, 1.0f), "",
0.5f, "", 0.0f, ""},
{constants::kRedWallMaterial, glm::vec4(1.0f, 0.0f, 0.0f, 1.0f), "",
0.5f, "", 0.0f, ""},
{constants::kWhiteWallMaterial, glm::vec4(1.0f), "",
0.5f, "", 0.0f, ""},
{constants::kMetalDamagedMaterial, glm::vec4(1.0f), constants::kMetalDamagedAlbedoTexture,
0.5f, constants::kMetalDamagedRoughnessTexture, 0.5f, constants::kMetalDamagedMetallicTexture, constants::kMetalDamagedNormalTexture, 2.0f},
{constants::kRedMaterial, glm::vec4(1.0f, 0.0f, 0.0f, 1.0f), "", 0.15f, "", 0.0f, "", "", 1.0f},
{constants::kGreenMaterial, glm::vec4(0.0f, 1.0f, 0.0f, 1.0f), "", 0.35f, "", 0.25f, "", "", 1.0f},
{constants::kBlueMaterial, glm::vec4(0.0f, 0.0f, 1.0f, 1.0f), "", 0.55f, "", 0.5f, "", "", 1.0f},
{constants::kYellowMaterial, glm::vec4(1.0f, 1.0f, 0.0f, 1.0f), "", 0.70f, "", 0.75f, "", "", 1.0f},
{constants::kMagentaMaterial, glm::vec4(1.0f, 0.0f, 1.0f, 1.0f), "", 0.85f, "", 1.0f, "", "", 1.0f},
{constants::kCyanMaterial, glm::vec4(0.0f, 1.0f, 1.0f, 1.0f), "", 0.35f, "", 0.9f, "", "", 1.0f},
// HDR Test grid materials
{"HdrGridMat_R05_M1", glm::vec4(1.0f), "", 0.05f, "", 1.0f, "", "", 1.0f},
{"HdrGridMat_R20_M0", glm::vec4(1.0f), "", 0.20f, "", 0.0f, "", "", 1.0f},
{"HdrGridMat_R35_M1", glm::vec4(1.0f), "", 0.35f, "", 1.0f, "", "", 1.0f},
{"HdrGridMat_R50_M0", glm::vec4(1.0f), "", 0.50f, "", 0.0f, "", "", 1.0f},
{"HdrGridMat_R65_M1", glm::vec4(1.0f), "", 0.65f, "", 1.0f, "", "", 1.0f},
{"HdrGridMat_R80_M0", glm::vec4(1.0f), "", 0.80f, "", 0.0f, "", "", 1.0f},
{"HdrGridMat_R95_M1", glm::vec4(1.0f), "", 0.95f, "", 1.0f, "", "", 1.0f},
{"HdrGridMat_R05_M0", glm::vec4(1.0f), "", 0.05f, "", 0.0f, "", "", 1.0f}
};
// clang-format on
// Point lights in the scene (should be converted to the view-space)
// clang-format off
inline const std::vector<PointLightGpuData> pointLights{
// Dark room
{glm::vec4{0.0f, 7.0f, 12.0f, 1.0f}, glm::vec4{1.0f, 0.85f, 0.65f, 8.0f}},
{glm::vec4{-6.5f, 1.8f, 17.5f, 1.0f}, glm::vec4{1.0f, 0.6f, 0.3f, 2.5f}},
// Bright room
{glm::vec4{0.0f, 5.0f, -12.0f, 1.0f}, glm::vec4{1.0f, 0.97f, 0.92f, 600.0f}},
{glm::vec4{-5.0f, 5.0f, -17.5f, 1.0f}, glm::vec4{0.9f, 0.95f, 1.0f, 250.0f}},
{glm::vec4{5.0f, 5.0f, -17.0f, 1.0f}, glm::vec4{0.9f, 0.95f, 1.0f, 250.0f}}
};
// clang-format on
// Room parts (floor and three walls)
// clang-format off
inline const std::vector<SceneObjectDesc> roomParts{
// Floors
{common::scene::BuiltinMeshType::CUBE, glm::vec3(0.0f, -0.25f, 10.0f), glm::vec3(0.0f), glm::vec3(16.5f, 0.5f, 20.0f), constants::kFloorMaterial},
{common::scene::BuiltinMeshType::CUBE, glm::vec3(0.0f, -0.25f, -10.0f), glm::vec3(0.0f), glm::vec3(16.5f, 0.5f, 20.0f), constants::kFloorMaterial},
// Ceiling
{common::scene::BuiltinMeshType::CUBE, glm::vec3(0.0f, 8.25f, 0.0f), glm::vec3(0.0f), glm::vec3(16.5f, 0.5f, 41.0f), constants::kWhiteWallMaterial},
// Dark room walls (left, right, front)
{common::scene::BuiltinMeshType::CUBE, glm::vec3(-8.25f, 4.0f, 10.0f), glm::vec3(0.0f), glm::vec3(0.5f, 8.0f, 20.0f), constants::kGreenWallMaterial},
{common::scene::BuiltinMeshType::CUBE, glm::vec3(8.25f, 4.0f, 10.0f), glm::vec3(0.0f), glm::vec3(0.5f, 8.0f, 20.0f), constants::kRedWallMaterial},
{common::scene::BuiltinMeshType::CUBE, glm::vec3(0.0f, 4.0f, 20.25f), glm::vec3(0.0f), glm::vec3(17.0f, 8.0f, 0.5f), constants::kWhiteWallMaterial},
// Bright room walls (left, right, front)
{common::scene::BuiltinMeshType::CUBE, glm::vec3(-8.25f, 4.0f, -10.0f), glm::vec3(0.0f), glm::vec3(0.5f, 8.0f, 20.0f), constants::kGreenWallMaterial},
{common::scene::BuiltinMeshType::CUBE, glm::vec3(8.25f, 4.0f, -10.0f), glm::vec3(0.0f), glm::vec3(0.5f, 8.0f, 20.0f), constants::kRedWallMaterial},
{common::scene::BuiltinMeshType::CUBE, glm::vec3(0.0f, 4.0f, -20.25f), glm::vec3(0.0f), glm::vec3(17.0f, 8.0f, 0.5f), constants::kWhiteWallMaterial},
// Partition wall with a doorway
{common::scene::BuiltinMeshType::CUBE, glm::vec3(-5.0f, 4.0f, 0.0f), glm::vec3(0.0f), glm::vec3(6.0f, 8.0f, 0.5f), constants::kWhiteWallMaterial},
{common::scene::BuiltinMeshType::CUBE, glm::vec3(5.0f, 4.0f, 0.0f), glm::vec3(0.0f), glm::vec3(6.0f, 8.0f, 0.5f), constants::kWhiteWallMaterial},
{common::scene::BuiltinMeshType::CUBE, glm::vec3(0.0f, 6.5f, 0.0f), glm::vec3(0.0f), glm::vec3(4.0f, 3.0f, 0.5f), constants::kWhiteWallMaterial},
};
// clang-format on
// Objects placed inside the room (mostly close to the walls)
// clang-format off
inline const std::vector<SceneObjectDesc> propObjects{
// Sphere pyramid (in bright room)
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-1.0f, 0.5f, -13.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(0.0f, 0.5f, -13.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(1.0f, 0.5f, -13.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-1.0f, 0.5f, -12.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(0.0f, 0.5f, -12.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(1.0f, 0.5f, -12.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-1.0f, 0.5f, -11.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(0.0f, 0.5f, -11.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(1.0f, 0.5f, -11.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-0.5f, 1.207f, -12.5f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(0.5f, 1.207f, -12.5f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-0.5f, 1.207f, -11.5f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(0.5f, 1.207f, -11.5f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(0.0f, 1.914f, -12.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
// Colored spheres (in bright room)
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-6.25f, 0.8f, -18.8f), glm::vec3(0.0f), glm::vec3(1.6f), constants::kRedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-3.75f, 0.8f, -18.8f), glm::vec3(0.0f), glm::vec3(1.6f), constants::kGreenMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-1.25f, 0.8f, -18.8f), glm::vec3(0.0f), glm::vec3(1.6f), constants::kBlueMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(1.25f, 0.8f, -18.8f), glm::vec3(0.0f), glm::vec3(1.6f), constants::kYellowMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(3.75f, 0.8f, -18.8f), glm::vec3(0.0f), glm::vec3(1.6f), constants::kMagentaMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(6.25f, 0.8f, -18.8f), glm::vec3(0.0f), glm::vec3(1.6f), constants::kCyanMaterial},
// Colored spheres (in dark room)
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-6.25f, 0.8f, 18.8f), glm::vec3(0.0f), glm::vec3(1.6f), constants::kRedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-3.75f, 0.8f, 18.8f), glm::vec3(0.0f), glm::vec3(1.6f), constants::kGreenMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-1.25f, 0.8f, 18.8f), glm::vec3(0.0f), glm::vec3(1.6f), constants::kBlueMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(1.25f, 0.8f, 18.8f), glm::vec3(0.0f), glm::vec3(1.6f), constants::kYellowMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(3.75f, 0.8f, 18.8f), glm::vec3(0.0f), glm::vec3(1.6f), constants::kMagentaMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(6.25f, 0.8f, 18.8f), glm::vec3(0.0f), glm::vec3(1.6f), constants::kCyanMaterial},
// Metal cubes (in dark room)
{common::scene::BuiltinMeshType::CUBE, glm::vec3(-6.8f, 1.0f, 5.0f), glm::vec3(0.0f), glm::vec3(2.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::CUBE, glm::vec3(-6.8f, 1.0f, 9.0f), glm::vec3(0.0f), glm::vec3(2.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::CUBE, glm::vec3(-6.8f, 1.0f, 13.0f), glm::vec3(0.0f), glm::vec3(2.0f), constants::kMetalDamagedMaterial},
// HDR test grid: 8 spheres in front of the right wall, roughness sweeping from 0.05 to 0.95, and metallic changes
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(7.2f, 0.6f, -9.0f), glm::vec3(0.0f), glm::vec3(1.2f), "HdrGridMat_R05_M1"},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(7.2f, 0.6f, -6.5f), glm::vec3(0.0f), glm::vec3(1.2f), "HdrGridMat_R20_M0"},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(7.2f, 0.6f, -4.0f), glm::vec3(0.0f), glm::vec3(1.2f), "HdrGridMat_R35_M1"},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(7.2f, 0.6f, -1.5f), glm::vec3(0.0f), glm::vec3(1.2f), "HdrGridMat_R50_M0"},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(7.2f, 0.6f, 1.5f), glm::vec3(0.0f), glm::vec3(1.2f), "HdrGridMat_R65_M1"},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(7.2f, 0.6f, 4.0f), glm::vec3(0.0f), glm::vec3(1.2f), "HdrGridMat_R80_M0"},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(7.2f, 0.6f, 6.5f), glm::vec3(0.0f), glm::vec3(1.2f), "HdrGridMat_R95_M1"},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(7.2f, 0.6f, 9.0f), glm::vec3(0.0f), glm::vec3(1.2f), "HdrGridMat_R05_M0"},
};
// clang-format on
} // namespace examples::post_processing_effects::exposure_and_adaptation::histogram_based_auto_exposure