Repository navigation
Expand file tree
/
Copy pathApplicationData.h
More file actions
209 lines (186 loc) · 12.1 KB
/
Copy pathApplicationData.h
File metadata and controls
209 lines (186 loc) · 12.1 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
/**
* @file ApplicationData.h
* @brief This header file keeps user-provided application data (vertices, indices etc.).
* @author Mustafa Yemural (myemural)
* @date 16.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::color_processing_tone_mapping::hdr_tone_mapping
{
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
{
OFF = 0U, // Off (raw exposed HDR, clamped to [0,1] by the render target)
REINHARD, // Reinhard (simple)
ACES, // ACES (Narkowicz fit)
UCHIMURA, // Uchimura (Gran Turismo style)
AGX, // AgX (fast approximation)
PARAMETRIC_FILMIC // Parametric Filmic (Hable / Uncharted2 style)
};
struct alignas(16) PointLightGpuData
{
glm::vec4 lightPosition; // xyz = Light Position (View-Space)
glm::vec4 lightColorIntensity; // xyz = Light Color, w = Color Intensity
};
struct MeshPushConstants
{
glm::mat4 view;
glm::mat4 projection;
std::uint32_t objectId;
};
struct LightingPushConstants
{
std::uint32_t lightCount;
};
struct ToneMappingPushConstants
{
float exposure;
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{
{glm::vec4{-10.5f, 4.0f, 10.5f, 1.0f}, glm::vec4{0.55f, 0.7f, 1.0f, 18.0f}}, // Front-left corner, cool color
{glm::vec4{10.5f, 4.0f, 10.5f, 1.0f}, glm::vec4{1.0f, 0.6f, 0.3f, 18.0f}}, // Front-right corner, warm color
{glm::vec4{-10.5f, 4.0f, -10.5f, 1.0f}, glm::vec4{0.8f, 0.85f, 1.0f, 5.0f}}, // Back-left corner, dim
{glm::vec4{10.5f, 4.0f, -10.5f, 1.0f}, glm::vec4{1.0f, 1.0f, 0.9f, 60.0f}}, // Back-right corner, bright
{glm::vec4{0.0f, 6.5f, -1.5f, 1.0f}, glm::vec4{1.0f, 0.95f, 0.85f, 320.0f}} // Center, high above the sphere pyramid
};
// clang-format on
// Room parts (floor and three walls)
// clang-format off
inline const std::vector<SceneObjectDesc> roomParts{
{common::scene::BuiltinMeshType::CUBE, glm::vec3(0.0f, -0.25f, 0.0f), glm::vec3(0.0f), glm::vec3(24.0f, 0.5f, 24.0f), constants::kFloorMaterial},
{common::scene::BuiltinMeshType::CUBE, glm::vec3(0.0f, 5.0f, -12.25f), glm::vec3(0.0f), glm::vec3(24.5f, 10.0f, 0.5f), constants::kWhiteWallMaterial},
{common::scene::BuiltinMeshType::CUBE, glm::vec3(-12.25f, 5.0f, 0.0f), glm::vec3(0.0f), glm::vec3(0.5f, 10.0f, 24.5f), constants::kGreenWallMaterial},
{common::scene::BuiltinMeshType::CUBE, glm::vec3(12.25f, 5.0f, 0.0f), glm::vec3(0.0f), glm::vec3(0.5f, 10.0f, 24.5f), constants::kRedWallMaterial}
};
// 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 the middle of the room
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-1.0f, 0.5f, -3.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(0.0f, 0.5f, -3.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(1.0f, 0.5f, -3.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-1.0f, 0.5f, -2.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(0.0f, 0.5f, -2.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(1.0f, 0.5f, -2.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-1.0f, 0.5f, -1.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(0.0f, 0.5f, -1.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(1.0f, 0.5f, -1.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-0.5f, 1.207f, -2.5f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(0.5f, 1.207f, -2.5f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-0.5f, 1.207f, -1.5f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(0.5f, 1.207f, -1.5f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(0.0f, 1.914f, -2.0f), glm::vec3(0.0f), glm::vec3(1.0f), constants::kMetalDamagedMaterial},
// Six spheres in front of the back wall - spread wider across the larger wall
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-10.0f, 1.0f, -10.9f), glm::vec3(0.0f), glm::vec3(2.0f), constants::kRedMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-6.0f, 1.0f, -10.9f), glm::vec3(0.0f), glm::vec3(2.0f), constants::kGreenMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(-2.0f, 1.0f, -10.9f), glm::vec3(0.0f), glm::vec3(2.0f), constants::kBlueMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(2.0f, 1.0f, -10.9f), glm::vec3(0.0f), glm::vec3(2.0f), constants::kYellowMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(6.0f, 1.0f, -10.9f), glm::vec3(0.0f), glm::vec3(2.0f), constants::kMagentaMaterial},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(10.0f, 1.0f, -10.9f), glm::vec3(0.0f), glm::vec3(2.0f), constants::kCyanMaterial},
// Three cubes in front of the left wall - spread further apart along the wall
{common::scene::BuiltinMeshType::CUBE, glm::vec3(-10.5f, 1.0f, -5.0f), glm::vec3(0.0f), glm::vec3(2.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::CUBE, glm::vec3(-10.5f, 1.0f, 5.0f), glm::vec3(0.0f), glm::vec3(2.0f), constants::kMetalDamagedMaterial},
{common::scene::BuiltinMeshType::CUBE, glm::vec3(-10.5f, 1.0f, 0.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(10.2f, 1.0f, -9.0f), glm::vec3(0.0f), glm::vec3(1.2f), "HdrGridMat_R05_M1"},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(10.2f, 1.0f, -7.1f), glm::vec3(0.0f), glm::vec3(1.2f), "HdrGridMat_R20_M0"},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(10.2f, 1.0f, -4.3f), glm::vec3(0.0f), glm::vec3(1.2f), "HdrGridMat_R35_M1"},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(10.2f, 1.0f, -1.4f), glm::vec3(0.0f), glm::vec3(1.2f), "HdrGridMat_R50_M0"},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(10.2f, 1.0f, 1.4f), glm::vec3(0.0f), glm::vec3(1.2f), "HdrGridMat_R65_M1"},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(10.2f, 1.0f, 4.3f), glm::vec3(0.0f), glm::vec3(1.2f), "HdrGridMat_R80_M0"},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(10.2f, 1.0f, 7.1f), glm::vec3(0.0f), glm::vec3(1.2f), "HdrGridMat_R95_M1"},
{common::scene::BuiltinMeshType::SPHERE, glm::vec3(10.2f, 1.0f, 9.0f), glm::vec3(0.0f), glm::vec3(1.2f), "HdrGridMat_R05_M0"},
};
// clang-format on
} // namespace examples::post_processing_effects::color_processing_tone_mapping::hdr_tone_mapping