From 3dc7e8aba4a07cc3c0d897b82af5a5951bde9991 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sat, 18 Dec 2021 10:59:06 +0500 Subject: Added AO mask --- src/AssetManager.cpp | 1 + src/AssetManager.hpp | 1 + src/RenderConfigs.cpp | 3 ++- src/RenderConfigs.hpp | 2 +- src/RendererSectionData.cpp | 1 + src/RendererSectionData.hpp | 3 ++- src/RendererWorld.cpp | 3 ++- 7 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/AssetManager.cpp b/src/AssetManager.cpp index ca68304..3e3f677 100644 --- a/src/AssetManager.cpp +++ b/src/AssetManager.cpp @@ -594,6 +594,7 @@ BlockFaces &AssetManager::GetBlockModelByBlockId(BlockId block) { blockFaces.transform = glm::mat4(1.0); blockFaces.faces = assetModel->blockModel.parsedFaces; blockFaces.isBlock = assetModel->blockModel.IsBlock; + blockFaces.ambientOcclusion = assetModel->blockModel.AmbientOcclusion; glm::mat4 transform = glm::mat4(1.0); if (model.y != 0) { diff --git a/src/AssetManager.hpp b/src/AssetManager.hpp index 2bee47c..59fc851 100644 --- a/src/AssetManager.hpp +++ b/src/AssetManager.hpp @@ -48,6 +48,7 @@ struct BlockFaces { glm::mat4 transform; std::vector faces; bool isBlock; + bool ambientOcclusion; Vector faceDirectionVector[FaceDirection::none]; }; diff --git a/src/RenderConfigs.cpp b/src/RenderConfigs.cpp index 43342bb..78b442d 100644 --- a/src/RenderConfigs.cpp +++ b/src/RenderConfigs.cpp @@ -183,7 +183,7 @@ Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH, int s normalConf->SetMaxFilter(Gal::Filtering::Bilinear); normal = gal->BuildTexture(normalConf); - auto lightConf = gal->CreateTexture2DConfig(geomW, geomH, Gal::Format::R8G8); + auto lightConf = gal->CreateTexture2DConfig(geomW, geomH, Gal::Format::R8G8B8); lightConf->SetMinFilter(Gal::Filtering::Bilinear); lightConf->SetMaxFilter(Gal::Filtering::Bilinear); light = gal->BuildTexture(lightConf); @@ -221,6 +221,7 @@ Gbuffer::Gbuffer(size_t geomW, size_t geomH, size_t lightW, size_t lightH, int s std::vector>> ssaoTextures = { {"normal", normal}, + {"light", light}, {"depthStencil", depthStencil}, {"ssaoNoise", ssaoNoise}, }; diff --git a/src/RenderConfigs.hpp b/src/RenderConfigs.hpp index d0adfce..9d1ffcd 100644 --- a/src/RenderConfigs.hpp +++ b/src/RenderConfigs.hpp @@ -96,7 +96,7 @@ class Gbuffer { std::shared_ptr depthStencil; std::shared_ptr color; //RGB - color std::shared_ptr normal; //RGB - normal - std::shared_ptr light; //R - faceLight, G - skyLight, B - unused + std::shared_ptr light; //R - faceLight, G - skyLight, B - ssaoDepthMask std::shared_ptr geomFramebuffer; public: diff --git a/src/RendererSectionData.cpp b/src/RendererSectionData.cpp index 7e3d285..c7d922e 100644 --- a/src/RendererSectionData.cpp +++ b/src/RendererSectionData.cpp @@ -69,6 +69,7 @@ void AddFacesByBlockModel(RendererSectionData &data, const BlockFaces &model, co vertexData.animations = face.frames; vertexData.colors = face.color; vertexData.lights = lightness; + vertexData.ambientOcclusion = model.ambientOcclusion ? 1.0f : 0.0f; } } diff --git a/src/RendererSectionData.hpp b/src/RendererSectionData.hpp index 0a80560..390200c 100644 --- a/src/RendererSectionData.hpp +++ b/src/RendererSectionData.hpp @@ -38,7 +38,8 @@ struct VertexData { float animations; glm::vec3 colors; glm::vec2 lights; - uint8_t padding[8]; + float ambientOcclusion; + uint8_t padding[4]; }; struct RendererSectionData { diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp index 7cbd45e..2ffb57f 100644 --- a/src/RendererWorld.cpp +++ b/src/RendererWorld.cpp @@ -463,7 +463,8 @@ void RendererWorld::PrepareRender(std::shared_ptr target, bool {"animation", Gal::Type::Float, 1, 1}, {"color", Gal::Type::Vec3, 1, 1}, {"light", Gal::Type::Vec2, 1, 1}, - {"", Gal::Type::Uint8, 8, 1} + {"ambientOcclusion", Gal::Type::Float, 1, 1}, + {"", Gal::Type::Uint8, 4, 1} }); sectionsPipeline = gal->BuildPipeline(sectionsPLC); } -- cgit v1.2.3