Works like garbage

This commit is contained in:
Dynamitos
2024-10-22 15:00:39 +02:00
parent 72e60cfe30
commit c7c7e4dd3e
7 changed files with 25 additions and 7 deletions
+4
View File
@@ -32,7 +32,11 @@ VertexOutput vert(VertexInput input)
// Which vertex should be read?
local_vert_id = local_vert_id == 0 ? 2 : (local_vert_id == 2 ? 0 : 1);
float3 positionRWS = pParams.currentVertexBuffer[output.triangleID * 3 + local_vert_id].xyz;
//positionRWS.y = pParams.displacementMap.SampleLevel(pParams.displacementSampler, positionRWS.xz, 0).r;
float2 texCoord = positionRWS.xz / 1000;
positionRWS.y = pParams.displacementMap.SampleLevel(pParams.displacementSampler, texCoord, 0).r * 100;
// Apply the view projection
output.positionCS = mul(pViewParams.projectionMatrix, mul(pViewParams.viewMatrix, float4(positionRWS, 1.0)));
return output;
+5 -1
View File
@@ -86,6 +86,10 @@ struct ComputeParams
// 22
StructuredBuffer<float> lebMatrixCache;
// 23
globallycoherent RWStructuredBuffer<DebugStruct> debugBuffer;
RWStructuredBuffer<DebugStruct> debugBuffer;
// 24
SamplerState displacementSampler;
// 25
Texture2D<float4> displacementMap;
};
ParameterBlock<ComputeParams> pParams;
+6 -6
View File
@@ -106,13 +106,13 @@ int main() {
//AssetImporter::importTexture(TextureImportArgs{
// .filePath = sourcePath / "import/textures/azeroth_height.png",
//});
//AssetImporter::importTexture(TextureImportArgs{
// .filePath = sourcePath / "import/textures/wgen.png",
//});
AssetImporter::importMesh(MeshImportArgs{
.filePath = sourcePath / "import/models/after-the-rain-vr-sound/source/Whitechapel.glb",
.importPath = "Whitechapel",
AssetImporter::importTexture(TextureImportArgs{
.filePath = sourcePath / "import/textures/wgen.png",
});
//AssetImporter::importMesh(MeshImportArgs{
// .filePath = sourcePath / "import/models/after-the-rain-vr-sound/source/Whitechapel.glb",
// .importPath = "Whitechapel",
//});
// AssetImporter::importMesh(MeshImportArgs{521
// .filePath = sourcePath / "import/models/city-suburbs/source/city-suburbs.obj",
// .importPath = "suburbs",
+3
View File
@@ -1,5 +1,6 @@
#include "CBT.h"
#include "Graphics/Shader.h"
#include "Asset/AssetRegistry.h"
using namespace Seele;
@@ -240,6 +241,8 @@ void MeshUpdater::init(Gfx::PGraphics gfx, Gfx::PDescriptorLayout viewParamsLayo
layout->addDescriptorBinding(Gfx::DescriptorBinding{21, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
layout->addDescriptorBinding(Gfx::DescriptorBinding{22, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
layout->addDescriptorBinding(Gfx::DescriptorBinding{23, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
layout->addDescriptorBinding(Gfx::DescriptorBinding{24, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER});
layout->addDescriptorBinding(Gfx::DescriptorBinding{25, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE});
layout->create();
pipelineLayout = graphics->createPipelineLayout("ComputeLayout");
pipelineLayout->addDescriptorLayout(viewParamsLayout);
+2
View File
@@ -30,6 +30,8 @@ constexpr auto MODIFIED_BISECTOR_INDICES = 20;
constexpr auto LEB_POSITION_BUFFER = 21;
constexpr auto LEB_MATRIX_CACHE = 22;
constexpr auto DEBUG_BUFFER = 23;
constexpr auto SAMPLER_LOCATION = 24;
constexpr auto DISPLACEMENT_MAP = 25;
constexpr uint64 WORKGROUP_SIZE = 64;
template <size_t Power> class CBT {
@@ -253,6 +253,8 @@ TerrainRenderer::TerrainRenderer(Gfx::PGraphics graphics, PScene scene, Gfx::PDe
.computeShader = deformCS,
.pipelineLayout = meshUpdater.pipelineLayout,
});
sampler = graphics->createSampler({});
displacementAsset = AssetRegistry::findTexture("", "wgen")->getTexture().cast<Gfx::Texture2D>();
meshUpdater.resetBuffers(plainMesh);
meshUpdater.prepareIndirection(plainMesh, geometryBuffer);
meshUpdater.evaluateLeb(baseMesh, plainMesh, viewParamsSet, geometryBuffer, updateBuffer, lebCache.getLebMatrixBuffer(), true, true);
@@ -273,6 +275,8 @@ Gfx::ORenderCommand TerrainRenderer::render(Gfx::PDescriptorSet viewParamsSet) {
Gfx::PDescriptorSet set = meshUpdater.layout->allocateDescriptorSet();
set->updateBuffer(CURRENT_VERTEX_BUFFER, 0, plainMesh.currentVertexBuffer);
set->updateBuffer(INDEXED_BISECTOR_BUFFER, 0, plainMesh.indexedBisectorBuffer);
set->updateSampler(SAMPLER_LOCATION, 0, sampler);
set->updateTexture(DISPLACEMENT_MAP, 0, displacementAsset);
set->writeChanges();
Gfx::ORenderCommand command = graphics->createRenderCommand("TerrainRender");
command->setViewport(viewport);
@@ -31,6 +31,7 @@ class TerrainRenderer {
Gfx::PTexture2D displacementMap;
Gfx::PTexture2D colorMap;
Gfx::OSampler sampler;
Gfx::PTexture2D displacementAsset;
Gfx::OUniformBuffer geometryBuffer;
Gfx::OUniformBuffer updateBuffer;