Basic terrain
This commit is contained in:
Vendored
+1
-1
Submodule external/vcpkg updated: 509f71e53f...4002e5f359
@@ -46,7 +46,7 @@ void taskMain(
|
||||
bounding.minCorner = float3(tile.location.x, tile.height, tile.location.y) * tile.extent;
|
||||
bounding.maxCorner = float3(tile.location.x + 1, tile.height, tile.location.y + 1) * tile.extent;
|
||||
float3 median = (bounding.minCorner + bounding.maxCorner) / 2;
|
||||
float distance = distance(median, pViewParams.cameraPos_WS.xyz);
|
||||
float distance = distance(median, pViewParams.c.cameraPos_WS.xyz);
|
||||
float tileDistance = distance / tile.extent;
|
||||
uint numMeshes = groupID.y + 1;
|
||||
|
||||
|
||||
@@ -111,12 +111,12 @@ void TextureLoader::import(TextureImportArgs args, PTextureAsset textureAsset) {
|
||||
ktxBasisParams basisParams = {
|
||||
.structSize = sizeof(ktxBasisParams),
|
||||
.uastc = true,
|
||||
.threadCount = 1,
|
||||
.uastcFlags = KTX_PACK_UASTC_LEVEL_FASTER,
|
||||
.threadCount = 14,
|
||||
.uastcFlags = KTX_PACK_UASTC_LEVEL_SLOWER,
|
||||
.uastcRDO = true,
|
||||
};
|
||||
KTX_ASSERT(ktxTexture2_CompressBasisEx(kTexture, &basisParams));
|
||||
KTX_ASSERT(ktxTexture2_DeflateZstd(kTexture, 2));
|
||||
KTX_ASSERT(ktxTexture2_DeflateZstd(kTexture, 20));
|
||||
|
||||
char writer[100];
|
||||
snprintf(writer, sizeof(writer), "%s version %s", "SeeleEngine", "0.0.1");
|
||||
|
||||
+23
-20
@@ -55,10 +55,10 @@ int main() {
|
||||
// AssetImporter::importFont(FontImportArgs{
|
||||
// .filePath = "./fonts/Calibri.ttf",
|
||||
// });
|
||||
//AssetImporter::importMesh(MeshImportArgs{
|
||||
// .filePath = sourcePath / "import/models/cube.fbx",
|
||||
//});
|
||||
//AssetImporter::importMesh(MeshImportArgs{
|
||||
AssetImporter::importMesh(MeshImportArgs{
|
||||
.filePath = sourcePath / "import/models/cube.fbx",
|
||||
});
|
||||
// AssetImporter::importMesh(MeshImportArgs{
|
||||
// .filePath = sourcePath / "import/models/culling.fbx",
|
||||
//});
|
||||
AssetImporter::importTexture(TextureImportArgs{
|
||||
@@ -69,22 +69,25 @@ int main() {
|
||||
.filePath = sourcePath / "import/models/ship.fbx",
|
||||
.importPath = "ship",
|
||||
});
|
||||
//AssetImporter::importMesh(MeshImportArgs{
|
||||
// .filePath = sourcePath / "import/models/after-the-rain-vr-sound/source/Whitechapel.glb",
|
||||
// .importPath = "Whitechapel",
|
||||
//});
|
||||
//AssetImporter::importMesh(MeshImportArgs{
|
||||
// .filePath = sourcePath / "import/models/city-suburbs/source/city-suburbs.obj",
|
||||
// .importPath = "suburbs",
|
||||
//});
|
||||
//AssetImporter::importMesh(MeshImportArgs{
|
||||
// .filePath = sourcePath / "import/models/minecraft-medieval-city.fbx",
|
||||
// .importPath = "minecraft",
|
||||
//});
|
||||
//AssetImporter::importMesh(MeshImportArgs{
|
||||
// .filePath = sourcePath / "import/models/Volvo/Volvo.fbx",
|
||||
// .importPath = "Volvo",
|
||||
//});
|
||||
AssetImporter::importTexture(TextureImportArgs{
|
||||
.filePath = sourcePath / "import/textures/azeroth.png",
|
||||
});
|
||||
// AssetImporter::importMesh(MeshImportArgs{
|
||||
// .filePath = sourcePath / "import/models/after-the-rain-vr-sound/source/Whitechapel.glb",
|
||||
// .importPath = "Whitechapel",
|
||||
// });
|
||||
// AssetImporter::importMesh(MeshImportArgs{
|
||||
// .filePath = sourcePath / "import/models/city-suburbs/source/city-suburbs.obj",
|
||||
// .importPath = "suburbs",
|
||||
// });
|
||||
// AssetImporter::importMesh(MeshImportArgs{
|
||||
// .filePath = sourcePath / "import/models/minecraft-medieval-city.fbx",
|
||||
// .importPath = "minecraft",
|
||||
// });
|
||||
// AssetImporter::importMesh(MeshImportArgs{
|
||||
// .filePath = sourcePath / "import/models/Volvo/Volvo.fbx",
|
||||
// .importPath = "Volvo",
|
||||
// });
|
||||
getThreadPool().waitIdle();
|
||||
vd->commitMeshes();
|
||||
WindowCreateInfo mainWindowInfo = {
|
||||
|
||||
@@ -87,7 +87,7 @@ void TerrainRenderer::beginFrame() {
|
||||
|
||||
set = layout->allocateDescriptorSet();
|
||||
set->updateBuffer(0, tilesBuffer);
|
||||
set->updateTexture(1, 0, Gfx::PTexture2D(displacementMap));
|
||||
set->updateTexture(1, Gfx::PTexture2D(displacementMap));
|
||||
set->updateSampler(2, sampler);
|
||||
set->writeChanges();
|
||||
}
|
||||
|
||||
@@ -134,7 +134,7 @@ void StaticMeshVertexData::init(Gfx::PGraphics _graphics) {
|
||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 3, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 4, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
for(uint i = 0; i < MAX_TEXCOORDS; ++i)
|
||||
for(uint32 i = 0; i < MAX_TEXCOORDS; ++i)
|
||||
{
|
||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{
|
||||
.binding = 5 + i,
|
||||
|
||||
@@ -248,27 +248,25 @@ void RenderCommand::bindPipeline(Gfx::PRayTracingPipeline gfxPipeline) {
|
||||
boundResources.add(PBufferAllocation(rtPipeline->miss));
|
||||
}
|
||||
|
||||
void RenderCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet, Array<uint32> dynamicOffsets) {
|
||||
void RenderCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet) {
|
||||
assert(threadId == std::this_thread::get_id());
|
||||
auto descriptor = descriptorSet.cast<DescriptorSet>();
|
||||
assert(descriptor->writeDescriptors.size() == 0);
|
||||
descriptor->bind();
|
||||
boundResources.add(descriptor);
|
||||
for (auto binding : descriptor->boundResources) {
|
||||
for (auto res : binding) {
|
||||
res->bind();
|
||||
boundResources.add(res);
|
||||
}
|
||||
binding->bind();
|
||||
boundResources.add(binding);
|
||||
}
|
||||
|
||||
VkDescriptorSet setHandle = descriptor->getHandle();
|
||||
Gfx::PPipelineLayout layout = pipeline != nullptr ? pipeline->getPipelineLayout() : rtPipeline->getPipelineLayout();
|
||||
vkCmdBindDescriptorSets(handle, pipeline != nullptr ? VK_PIPELINE_BIND_POINT_GRAPHICS : VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR,
|
||||
pipeline->getLayout(), layout->findParameter(descriptorSet->getName()), 1, &setHandle, dynamicOffsets.size(),
|
||||
dynamicOffsets.data());
|
||||
pipeline->getLayout(), layout->findParameter(descriptorSet->getName()), 1, &setHandle, 0,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
void RenderCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorSets, Array<uint32> dynamicOffsets) {
|
||||
void RenderCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorSets) {
|
||||
assert(threadId == std::this_thread::get_id());
|
||||
VkDescriptorSet* sets = new VkDescriptorSet[descriptorSets.size()];
|
||||
std::memset(sets, 0, sizeof(VkDescriptorSet) * descriptorSets.size());
|
||||
@@ -280,19 +278,17 @@ void RenderCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorS
|
||||
boundResources.add(descriptorSet);
|
||||
|
||||
for (auto binding : descriptorSet->boundResources) {
|
||||
for (auto res : binding) {
|
||||
// partially bound descriptors can include nulls
|
||||
if (res != nullptr) {
|
||||
res->bind();
|
||||
boundResources.add(res);
|
||||
}
|
||||
// partially bound descriptors can include nulls
|
||||
if (binding != nullptr) {
|
||||
binding->bind();
|
||||
boundResources.add(binding);
|
||||
}
|
||||
}
|
||||
sets[layout->findParameter(descriptorSet->getName())] = descriptorSet->getHandle();
|
||||
}
|
||||
vkCmdBindDescriptorSets(handle, pipeline != nullptr ? VK_PIPELINE_BIND_POINT_GRAPHICS : VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR,
|
||||
pipeline != nullptr ? pipeline->getLayout() : rtPipeline->getLayout(), 0, (uint32)descriptorSets.size(), sets,
|
||||
dynamicOffsets.size(), dynamicOffsets.data());
|
||||
0, nullptr);
|
||||
delete[] sets;
|
||||
}
|
||||
|
||||
@@ -411,27 +407,26 @@ void ComputeCommand::bindPipeline(Gfx::PComputePipeline computePipeline) {
|
||||
pipeline->bind(handle);
|
||||
}
|
||||
|
||||
void ComputeCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet, Array<uint32> dynamicOffsets) {
|
||||
void ComputeCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet) {
|
||||
assert(threadId == std::this_thread::get_id());
|
||||
auto descriptor = descriptorSet.cast<DescriptorSet>();
|
||||
assert(descriptor->writeDescriptors.size() == 0);
|
||||
descriptor->bind();
|
||||
boundResources.add(descriptor.getHandle());
|
||||
|
||||
for (const auto& binding : descriptor->boundResources) {
|
||||
for (auto res : binding) {
|
||||
res->bind();
|
||||
boundResources.add(res);
|
||||
}
|
||||
for (auto& binding : descriptor->boundResources) {
|
||||
binding->bind();
|
||||
boundResources.add(binding);
|
||||
|
||||
}
|
||||
|
||||
VkDescriptorSet setHandle = descriptor->getHandle();
|
||||
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(),
|
||||
pipeline->getPipelineLayout()->findParameter(descriptorSet->getName()), 1, &setHandle, dynamicOffsets.size(),
|
||||
dynamicOffsets.data());
|
||||
pipeline->getPipelineLayout()->findParameter(descriptorSet->getName()), 1, &setHandle,0,
|
||||
nullptr);
|
||||
}
|
||||
|
||||
void ComputeCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorSets, Array<uint32> dynamicOffsets) {
|
||||
void ComputeCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorSets) {
|
||||
assert(threadId == std::this_thread::get_id());
|
||||
VkDescriptorSet* sets = new VkDescriptorSet[descriptorSets.size()];
|
||||
for (uint32 i = 0; i < descriptorSets.size(); ++i) {
|
||||
@@ -443,15 +438,13 @@ void ComputeCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptor
|
||||
// std::cout << "Binding descriptor " << descriptorSet->getHandle() << " to cmd " << handle << std::endl;
|
||||
|
||||
for (auto binding : descriptorSet->boundResources) {
|
||||
for (auto res : binding) {
|
||||
res->bind();
|
||||
boundResources.add(res);
|
||||
}
|
||||
binding->bind();
|
||||
boundResources.add(binding);
|
||||
}
|
||||
sets[pipeline->getPipelineLayout()->findParameter(descriptorSet->getName())] = descriptorSet->getHandle();
|
||||
}
|
||||
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(), 0, (uint32)descriptorSets.size(), sets,
|
||||
dynamicOffsets.size(), dynamicOffsets.data());
|
||||
0, nullptr);
|
||||
delete[] sets;
|
||||
}
|
||||
|
||||
|
||||
@@ -340,7 +340,7 @@ void DescriptorSet::updateSamplerArray(uint32_t binding, Array<Gfx::PSampler> sa
|
||||
});
|
||||
|
||||
VkDescriptorType descriptorType = VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
|
||||
boundResources[binding][arrayElement] = vulkanSampler->getHandle();
|
||||
boundResources[binding] = vulkanSampler->getHandle();
|
||||
writeDescriptors.add(VkWriteDescriptorSet{
|
||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
.pNext = nullptr,
|
||||
|
||||
Reference in New Issue
Block a user