Skip to content
Snippets Groups Projects
Commit d7ea5c20 authored by Sebastian Gaida's avatar Sebastian Gaida
Browse files

[#87] add skippedIndice vector

parent 2c47c965
No related branches found
No related tags found
1 merge request!74Resolve "Mesh Shader Implementation"
Pipeline #26544 failed
......@@ -5,6 +5,19 @@
#include <iostream>
namespace vkcv::meshlet {
struct tipsifyResult{
/**
*
* @param indexBuffer new indexBuffer
* @param skippedIndices indices that have a spacial break
*/
tipsifyResult(const std::vector<uint32_t> indexBuffer, const std::vector<uint32_t> skippedIndices)
:indexBuffer(indexBuffer), skippedIndices(skippedIndices) {}
std::vector<uint32_t> indexBuffer;
std::vector<uint32_t> skippedIndices;
};
/**
* reorders the IndexBuffer, so all usages of vertices to triangle are as close as possible
* @param indexBuffer32Bit current IndexBuffer
......@@ -13,9 +26,12 @@ namespace vkcv::meshlet {
* Recommended: 20. Keep the value between 5 and 50 <br>
* low: more random and patchy<br>
* high: closer vertices have higher chance -> leads to sinuous lines
* @return new IndexBuffer that replaces the input IndexBuffer
* @return new IndexBuffer that replaces the input IndexBuffer, and the indices that are skipped
*
* https://gfx.cs.princeton.edu/pubs/Sander_2007_%3ETR/tipsy.pdf
* https://www.martin.st/thesis/efficient_triangle_reordering.pdf
*/
std::vector<uint32_t> tipsifyMesh(
tipsifyResult tipsifyMesh(
const std::vector<uint32_t> &indexBuffer32Bit,
const int vertexCount, const unsigned int cacheSize = 20);
......
......@@ -3,10 +3,11 @@
#include "vkcv/meshlet/Tipsify.hpp"
#include <iostream>
const int maxUsedVertices = 128;
namespace vkcv::meshlet {
const int maxUsedVertices = 128;
std::vector<uint32_t> skippedIndices;
/**
* modulo operation with maxUsedVertices
* @param number for modulo operation
......@@ -47,6 +48,7 @@ namespace vkcv::meshlet {
while (lowestLivingVertexIndex + 1 < vertexCount) {
lowestLivingVertexIndex++;
if (livingTriangles[lowestLivingVertexIndex] > 0) {
skippedIndices.push_back(static_cast<uint32_t>(lowestLivingVertexIndex));
return lowestLivingVertexIndex;
}
}
......@@ -115,14 +117,14 @@ namespace vkcv::meshlet {
return nextVertexIndex;
}
std::vector<uint32_t> tipsifyMesh(
tipsifyResult tipsifyMesh(
const std::vector<uint32_t> &indexBuffer32Bit,
const int vertexCount,
const unsigned int cacheSize) {
if (indexBuffer32Bit.empty() || vertexCount <= 0) {
vkcv_log(LogLevel::ERROR, "Invalid Input.");
return indexBuffer32Bit;
return tipsifyResult(indexBuffer32Bit ,skippedIndices );
}
int triangleCount = indexBuffer32Bit.size() / 3;
......@@ -264,6 +266,6 @@ namespace vkcv::meshlet {
}
}
return reorderedIndexBuffer;
return tipsifyResult(reorderedIndexBuffer, skippedIndices);
}
}
\ No newline at end of file
......@@ -140,10 +140,10 @@ int main(int argc, const char** argv) {
// mesh shader buffers
const auto& assetLoaderIndexBuffer = mesh.vertexGroups[0].indexBuffer;
std::vector<uint32_t> indexBuffer32Bit = vkcv::meshlet::assetLoaderIndicesTo32BitIndices(assetLoaderIndexBuffer.data, assetLoaderIndexBuffer.type);
//std::vector<uint32_t> reorderedIndexBuffer32Bit = vkcv::meshlet::tipsifyMesh(indexBuffer32Bit, interleavedVertices.size());
std::vector<uint32_t> reorderedIndexBuffer32Bit = vkcv::meshlet::forsythReorder(indexBuffer32Bit, interleavedVertices.size());
vkcv::meshlet::tipsifyResult tipsifyResult = vkcv::meshlet::tipsifyMesh(indexBuffer32Bit, interleavedVertices.size());
//std::vector<uint32_t> reorderedIndexBuffer32Bit = vkcv::meshlet::forsythReorder(indexBuffer32Bit, interleavedVertices.size());
const auto meshShaderModelData = createMeshShaderModelData(interleavedVertices, reorderedIndexBuffer32Bit);
const auto meshShaderModelData = createMeshShaderModelData(interleavedVertices, tipsifyResult.indexBuffer);
auto meshShaderVertexBuffer = core.createBuffer<vkcv::meshlet::Vertex>(
vkcv::BufferType::STORAGE,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment