Auto stash before merge of "master" and "Gitea/master"

This commit is contained in:
Dynamitos
2024-09-25 17:27:21 +02:00
parent 6417ab940d
commit 81f29d1b3f
16 changed files with 518 additions and 147 deletions
+15 -12
View File
@@ -54,7 +54,12 @@ void MeshLoader::loadTextures(const aiScene* scene, const std::filesystem::path&
} else if (std::filesystem::exists(meshDirectory / texPath)) {
texPath = meshDirectory / texPath;
} else {
texPath = (meshDirectory / texPath).replace_extension("png");
if (tex->mFilename.length == 0) {
texPath = (meshDirectory / fmt::format("Texture{0}", i));
} else {
texPath = (meshDirectory / texPath);
}
texPath = texPath.replace_extension(tex->achFormatHint);
if (tex->mHeight == 0) {
std::cout << "Dumping texture " << texPath << std::endl;
// already compressed, just dump it to the disk
@@ -219,18 +224,17 @@ void MeshLoader::loadMaterials(const aiScene* scene, const Array<PTextureAsset>&
expressions.back()->key = colorExtract;
expressions.back()->inputs["target"].source = sampleKey;
if (alpha != nullptr)
{
if (alpha != nullptr) {
std::string alphaExtract = fmt::format("{0}Alpha{1}", paramKey, index);
expressions.add(new SwizzleExpression({3, -1, -1, -1}));
expressions.back()->key = alphaExtract;
expressions.back()->inputs["target"].source = sampleKey;
//std::string alphaMul = fmt::format("{0}AlphaMul{1}", paramKey, index);
//expressions.add(new MulExpression());
//expressions.back()->key = alphaMul;
//expressions.back()->inputs["lhs"].source = *alpha;
//expressions.back()->inputs["rhs"].source = alphaExtract;
// std::string alphaMul = fmt::format("{0}AlphaMul{1}", paramKey, index);
// expressions.add(new MulExpression());
// expressions.back()->key = alphaMul;
// expressions.back()->inputs["lhs"].source = *alpha;
// expressions.back()->inputs["rhs"].source = alphaExtract;
*alpha = alphaExtract;
}
@@ -561,9 +565,8 @@ void MeshLoader::import(MeshImportArgs args, PMeshAsset meshAsset) {
meshAsset->setStatus(Asset::Status::Loading);
Assimp::Importer importer;
importer.ReadFile(args.filePath.string().c_str(),
(uint32)(aiProcess_FlipUVs | aiProcess_Triangulate | aiProcess_SortByPType |
aiProcess_GenBoundingBoxes | aiProcess_GenSmoothNormals |
aiProcess_GenUVCoords | aiProcess_FindDegenerates));
(uint32)(aiProcess_FlipUVs | aiProcess_Triangulate | aiProcess_SortByPType | aiProcess_GenBoundingBoxes |
aiProcess_GenSmoothNormals | aiProcess_GenUVCoords | aiProcess_FindDegenerates));
const aiScene* scene = importer.ApplyPostProcessing(aiProcess_CalcTangentSpace);
std::cout << importer.GetErrorString() << std::endl;
@@ -593,6 +596,6 @@ void MeshLoader::import(MeshImportArgs args, PMeshAsset meshAsset) {
meshAsset->physicsMesh = std::move(collider);
AssetRegistry::saveAsset(meshAsset, MeshAsset::IDENTIFIER, meshAsset->getFolderPath(), meshAsset->getName());
meshAsset->setStatus(Asset::Status::Ready);
}
-2
View File
@@ -45,6 +45,4 @@ void PlayView::keyCallback(KeyCode code, InputAction action, KeyModifier modifie
std::cout << cam.getCameraPosition() << std::endl;
std::cout << tra.getRotation() << std::endl;
}
if (code == KeyCode::KEY_R && action == InputAction::RELEASE) {
}
}
+8
View File
@@ -77,6 +77,14 @@ int main() {
// .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 = {
+2
View File
@@ -16,6 +16,7 @@ target_sources(Engine
ShapeBase.cpp
Skybox.h
SphereCollider.h
TerrainTile.h
Transform.h
Transform.cpp
WaterTile.h)
@@ -37,5 +38,6 @@ target_sources(Engine
ShapeBase.h
Skybox.h
SphereCollider.h
TerrainTile.h
Transform.h
WaterTile.h)
+13
View File
@@ -0,0 +1,13 @@
#pragma once
#include "Math/Vector.h"
#include "MinimalEngine.h"
namespace Seele {
namespace Component {
struct TerrainTile {
IVector2 location;
float height;
constexpr static float DIMENSIONS = 10;
};
} // namespace Component
} // namespace Seele
+5 -1
View File
@@ -27,6 +27,7 @@ void Seele::addDebugVertices(Array<DebugVertex> verts) { gDebugVertices.addAll(v
BasePass::BasePass(Gfx::PGraphics graphics, PScene scene) : RenderPass(graphics, scene) {
//waterRenderer = new WaterRenderer(graphics, scene, viewParamsLayout);
terrainRenderer = new TerrainRenderer(graphics, scene, viewParamsLayout);
basePassLayout = graphics->createPipelineLayout("BasePassLayout");
basePassLayout->addDescriptorLayout(viewParamsLayout);
@@ -99,6 +100,7 @@ void BasePass::beginFrame(const Component::Camera& cam) {
transparentCulling = lightCullingLayout->allocateDescriptorSet();
//waterRenderer->beginFrame();
terrainRenderer->beginFrame();
// Debug vertices
{
@@ -247,7 +249,8 @@ void BasePass::render() {
}
}
//commands.add(waterRenderer->render(viewParamsSet));
// commands.add(waterRenderer->render(viewParamsSet));
commands.add(terrainRenderer->render(viewParamsSet));
// Skybox
{
@@ -471,6 +474,7 @@ void BasePass::createRenderPass() {
tLightGrid = resources->requestTexture("LIGHTCULLING_TLIGHTGRID");
//waterRenderer->setViewport(viewport, renderPass);
terrainRenderer->setViewport(viewport, renderPass);
// Debug rendering
{
@@ -2,6 +2,7 @@
#include "MinimalEngine.h"
#include "RenderPass.h"
#include "WaterRenderer.h"
#include "TerrainRenderer.h"
namespace Seele {
DECLARE_REF(CameraActor)
@@ -50,6 +51,7 @@ class BasePass : public RenderPass {
Gfx::PShaderBuffer cullingBuffer;
OWaterRenderer waterRenderer;
OTerrainRenderer terrainRenderer;
// Debug rendering
Gfx::OVertexInput debugVertexInput;
@@ -15,6 +15,8 @@ target_sources(Engine
RenderGraphResources.cpp
RenderPass.h
RenderPass.cpp
TerrainRenderer.h
TerrainRenderer.cpp
TextPass.h
TextPass.cpp
UIPass.h
@@ -35,6 +37,7 @@ target_sources(Engine
RenderGraph.h
RenderGraphResources.h
RenderPass.h
TerrainRenderer.h
TextPass.h
UIPass.h
VisibilityPass.h)
@@ -0,0 +1,134 @@
#include "TerrainRenderer.h"
#include "Asset/AssetRegistry.h"
#include "Component/TerrainTile.h"
#include "Graphics/Graphics.h"
#include "Graphics/Shader.h"
using namespace Seele;
TerrainRenderer::TerrainRenderer(Gfx::PGraphics graphics, PScene scene, Gfx::PDescriptorLayout viewParamsLayout)
: graphics(graphics), scene(scene) {
tilesBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{
.dynamic = true,
.name = "TilesBuffer",
});
float displacementData = 0;
displacementMap = graphics->createTexture2D(TextureCreateInfo{
.sourceData =
{
.size = sizeof(float),
.data = (uint8*)&displacementData,
},
.format = Gfx::SE_FORMAT_R32_SFLOAT,
.width = 1,
.height = 1,
.depth = 1,
.name = "TerrainDisplacement",
});
sampler = graphics->createSampler(SamplerCreateInfo{});
layout = graphics->createDescriptorLayout("pTerrainData");
layout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 0,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,
});
layout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 1,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
});
layout->addDescriptorBinding(Gfx::DescriptorBinding{
.binding = 2,
.descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,
});
layout->create();
pipelineLayout = graphics->createPipelineLayout("TerrainLayout");
pipelineLayout->addDescriptorLayout(viewParamsLayout);
pipelineLayout->addDescriptorLayout(layout);
ShaderCompilationInfo s{
.name = "TerrainShaders",
.modules = {"TerrainPass"},
.entryPoints =
{
{"taskMain", "TerrainPass"},
{"meshMain", "TerrainPass"},
{"fragmentMain", "TerrainPass"},
},
.rootSignature = pipelineLayout,
.dumpIntermediate = false,
};
graphics->beginShaderCompilation(s);
task = graphics->createTaskShader({0});
mesh = graphics->createMeshShader({1});
frag = graphics->createFragmentShader({2});
pipelineLayout->create();
}
TerrainRenderer::~TerrainRenderer() {}
void TerrainRenderer::beginFrame() {
struct TerrainTile {
IVector2 offset;
float extent;
float height;
};
Array<TerrainTile> payloads;
scene->view<Component::TerrainTile>([&](Component::TerrainTile& tile) {
payloads.add(TerrainTile{
.offset = IVector2(tile.location),
.extent = Component::TerrainTile::DIMENSIONS,
.height = tile.height,
});
});
if (payloads.size() == 0)
return;
tilesBuffer->rotateBuffer(sizeof(TerrainTile) * payloads.size());
tilesBuffer->updateContents(0, sizeof(TerrainTile) * payloads.size(), payloads.data());
tilesBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT, Gfx::SE_ACCESS_SHADER_READ_BIT,
Gfx::SE_PIPELINE_STAGE_TASK_SHADER_BIT_EXT);
set = layout->allocateDescriptorSet();
set->updateBuffer(0, tilesBuffer);
set->updateTexture(1, 0, Gfx::PTexture2D(displacementMap));
set->updateSampler(2, sampler);
set->writeChanges();
}
Gfx::ORenderCommand TerrainRenderer::render(Gfx::PDescriptorSet viewParamsSet) {
Gfx::ORenderCommand command = graphics->createRenderCommand("TerrainRender");
command->setViewport(viewport);
command->bindPipeline(pipeline);
command->bindDescriptor({viewParamsSet, set});
command->drawMesh(400, 4, 1);
return command;
}
void TerrainRenderer::setViewport(Gfx::PViewport _viewport, Gfx::PRenderPass renderPass) {
viewport = _viewport;
Gfx::MeshPipelineCreateInfo pipelineInfo = {
.taskShader = task,
.meshShader = mesh,
.fragmentShader = frag,
.renderPass = renderPass,
.pipelineLayout = pipelineLayout,
.multisampleState =
{
.samples = viewport->getSamples(),
},
.rasterizationState =
{
//.polygonMode = Gfx::SE_POLYGON_MODE_LINE,
.cullMode = Gfx::SE_CULL_MODE_BACK_BIT,
},
.colorBlend =
{
.attachmentCount = 1,
.blendAttachments =
{
Gfx::ColorBlendState::BlendAttachment{
.blendEnable = false,
},
},
},
};
pipeline = graphics->createGraphicsPipeline(std::move(pipelineInfo));
}
@@ -0,0 +1,29 @@
#pragma once
#include "RenderPass.h"
namespace Seele {
class TerrainRenderer {
public:
TerrainRenderer(Gfx::PGraphics graphics, PScene scene, Gfx::PDescriptorLayout viewParamsLayout);
~TerrainRenderer();
void beginFrame();
Gfx::ORenderCommand render(Gfx::PDescriptorSet viewParamsSet);
void setViewport(Gfx::PViewport viewport, Gfx::PRenderPass renderPass);
private:
Gfx::PGraphics graphics;
PScene scene;
Gfx::ODescriptorLayout layout;
Gfx::PDescriptorSet set;
Gfx::OPipelineLayout pipelineLayout;
Gfx::OTaskShader task;
Gfx::OMeshShader mesh;
Gfx::OFragmentShader frag;
Gfx::PGraphicsPipeline pipeline;
Gfx::PViewport viewport;
Gfx::OShaderBuffer tilesBuffer;
Gfx::OTexture2D displacementMap;
Gfx::OSampler sampler;
};
DEFINE_REF(TerrainRenderer);
}
@@ -243,15 +243,15 @@ WaterRenderer::WaterRenderer(Gfx::PGraphics graphics, PScene scene, Gfx::PDescri
ShaderCompilationInfo createInfo = {
.name = "WaterTiles",
.modules = {"WaterTask", "WaterMesh", "WaterPass"},
.modules = {"WaterPass"},
.entryPoints =
{
{"taskMain", "WaterTask"},
{"meshMain", "WaterMesh"},
{"taskMain", "WaterPass"},
{"meshMain", "WaterPass"},
{"fragmentMain", "WaterPass"},
},
.rootSignature = waterLayout,
.dumpIntermediate = true,
.dumpIntermediate = false,
};
graphics->beginShaderCompilation(createInfo);
waterTask = graphics->createTaskShader({0});
@@ -353,7 +353,7 @@ void WaterRenderer::beginFrame() {
Array<WaterTile> payloads;
scene->view<Component::WaterTile>([&](Component::WaterTile& tile) {
payloads.add(WaterTile{
.offset = Vector2(tile.location),
.offset = IVector2(tile.location),
.extent = Component::WaterTile::DIMENSIONS,
.height = tile.height,
});
+1 -1
View File
@@ -42,7 +42,7 @@ void Seele::beginCompilation(const ShaderCompilationInfo& info, SlangCompileTarg
option[1].value.intValue0 = 1;
option[2].name = slang::CompilerOptionName::DebugInformation;
option[2].value.kind = slang::CompilerOptionValueKind::Int;
option[2].value.intValue0 = SLANG_DEBUG_INFO_LEVEL_STANDARD;
option[2].value.intValue0 = SLANG_DEBUG_INFO_LEVEL_NONE;
option[3].name = slang::CompilerOptionName::DebugInformationFormat;
option[3].value.kind = slang::CompilerOptionValueKind::Int;
option[3].value.intValue0 = SLANG_DEBUG_INFO_FORMAT_PDB;