SpiecsEngine
 
Loading...
Searching...
No Matches
MeshPack.cpp
Go to the documentation of this file.
1/**
2* @file MeshPack.cpp.
3* @brief The MeshPack Class Implementation.
4* @author Spices.
5*/
6
7#include "Pchheader.h"
8#include "MeshPack.h"
9#include "Render/Vulkan/VulkanRenderBackend.h"
10#include "Resources/Loader/MeshLoader.h"
11
12namespace Spices {
13
14 void MeshResource::CreateBuffer(const std::string& name)
15 {
17
18 positions .CreateBuffer(name + "PositionsBuffer", VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR);
19 normals .CreateBuffer(name + "NormalsBuffer" );
20 colors .CreateBuffer(name + "ColorsBuffer" );
21 texCoords .CreateBuffer(name + "TexCoordsBuffer" );
22 vertices .CreateBuffer(name + "VerticesBuffer" );
23 primitivePoints .CreateBuffer(name + "PrimitivePointsBuffer", VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_BUILD_INPUT_READ_ONLY_BIT_KHR);
24 primitiveVertices .CreateBuffer(name + "PrimitiveVerticesBuffer" );
25 primitiveLocations .CreateBuffer(name + "PrimitiveLocationsBuffer" );
26 meshlets .CreateBuffer(name + "MeshletsBuffer" );
27 }
28
30 {
32
33 modelAddress = 0;
34 positionsAddress = 0;
35 normalsAddress = 0;
36 colorsAddress = 0;
37 texCoordsAddress = 0;
38 verticesAddress = 0;
39 primitivePointsAddress = 0;
40 primitiveVerticesAddress = 0;
41 primitiveLocationsAddress = 0;
42 materialParameterAddress = 0;
43 meshletsAddress = 0;
44 nMeshlets = 0;
45 entityID = 0;
46
47 m_Buffer = std::make_shared<VulkanBuffer>(
48 VulkanRenderBackend::GetState() ,
49 "MeshDescBuffer" ,
50 sizeof(SpicesShader::MeshDesc) ,
51 VK_BUFFER_USAGE_TRANSFER_SRC_BIT |
52 VK_BUFFER_USAGE_TRANSFER_DST_BIT |
53 VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
54 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
55 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
56 );
57
58 m_Buffer->WriteToBuffer(this);
59 }
60
62 {
64
65 MeshDesc desc;
66 desc.m_Buffer->CopyBuffer(m_Buffer->Get(), desc.m_Buffer->Get(), sizeof(SpicesShader::MeshDesc));
67
68 return desc;
69 }
70
71 uint64_t MeshDesc::GetBufferAddress() const
72 {
74
75 return m_Buffer->GetAddress();
76 }
77
78 MeshPack::MeshPack(const std::string& name, bool instanced)
79 : m_MeshPackName(name)
80 , m_Instanced(instanced)
81 , m_NTasks(0)
82 , m_IsRequiredAccel(false)
83 , m_UUID(UUID())
84 {}
85
86 void MeshPack::OnBind(const VkCommandBuffer& commandBuffer) const
87 {
89
90 const VkBuffer buffers[] = { m_MeshResource.positions.buffer->Get() };
91 constexpr VkDeviceSize offsets[] = { 0 };
92 vkCmdBindVertexBuffers(commandBuffer, 0, 1, buffers, offsets);
93 vkCmdBindIndexBuffer(commandBuffer, m_MeshResource.primitivePoints.buffer->Get(), 0, VK_INDEX_TYPE_UINT32);
94 }
95
96 void MeshPack::OnDraw(const VkCommandBuffer& commandBuffer) const
97 {
99
100 int lodLevel = 0;
101 const auto ptr = m_Material->GetConstantParams().find_value("lod");
102 if (ptr)
103 {
104 lodLevel = std::any_cast<int>(ptr->value.paramValue);
105 lodLevel = std::max(lodLevel, 0);
106 lodLevel = std::min(lodLevel, (int)m_MeshResource.lods.attributes->size() - 1);
107 }
108 const Lod& lod0 = (*m_MeshResource.lods.attributes)[lodLevel];
109 vkCmdDrawIndexed(commandBuffer, lod0.nPrimitives * 3, 1, lod0.primVertexOffset * 3, 0, 0);
110 }
111
112 void MeshPack::OnDrawMeshTasks(const VkCommandBuffer& commandBuffer) const
113 {
115
116 VulkanRenderBackend::GetState().m_VkFunc.vkCmdDrawMeshTasksEXT(commandBuffer, m_NTasks, 1, 1);
117 }
118
119 bool MeshPack::OnCreatePack(bool isCreateBuffer)
120 {
122
123 if (m_Instanced || !ResourcePool<MeshPack>::Has(m_MeshPackName)) return false;
124
125 auto ptr = ResourcePool<MeshPack>::Access(m_MeshPackName);
126
127 /**
128 * @brief Copy Data from ResourcePool.
129 */
130 m_Desc = ptr->m_Desc.Copy();
131 m_MeshResource = ptr->m_MeshResource;
132 m_NTasks = ptr->m_NTasks;
133 m_MeshTaskIndirectDrawCommand = ptr->m_MeshTaskIndirectDrawCommand;
134 m_Accel = ptr->m_Accel;
135 m_IsRequiredAccel = ptr->m_IsRequiredAccel.load();
136
137 if (m_Material)
138 {
139 m_Desc.UpdatematerialParameterAddress(m_Material->GetMaterialParamsAddress());
140 }
141
142 return true;
143 }
144
145 void MeshPack::SetMaterial(const std::string& materialPath)
146 {
148
149 m_Material = ResourcePool<Material>::Load<Material>(materialPath, materialPath);
150 m_Material->BuildMaterial();
151
152 m_Desc.UpdatematerialParameterAddress(m_Material->GetMaterialParamsAddress());
153 }
154
155 void MeshPack::SetMaterial(std::shared_ptr<Material> material)
156 {
158
159 m_Material = material;
160 m_Material->BuildMaterial();
161
162 m_Desc.UpdatematerialParameterAddress(material->GetMaterialParamsAddress());
163 }
164
165 uint32_t MeshPack::GetHitShaderHandle() const
166 {
168
169 if(!m_HitShaderHandle.has_value())
170 {
171 std::stringstream ss;
172 ss << "MeshPack do not has a valid material handle.";
173
174 SPICES_CORE_ERROR(ss.str())
175 }
176
177 return m_HitShaderHandle.value().load();
178 }
179
181 {
183
184 if (!m_ShaderGroupHandle.has_value())
185 {
186 std::stringstream ss;
187 ss << "MeshPack do not has a valid material handle.";
188
189 SPICES_CORE_ERROR(ss.str())
190 }
191
192 return m_ShaderGroupHandle.value().load();
193 }
194
196 {
198
199 /**
200 * @brief BLAS builder requires raw device addresses.
201 */
202 const VkDeviceAddress vertexAddress = m_MeshResource.positions.buffer->GetAddress();
203 const VkDeviceAddress indicesAddress = m_MeshResource.primitivePoints.buffer->GetAddress();
204
205 const Lod& lod0 = (*m_MeshResource.lods.attributes)[0];
206 const uint32_t maxPrimitiveCount = lod0.nPrimitives;
207
208 /**
209 * @brief device pointer to the buffers holding triangle vertex/index data,
210 * along with information for interpreting it as an array (stride, data type, etc.)
211 */
212 VkAccelerationStructureGeometryTrianglesDataKHR triangles {};
213 triangles.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR;
214 triangles.vertexFormat = VK_FORMAT_R32G32B32_SFLOAT; // vec3 vertex position data.
215 triangles.vertexData.deviceAddress = vertexAddress; /* @note position needs to be the first attribute of Vertex, otherwise correct offset is needs to be added here. */
216 triangles.vertexStride = sizeof(glm::vec3);
217 triangles.indexType = VK_INDEX_TYPE_UINT32;
218 triangles.indexData.deviceAddress = indicesAddress;
219 //triangles.transformData = {};
220 triangles.maxVertex = static_cast<uint32_t>(m_MeshResource.primitivePoints.buffer->GetSize() / sizeof(glm::uvec3) * 3 - 1);
221
222 /**
223 * @brief wrapper around the above with the geometry type enum (triangles in this case) plus flags for the AS builder.
224 */
225 VkAccelerationStructureGeometryKHR asGeom {};
226 asGeom.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_KHR;
227 asGeom.geometryType = VK_GEOMETRY_TYPE_TRIANGLES_KHR;
228 asGeom.flags = VK_GEOMETRY_OPAQUE_BIT_KHR;
229 asGeom.geometry.triangles = triangles;
230
231 /**
232 * @brief the indices within the vertex arrays to source input geometry for the BLAS.
233 */
234 VkAccelerationStructureBuildRangeInfoKHR offset {};
235 offset.firstVertex = 0;
236 offset.primitiveCount = maxPrimitiveCount;
237 offset.primitiveOffset = lod0.primVertexOffset;
238 offset.transformOffset = 0;
239
240 /**
241 * @brief Our blas is made from only one geometry, but could be made of many geometries.
242 */
243 VulkanRayTracing::BlasInput input;
244 input.asGeometry.emplace_back(asGeom);
245 input.asBuildOffsetInfo.emplace_back(offset);
246 input.accel = &m_Accel;
247
248 return input;
249 }
250
252 {
254
255 if(m_IsRequiredAccel) return true;
256
257 m_IsRequiredAccel = true;
258 return false;
259 }
260
262 {
264
265 if(!m_IsRequiredAccel)
266 {
267 SPICES_CORE_ERROR("Can not access accel before require it.")
268 }
269
270 if(!m_Accel.accel)
271 {
272 SPICES_CORE_ERROR("Can not access accel before build it.")
273 }
274
275 return m_Accel;
276 }
277
279 {
281
282 m_NTasks = m_MeshResource.meshlets.attributes->size() / SpicesShader::SUBGROUP_SIZE + 1;
283 m_MeshTaskIndirectDrawCommand.firstTask = 0;
284 m_MeshTaskIndirectDrawCommand.taskCount = m_NTasks;
285
286 m_MeshResource.CreateBuffer(m_MeshPackName);
287
288 m_Desc.UpdatepositionsAddress (m_MeshResource.positions.buffer );
289 m_Desc.UpdatenormalsAddress (m_MeshResource.normals.buffer );
290 m_Desc.UpdatecolorsAddress (m_MeshResource.colors.buffer );
291 m_Desc.UpdatetexCoordsAddress (m_MeshResource.texCoords.buffer );
292 m_Desc.UpdateverticesAddress (m_MeshResource.vertices.buffer );
293 m_Desc.UpdateprimitivePointsAddress (m_MeshResource.primitivePoints.buffer );
294 m_Desc.UpdateprimitiveVerticesAddress (m_MeshResource.primitiveVertices.buffer );
295 m_Desc.UpdateprimitiveLocationsAddress (m_MeshResource.primitiveLocations.buffer );
296 m_Desc.UpdatemeshletsAddress (m_MeshResource.meshlets.buffer );
297 m_Desc.UpdatenMeshlets (m_MeshResource.meshlets.attributes ->size());
298
299#if 1
300
301 m_MeshResource.positions.attributes = nullptr;
302 m_MeshResource.normals.attributes = nullptr;
303 m_MeshResource.colors.attributes = nullptr;
304 m_MeshResource.texCoords.attributes = nullptr;
305 m_MeshResource.vertices.attributes = nullptr;
306 m_MeshResource.primitivePoints.attributes = nullptr;
307 m_MeshResource.primitiveVertices.attributes = nullptr;
308 m_MeshResource.primitiveLocations.attributes = nullptr;
309 m_MeshResource.meshlets.attributes = nullptr;
310
311#endif
312
313 }
314
315 bool PlanePack::OnCreatePack(bool isCreateBuffer)
316 {
318
319 if (MeshPack::OnCreatePack(isCreateBuffer)) return true;
320
321 for (uint32_t i = 0; i < m_Rows; i++)
322 {
323 float rowRamp = i / static_cast<float>(m_Rows - 1) - 0.5f; // -0.5f ~ 0.5f
324
325 for (uint32_t j = 0; j < m_Columns; j++)
326 {
327 const uint32_t vtIndex = i * m_Columns + j;
328 float colRamp = j / static_cast<float>(m_Columns - 1) - 0.5f; // -0.5f ~ 0.5f
329
330 m_MeshResource.positions.attributes->push_back({ colRamp, rowRamp, 0.0f });
331 m_MeshResource.normals .attributes->push_back({ 0.0f, 0.0f, -1.0f });
332 m_MeshResource.colors .attributes->push_back({ 1.0f, 1.0f, 1.0f });
333 m_MeshResource.texCoords.attributes->push_back({ colRamp + 0.5, 0.5 - rowRamp });
334
335 m_MeshResource.vertices .attributes->push_back(glm::uvec4(vtIndex));
336 }
337 }
338
339 for (uint32_t i = 0; i < m_Rows - 1; i++)
340 {
341 for (uint32_t j = 0; j < m_Columns - 1; j++)
342 {
343 const uint32_t vtIndex = i * m_Columns + j;
344
345 m_MeshResource.primitiveVertices.attributes->push_back({ vtIndex, vtIndex + 1, vtIndex + m_Columns + 1 });
346 m_MeshResource.primitiveVertices.attributes->push_back({ vtIndex + m_Columns + 1, vtIndex + m_Columns, vtIndex });
347 }
348 }
349
350 if (isCreateBuffer)
351 {
353 CreateBuffer();
354 }
355
356 return true;
357 }
358
359 bool CubePack::OnCreatePack(bool isCreateBuffer)
360 {
362
363 if (MeshPack::OnCreatePack(isCreateBuffer)) return true;
364
365 auto ApplyMatrixInPositions = [&](auto& positions, const glm::mat4& matrix) {
366
367 for (uint64_t i = 0; i < positions.size(); i++)
368 {
369 glm::vec4 p = matrix * glm::vec4(positions[i], 1.0f);
370 positions[i] = { p.x, p.y, p.z };
371 }
372 };
373
374 auto ApplyMatrixInNormals = [&](auto& normals, const glm::mat4& matrix) {
375
376 for (uint64_t i = 0; i < normals.size(); i++)
377 {
378 glm::vec4 n = matrix * glm::vec4(normals[i], 1.0f);
379 normals[i] = { n.x, n.y, n.z };
380 }
381 };
382
383 auto CopyToVertices = [&](auto& resources) {
384
385 uint64_t nPositions = m_MeshResource.positions.attributes->size();
386 m_MeshResource.positions.attributes->insert(
387 m_MeshResource.positions.attributes->end(),
388 resources.positions.attributes->begin(),
389 resources.positions.attributes->end()
390 );
391
392 uint64_t nNormals = m_MeshResource.normals.attributes->size();
393 m_MeshResource.normals.attributes->insert(
394 m_MeshResource.normals.attributes->end(),
395 resources.normals.attributes->begin(),
396 resources.normals.attributes->end()
397 );
398
399 uint64_t nColors = m_MeshResource.colors.attributes->size();
400 m_MeshResource.colors.attributes->insert(
401 m_MeshResource.colors.attributes->end(),
402 resources.colors.attributes->begin(),
403 resources.colors.attributes->end()
404 );
405
406 uint64_t nTexCoords = m_MeshResource.texCoords.attributes->size();
407 m_MeshResource.texCoords.attributes->insert(
408 m_MeshResource.texCoords.attributes->end(),
409 resources.texCoords.attributes->begin(),
410 resources.texCoords.attributes->end()
411 );
412
413 uint64_t nVertices = m_MeshResource.vertices.attributes->size();
414 for (auto& vertex : *resources.vertices.attributes)
415 {
416 m_MeshResource.vertices.attributes->push_back({
417 vertex.x + nPositions ,
418 vertex.y + nNormals ,
419 vertex.z + nColors ,
420 vertex.w + nTexCoords
421 });
422 }
423
424 uint64_t nPrimVertices = m_MeshResource.primitiveVertices.attributes->size();
425 for (auto& primitiveVertex : *resources.primitiveVertices.attributes)
426 {
427 m_MeshResource.primitiveVertices.attributes->push_back({
428 primitiveVertex.x + nVertices,
429 primitiveVertex.y + nVertices,
430 primitiveVertex.z + nVertices
431 });
432 }
433 };
434
435 // Front
436 {
438 pack.OnCreatePack(false);
439 const glm::mat4 tran = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, -0.5f));
440
441 auto& resources = pack.GetResource();
442
443 const auto positions = resources.positions.attributes;
444 ApplyMatrixInPositions(*positions, tran);
445
446 const auto normals = resources.normals.attributes;
447 ApplyMatrixInNormals(*normals, tran);
448
449 CopyToVertices(resources);
450 }
451
452 // Back
453 {
455 pack.OnCreatePack(false);
456 const glm::mat4 tran = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.0f, 0.5f));
457 const glm::mat4 rot = glm::toMat4(glm::quat({0.0f, glm::radians(180.0f), 0.0f}));
458
459 auto& resources = pack.GetResource();
460
461 const auto positions = resources.positions.attributes;
462 ApplyMatrixInPositions(*positions, tran * rot);
463
464 const auto normals = resources.normals.attributes;
465 ApplyMatrixInNormals(*normals, tran * rot);
466
467 CopyToVertices(resources);
468 }
469
470 // Left
471 {
473 pack.OnCreatePack(false);
474 const glm::mat4 tran = glm::translate(glm::mat4(1.0f), glm::vec3(0.5f, 0.0f, 0.0f));
475 const glm::mat4 rot = glm::toMat4(glm::quat({ 0.0f, glm::radians(-90.0f), 0.0f }));
476
477 auto& resources = pack.GetResource();
478
479 const auto positions = resources.positions.attributes;
480 ApplyMatrixInPositions(*positions, tran * rot);
481
482 const auto normals = resources.normals.attributes;
483 ApplyMatrixInNormals(*normals, tran * rot);
484
485 CopyToVertices(resources);
486 }
487
488 // Right
489 {
491 pack.OnCreatePack(false);
492 const glm::mat4 tran = glm::translate(glm::mat4(1.0f), glm::vec3(-0.5f, 0.0f, 0.0f));
493 const glm::mat4 rot = glm::toMat4(glm::quat({ 0.0f, glm::radians(90.0f), 0.0f }));
494
495 auto& resources = pack.GetResource();
496
497 const auto positions = resources.positions.attributes;
498 ApplyMatrixInPositions(*positions, tran * rot);
499
500 const auto normals = resources.normals.attributes;
501 ApplyMatrixInNormals(*normals, tran * rot);
502
503 CopyToVertices(resources);
504 }
505
506 // Top
507 {
509 pack.OnCreatePack(false);
510 const glm::mat4 tran = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, -0.5f, 0.0f));
511 const glm::mat4 rot = glm::toMat4(glm::quat({ glm::radians(-90.0f), 0.0f, 0.0f }));
512
513 auto& resources = pack.GetResource();
514
515 const auto positions = resources.positions.attributes;
516 ApplyMatrixInPositions(*positions, tran * rot);
517
518 const auto normals = resources.normals.attributes;
519 ApplyMatrixInNormals(*normals, tran * rot);
520
521 CopyToVertices(resources);
522 }
523
524 // Button
525 {
527 pack.OnCreatePack(false);
528 const glm::mat4 tran = glm::translate(glm::mat4(1.0f), glm::vec3(0.0f, 0.5f, 0.0f));
529 const glm::mat4 rot = glm::toMat4(glm::quat({ glm::radians(90.0f), 0.0f, 0.0f }));
530
531 auto& resources = pack.GetResource();
532
533 const auto positions = resources.positions.attributes;
534 ApplyMatrixInPositions(*positions, tran * rot);
535
536 const auto normals = resources.normals.attributes;
537 ApplyMatrixInNormals(*normals, tran * rot);
538
539 CopyToVertices(resources);
540 }
541
542 if (isCreateBuffer)
543 {
545 CreateBuffer();
546 }
547
548 return true;
549 }
550
551 bool FilePack::OnCreatePack(bool isCreateBuffer)
552 {
554
555 if (MeshPack::OnCreatePack(isCreateBuffer)) return true;
556
558 if(isCreateBuffer) CreateBuffer();
559
560 return true;
561 }
562
563 bool SpherePack::OnCreatePack(bool isCreateBuffer)
564 {
566
567 if (MeshPack::OnCreatePack(isCreateBuffer)) return true;
568
569 for (uint32_t i = 0; i < m_Rows; i++)
570 {
571 const float rowRamp = i / static_cast<float>(m_Rows - 1) * 180.0f; // 0 ~ 180
572
573 for (uint32_t j = 0; j < m_Columns; j++)
574 {
575 const uint32_t vtIndex = i * m_Columns + j;
576 const float colRamp = j * 360.0f / static_cast<float>(m_Columns - 1); // 0 ~ 360
577
578 glm::vec3 position{ glm::sin(glm::radians(rowRamp)) * glm::sin(glm::radians(colRamp)), glm::cos(glm::radians(rowRamp)), glm::sin(glm::radians(rowRamp)) * glm::cos(glm::radians(colRamp)) };
579
580 m_MeshResource.positions.attributes->push_back(position);
581 m_MeshResource.normals .attributes->push_back(glm::normalize(position));
582 m_MeshResource.colors .attributes->push_back({ 1.0f, 1.0f, 1.0f });
583 m_MeshResource.texCoords.attributes->push_back({ j / static_cast<float>(m_Columns - 1), i / static_cast<float>(m_Rows - 1) });
584
585 m_MeshResource.vertices .attributes->push_back(glm::uvec4(vtIndex));
586 }
587 }
588
589 for (uint32_t i = 0; i < m_Rows - 1; i++)
590 {
591 for (uint32_t j = 0; j < m_Columns - 1; j++)
592 {
593 const uint32_t vtIndex = i * m_Columns + j;
594
595 m_MeshResource.primitiveVertices.attributes->push_back({ vtIndex, vtIndex + 1, vtIndex + m_Columns + 1 });
596 m_MeshResource.primitiveVertices.attributes->push_back({ vtIndex + m_Columns + 1, vtIndex + m_Columns, vtIndex });
597 }
598 }
599
600 if (isCreateBuffer)
601 {
603 CreateBuffer();
604 }
605
606 return true;
607 }
608
609}
#define SPICES_PROFILE_ZONE
virtual bool OnCreatePack(bool isCreateBuffer=true) override
This interface is used for build specific mesh pack data.
Definition MeshPack.cpp:359
uint32_t m_Columns
How much cols number we use.
Definition MeshPack.h:486
uint32_t m_Rows
How much rows number we use.
Definition MeshPack.h:481
CubePack Class. This class defines box type mesh pack.
Definition MeshPack.h:446
virtual bool OnCreatePack(bool isCreateBuffer=true) override
This interface is used for build specific mesh pack data.
Definition MeshPack.cpp:551
std::string m_Path
The mesh file path in disk.
Definition MeshPack.h:575
FilePack Class. This class defines file type mesh pack.
Definition MeshPack.h:542
Material Class. This class contains a branch of parameter and shader, also descriptor.
Definition Material.h:62
static bool Load(const std::string &fileName, MeshPack *outMeshPack)
Public called API, it is entrance.
MeshLoader Class. This class only defines static function for load data from mesh file.
Definition MeshLoader.h:48
std::string m_MeshPackName
MeshPack Name.
Definition MeshPack.h:321
void OnDraw(const VkCommandBuffer &commandBuffer) const
Draw indexed.
Definition MeshPack.cpp:96
virtual bool OnCreatePack(bool isCreateBuffer=true)
This interface is used for build specific mesh pack data.
Definition MeshPack.cpp:119
uint32_t GetShaderGroupHandle() const
Get ShaderGroup Handle, which accessed by gdc buffer.
Definition MeshPack.cpp:180
void OnDrawMeshTasks(const VkCommandBuffer &commandBuffer) const
Draw Mesh Tasks.
Definition MeshPack.cpp:112
uint32_t GetHitShaderHandle() const
Get Hit Shader Handle, which accessed by ray gen shader.
Definition MeshPack.cpp:165
MeshPack(const std::string &name, bool instanced)
Constructor Function.
Definition MeshPack.cpp:78
bool HasBlasAccel()
Is this meshPack has a valid blas.
Definition MeshPack.cpp:251
void CreateBuffer()
Create Vertices buffer anf Indices buffer.
Definition MeshPack.cpp:278
VulkanRayTracing::BlasInput MeshPackToVkGeometryKHR()
Convert MeshPack into the ray tracing geometry used to build the BLAS.
Definition MeshPack.cpp:195
void OnBind(const VkCommandBuffer &commandBuffer) const
Bind VBO and EBO.
Definition MeshPack.cpp:86
void SetMaterial(std::shared_ptr< Material > material)
Set specific material for this class.
Definition MeshPack.cpp:155
const MeshResource & GetResource() const
Get Resource.
Definition MeshPack.h:307
void SetMaterial(const std::string &materialPath)
Set specific material for this class.
Definition MeshPack.cpp:145
uint32_t m_NTasks
Task Shader Work Group Size.
Definition MeshPack.h:336
UUID m_UUID
UUID for mesh pack.
Definition MeshPack.h:378
bool m_Instanced
If this mesh pack needs instanced.
Definition MeshPack.h:326
AccelKHR & GetAccel()
Get this accel.
Definition MeshPack.cpp:261
MeshPack Class. This class defines some basic behaves and variables. This class need to be inherited ...
Definition MeshPack.h:156
static void GenerateMeshLodClusterHierarchy(MeshPack *meshPack)
Generate Mesh Lod Resources.
Class for provide functions of process Meshpack.
uint32_t m_Columns
How much cols number we use.
Definition MeshPack.h:437
uint32_t m_Rows
How much rows number we use.
Definition MeshPack.h:432
virtual bool OnCreatePack(bool isCreateBuffer=true) override
This interface is used for build specific mesh pack data.
Definition MeshPack.cpp:315
PlanePack(uint32_t rows=2, uint32_t columns=2, bool instanced=true)
Constructor Function. Init member variables.
Definition MeshPack.h:407
PlanePack Class. This class defines plane type mesh pack.
Definition MeshPack.h:397
uint32_t m_Rows
How much rows number we use.
Definition MeshPack.h:529
virtual bool OnCreatePack(bool isCreateBuffer=true) override
This interface is used for build specific mesh pack data.
Definition MeshPack.cpp:563
uint32_t m_Columns
How much cols number we use.
Definition MeshPack.h:534
SpherePack Class. This class defines sphere type mesh pack.
Definition MeshPack.h:494
UUID()
Constructor Function.
Definition UUID.cpp:18
This class helps to generate a uuid for one resource.
Definition UUID.h:16
AccelStructure Wrapper.
Definition Attribute.h:17
uint32_t nPrimitives
Definition MeshPack.h:30
Lod Data.
Definition MeshPack.h:28
MeshDesc()
Constructor Function.
Definition MeshPack.cpp:29
MeshDesc Copy() const
Copy a MeshDesc from this.
Definition MeshPack.cpp:61
uint64_t GetBufferAddress() const
Get m_Buffer's Address.
Definition MeshPack.cpp:71
Add Construction Functions to SpicesShader::MeshDesc.
Definition MeshPack.h:90
void CreateBuffer(const std::string &name)
Create MeshResource Buffers.
Definition MeshPack.cpp:14
Mesh Resources Data.
Definition MeshPack.h:39