Reverting normal cone introduction
This commit is contained in:
+2
-1
@@ -10,7 +10,8 @@
|
|||||||
"inheritEnvironments": [ "msvc_x64" ],
|
"inheritEnvironments": [ "msvc_x64" ],
|
||||||
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
|
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
|
||||||
"buildRoot": "C:/Users/Dynamitos/Seele/bin/",
|
"buildRoot": "C:/Users/Dynamitos/Seele/bin/",
|
||||||
"installRoot": "C:/Program Files/Seele"
|
"installRoot": "C:/Program Files/Seele",
|
||||||
|
"addressSanitizerEnabled": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Release",
|
"name": "Release",
|
||||||
|
|||||||
@@ -29,18 +29,18 @@ void taskMain(
|
|||||||
localToClip = mul(pViewParams.projectionMatrix, mul(pViewParams.viewMatrix, instance.transformMatrix));
|
localToClip = mul(pViewParams.projectionMatrix, mul(pViewParams.viewMatrix, instance.transformMatrix));
|
||||||
// Left
|
// Left
|
||||||
viewFrustum.sides[0].n = float3(1, 0, 0);
|
viewFrustum.sides[0].n = float3(1, 0, 0);
|
||||||
viewFrustum.sides[0].d = 1;
|
viewFrustum.sides[0].d = -1;
|
||||||
// Right
|
// Right
|
||||||
viewFrustum.sides[1].n = float3(-1, 0, 0);
|
viewFrustum.sides[1].n = float3(-1, 0, 0);
|
||||||
viewFrustum.sides[1].d = 1;
|
viewFrustum.sides[1].d = -1;
|
||||||
// Top
|
// Top
|
||||||
viewFrustum.sides[2].n = float3(0, -1, 0);
|
viewFrustum.sides[2].n = float3(0, -1, 0);
|
||||||
viewFrustum.sides[2].d = 1;
|
viewFrustum.sides[2].d = -1;
|
||||||
// Bottom
|
// Bottom
|
||||||
viewFrustum.sides[3].n = float3(0, 1, 0);
|
viewFrustum.sides[3].n = float3(0, 1, 0);
|
||||||
viewFrustum.sides[3].d = 1;
|
viewFrustum.sides[3].d = -1;
|
||||||
// Base
|
// Base
|
||||||
viewFrustum.basePlane.n = float3(0, 0, 1);
|
viewFrustum.basePlane.n = float3(0, 0, -1);
|
||||||
viewFrustum.basePlane.d = 0;
|
viewFrustum.basePlane.d = 0;
|
||||||
}
|
}
|
||||||
GroupMemoryBarrierWithGroupSync();
|
GroupMemoryBarrierWithGroupSync();
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ struct Frustum
|
|||||||
Plane basePlane;
|
Plane basePlane;
|
||||||
bool pointInside(float3 point)
|
bool pointInside(float3 point)
|
||||||
{
|
{
|
||||||
if (dot(basePlane.n, point) + basePlane.d < 0.0f)
|
if (dot(basePlane.n, point) + basePlane.d > 0.0f)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for(int p = 0; p < 4; ++p)
|
for(int p = 0; p < 4; ++p)
|
||||||
{
|
{
|
||||||
if(dot(sides[p].n, point) + sides[p].d < 0.0f)
|
if(dot(sides[p].n, point) + sides[p].d > 0.0f)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ struct MeshletDescription
|
|||||||
uint32_t primitiveCount;
|
uint32_t primitiveCount;
|
||||||
uint32_t vertexOffset;
|
uint32_t vertexOffset;
|
||||||
uint32_t primitiveOffset;
|
uint32_t primitiveOffset;
|
||||||
float3 color;
|
|
||||||
float pad;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MeshData
|
struct MeshData
|
||||||
@@ -22,8 +20,8 @@ struct MeshData
|
|||||||
uint32_t pad0[3];
|
uint32_t pad0[3];
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint MAX_VERTICES = 64;
|
static const uint MAX_VERTICES = 256;
|
||||||
static const uint MAX_PRIMITIVES = 126;
|
static const uint MAX_PRIMITIVES = 256;
|
||||||
static const uint TASK_GROUP_SIZE = 128;
|
static const uint TASK_GROUP_SIZE = 128;
|
||||||
static const uint MESH_GROUP_SIZE = 32;
|
static const uint MESH_GROUP_SIZE = 32;
|
||||||
static const uint MAX_MESHLETS_PER_MESH = 512;
|
static const uint MAX_MESHLETS_PER_MESH = 512;
|
||||||
|
|||||||
@@ -268,7 +268,11 @@ void MeshLoader::loadGlobalMeshes(const aiScene* scene, const Array<PMaterialIns
|
|||||||
|
|
||||||
Array<Meshlet> meshlets;
|
Array<Meshlet> meshlets;
|
||||||
meshlets.reserve(indices.size() / (3ull * Gfx::numPrimitivesPerMeshlet));
|
meshlets.reserve(indices.size() / (3ull * Gfx::numPrimitivesPerMeshlet));
|
||||||
Meshlet::build(positions, indices, meshlets);
|
Meshlet::build(indices, meshlets);
|
||||||
|
for (auto& meshlet : meshlets)
|
||||||
|
{
|
||||||
|
meshlet.calcBoundingBox(positions);
|
||||||
|
}
|
||||||
vertexData->loadMesh(id, indices, meshlets);
|
vertexData->loadMesh(id, indices, meshlets);
|
||||||
|
|
||||||
collider.physicsMesh.addCollider(positions, indices, Matrix4(1.0f));
|
collider.physicsMesh.addCollider(positions, indices, Matrix4(1.0f));
|
||||||
|
|||||||
@@ -587,8 +587,8 @@ private:
|
|||||||
deallocateArray(_data, arraySize);
|
deallocateArray(_data, arraySize);
|
||||||
_data = tempArray;
|
_data = tempArray;
|
||||||
}
|
}
|
||||||
std::allocator_traits<allocator_type>::construct(allocator, &_data[arraySize++], std::forward<Type>(t));
|
std::allocator_traits<allocator_type>::construct(allocator, &_data[arraySize], std::forward<Type>(t));
|
||||||
return _data[arraySize - 1];
|
return _data[arraySize++];
|
||||||
}
|
}
|
||||||
template<typename Type>
|
template<typename Type>
|
||||||
void resizeInternal(size_type newSize, const Type& value) noexcept
|
void resizeInternal(size_type newSize, const Type& value) noexcept
|
||||||
|
|||||||
@@ -114,7 +114,6 @@ void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet>
|
|||||||
.primitiveCount = m.numPrimitives,
|
.primitiveCount = m.numPrimitives,
|
||||||
.vertexOffset = vertexOffset,
|
.vertexOffset = vertexOffset,
|
||||||
.primitiveOffset = primitiveOffset,
|
.primitiveOffset = primitiveOffset,
|
||||||
.color = Vector((float)rand() / RAND_MAX, (float)rand() / RAND_MAX, (float)rand() / RAND_MAX),
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
meshData[id].add(MeshData{
|
meshData[id].add(MeshData{
|
||||||
@@ -244,70 +243,66 @@ VertexData::VertexData()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void Meshlet::build(const Array<Vector>& positions, const Array<uint32>& indices, Array<Meshlet>& meshlets)
|
void Meshlet::build(const Array<uint32>& indices, Array<Meshlet>& meshlets)
|
||||||
{
|
{
|
||||||
std::set<uint32> uniqueVertices;
|
|
||||||
Meshlet current = {
|
Meshlet current = {
|
||||||
.numVertices = 0,
|
.numVertices = 0,
|
||||||
.numPrimitives = 0,
|
.numPrimitives = 0,
|
||||||
};
|
};
|
||||||
auto insertAndGetIndex = [&positions, &uniqueVertices, ¤t](uint32 index) -> int8_t
|
auto findIndex = [¤t](uint32 index) -> int {
|
||||||
|
for (uint32 i = 0; i < current.numVertices; ++i)
|
||||||
{
|
{
|
||||||
auto [it, inserted] = uniqueVertices.insert(index);
|
if (current.uniqueVertices[i] == index)
|
||||||
if (inserted)
|
|
||||||
{
|
{
|
||||||
if (current.numVertices == Gfx::numVerticesPerMeshlet)
|
return i;
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
current.uniqueVertices[current.numVertices] = index;
|
|
||||||
current.boundingBox.adjust(positions[index]);
|
|
||||||
return current.numVertices++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (uint32 i = 0; i < current.numVertices; ++i)
|
|
||||||
{
|
|
||||||
if (current.uniqueVertices[i] == index)
|
|
||||||
{
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// it could be in unique vertices but not in meshlet vertices
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (current.numVertices == Gfx::numVerticesPerMeshlet)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
current.uniqueVertices[current.numVertices] = index;
|
||||||
|
return current.numVertices++;
|
||||||
};
|
};
|
||||||
auto completeMeshlet = [&meshlets, ¤t, &uniqueVertices]() {
|
auto completeMeshlet = [&meshlets, ¤t]() {
|
||||||
meshlets.add(current);
|
meshlets.add(current);
|
||||||
current = {
|
current = {
|
||||||
.numVertices = 0,
|
.numVertices = 0,
|
||||||
.numPrimitives = 0,
|
.numPrimitives = 0,
|
||||||
};
|
};
|
||||||
uniqueVertices.clear();
|
|
||||||
};
|
};
|
||||||
for (size_t faceIndex = 0; faceIndex < indices.size() / 3; ++faceIndex)
|
for (size_t faceIndex = 0; faceIndex < indices.size() / 3; ++faceIndex)
|
||||||
{
|
{
|
||||||
auto i1 = insertAndGetIndex(indices[faceIndex * 3 + 0]);
|
int f1 = findIndex(indices[faceIndex * 3 + 0]);
|
||||||
auto i2 = insertAndGetIndex(indices[faceIndex * 3 + 1]);
|
int f2 = findIndex(indices[faceIndex * 3 + 1]);
|
||||||
auto i3 = insertAndGetIndex(indices[faceIndex * 3 + 2]);
|
int f3 = findIndex(indices[faceIndex * 3 + 2]);
|
||||||
if (i1 == -1 || i2 == -1 || i3 == -1)
|
|
||||||
|
if (f1 == -1 || f2 == -1 || f1 == -1)
|
||||||
{
|
{
|
||||||
completeMeshlet();
|
completeMeshlet();
|
||||||
i1 = insertAndGetIndex(indices[faceIndex * 3 + 0]);
|
f1 = findIndex(indices[faceIndex * 3 + 0]);
|
||||||
i2 = insertAndGetIndex(indices[faceIndex * 3 + 1]);
|
f2 = findIndex(indices[faceIndex * 3 + 1]);
|
||||||
i3 = insertAndGetIndex(indices[faceIndex * 3 + 2]);
|
f3 = findIndex(indices[faceIndex * 3 + 2]);
|
||||||
}
|
}
|
||||||
current.primitiveLayout[current.numPrimitives * 3 + 0] = i1;
|
current.primitiveLayout[current.numPrimitives * 3 + 0] = uint8(f1);
|
||||||
current.primitiveLayout[current.numPrimitives * 3 + 1] = i2;
|
current.primitiveLayout[current.numPrimitives * 3 + 1] = uint8(f2);
|
||||||
current.primitiveLayout[current.numPrimitives * 3 + 2] = i3;
|
current.primitiveLayout[current.numPrimitives * 3 + 2] = uint8(f3);
|
||||||
current.numPrimitives++;
|
current.numPrimitives++;
|
||||||
if (current.numPrimitives == Gfx::numPrimitivesPerMeshlet)
|
if (current.numPrimitives == Gfx::numPrimitivesPerMeshlet)
|
||||||
{
|
{
|
||||||
completeMeshlet();
|
completeMeshlet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!uniqueVertices.empty())
|
if (current.numVertices > 0)
|
||||||
{
|
{
|
||||||
completeMeshlet();
|
completeMeshlet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Meshlet::calcBoundingBox(const Array<Vector>& positions)
|
||||||
|
{
|
||||||
|
for (uint32 i = 0; i < numVertices; ++i)
|
||||||
|
{
|
||||||
|
boundingBox.adjust(positions[uniqueVertices[i]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -30,7 +30,8 @@ struct Meshlet
|
|||||||
uint8 primitiveLayout[Gfx::numPrimitivesPerMeshlet * 3]; // indices into the uniqueVertices array, only uint8 needed
|
uint8 primitiveLayout[Gfx::numPrimitivesPerMeshlet * 3]; // indices into the uniqueVertices array, only uint8 needed
|
||||||
uint32 numVertices;
|
uint32 numVertices;
|
||||||
uint32 numPrimitives;
|
uint32 numPrimitives;
|
||||||
static void build(const Array<Vector>& positions, const Array<uint32>& indices, Array<Meshlet>& meshlets);
|
static void build(const Array<uint32>& indices, Array<Meshlet>& meshlets);
|
||||||
|
void calcBoundingBox(const Array<Vector>& positions);
|
||||||
};
|
};
|
||||||
class VertexData
|
class VertexData
|
||||||
{
|
{
|
||||||
@@ -98,8 +99,6 @@ protected:
|
|||||||
uint32_t primitiveCount;
|
uint32_t primitiveCount;
|
||||||
uint32_t vertexOffset;
|
uint32_t vertexOffset;
|
||||||
uint32_t primitiveOffset;
|
uint32_t primitiveOffset;
|
||||||
Vector color;
|
|
||||||
float pad0;
|
|
||||||
};
|
};
|
||||||
Map<std::string, MaterialData> materialData;
|
Map<std::string, MaterialData> materialData;
|
||||||
Map<MeshId, Array<MeshData>> meshData;
|
Map<MeshId, Array<MeshData>> meshData;
|
||||||
|
|||||||
Reference in New Issue
Block a user