From 663821b00ca8440509e0bc6d5022c809c7fe1cff Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Mon, 15 Nov 2021 12:55:20 +0500 Subject: Changed section rendering to Gal --- src/RendererWorld.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 7 deletions(-) (limited to 'src/RendererWorld.cpp') diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp index 6996762..2764405 100644 --- a/src/RendererWorld.cpp +++ b/src/RendererWorld.cpp @@ -188,7 +188,7 @@ RendererWorld::RendererWorld() { } it->second.UpdateData(parsing[id].renderer); } else - sections.emplace(std::make_pair(parsing[id].renderer.sectionPos, RendererSection(parsing[id].renderer))); + sections.emplace(std::make_pair(parsing[id].renderer.sectionPos, RendererSection(parsing[id].renderer, sectionsPipeline, sectionsBufferBinding))); parsing[id] = RendererWorld::SectionParsing(); }); @@ -401,12 +401,16 @@ void RendererWorld::Render(RenderState & renderState) { //Render sections auto rawGlobalTime = (std::chrono::high_resolution_clock::now() - globalTimeStart); float globalTime = rawGlobalTime.count() / 1000000000.0f; - Shader *blockShader = AssetManager::GetAsset("/altcraft/shaders/face")->shader.get(); + /*Shader* blockShader = AssetManager::GetAsset("/altcraft/shaders/face")->shader.get(); blockShader->Activate(); blockShader->SetUniform("DayTime", mixLevel); blockShader->SetUniform("projView", projView); blockShader->SetUniform("GlobalTime", globalTime); glCheckError(); + */ + sectionsPipeline->Activate(); + sectionsPipeline->SetShaderParameter("DayTime", mixLevel); + sectionsPipeline->SetShaderParameter("projView", projView); Frustum frustum(projView); @@ -425,7 +429,7 @@ void RendererWorld::Render(RenderState & renderState) { culledSections--; continue; } - section.second.Render(renderState); + section.second.Render(); renderedFaces += section.second.numOfFaces; } DebugInfo::culledSections = culledSections; @@ -434,10 +438,41 @@ void RendererWorld::Render(RenderState & renderState) { } void RendererWorld::PrepareRender() { - Shader *blockShader = AssetManager::GetAsset("/altcraft/shaders/face")->shader.get(); - blockShader->Activate(); - blockShader->SetUniform("textureAtlas", 0); - blockShader->SetUniform("MinLightLevel", 0.2f); + std::string sectionVertexSource, sectionPixelSource; + { + auto vertAsset = AssetManager::GetAssetByAssetName("/altcraft/shaders/vert/face"); + sectionVertexSource = std::string((char*)vertAsset->data.data(), (char*)vertAsset->data.data() + vertAsset->data.size()); + + auto pixelAsset = AssetManager::GetAssetByAssetName("/altcraft/shaders/frag/face"); + sectionPixelSource = std::string((char*)pixelAsset->data.data(), (char*)pixelAsset->data.data() + pixelAsset->data.size()); + } + + auto gal = Gal::GetImplementation(); + { + auto sectionsPLC = gal->CreatePipelineConfig(); + sectionsPLC->SetTarget(gal->GetDefaultFramebuffer()); + sectionsPLC->AddShaderParameter("projView", Gal::Type::Mat4); + sectionsPLC->AddShaderParameter("DayTime", Gal::Type::Float); + sectionsPLC->AddShaderParameter("GlobalTime", Gal::Type::Float); + sectionsPLC->AddShaderParameter("MinLightLevel", Gal::Type::Float); + sectionsPLC->AddShaderParameter("textureAtlas", Gal::Type::Int32); + sectionsPLC->SetVertexShader(gal->LoadVertexShader(sectionVertexSource)); + sectionsPLC->SetPixelShader(gal->LoadPixelShader(sectionPixelSource)); + sectionsPLC->SetPrimitive(Gal::Primitive::TriangleFan); + sectionsBufferBinding = sectionsPLC->BindVertexBuffer({ + {"position", Gal::Type::Vec3, 4, 1}, + {"uv", Gal::Type::Vec2, 4, 1}, + {"uvLayer", Gal::Type::Float, 1, 1}, + {"animation", Gal::Type::Float, 1, 1}, + {"color", Gal::Type::Vec3, 1, 1}, + {"light", Gal::Type::Vec2, 1, 1}, + {"", Gal::Type::Uint8, 20, 1} + }); + sectionsPipeline = gal->BuildPipeline(sectionsPLC); + sectionsPipeline->SetShaderParameter("MinLightLevel", 0.2f); + sectionsPipeline->SetShaderParameter("textureAtlas", 0); + } + TextureCoord sunTexture = AssetManager::GetTexture("/minecraft/textures/environment/sun"); TextureCoord moonTexture = AssetManager::GetTexture("/minecraft/textures/environment/moon_phases"); -- cgit v1.2.3 From 513fe5ebe3f59aa8d85d9517db9fe0bfa531d3dc Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Wed, 17 Nov 2021 10:59:16 +0500 Subject: Changed entities rendering to Gal --- src/RendererWorld.cpp | 270 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 181 insertions(+), 89 deletions(-) (limited to 'src/RendererWorld.cpp') diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp index 2764405..03d575b 100644 --- a/src/RendererWorld.cpp +++ b/src/RendererWorld.cpp @@ -293,62 +293,47 @@ void RendererWorld::Render(RenderState & renderState) { glm::mat4 projView = projection * view; //Render Entities -#ifndef __APPLE__ - glLineWidth(3.0); -#endif - Shader *entityShader = AssetManager::GetAsset("/altcraft/shaders/entity")->shader.get(); - entityShader->Activate(); - entityShader->SetUniform("projection", projection); - entityShader->SetUniform("view", view); - glCheckError(); - - renderState.SetActiveVao(RendererEntity::GetVao()); + entitiesPipeline->Activate(); + entitiesPipeline->SetShaderParameter("projection", projection); + entitiesPipeline->SetShaderParameter("view", view); + + entitiesPipelineInstance->Activate(); for (auto& it : entities) { - it.Render(renderState, &GetGameState()->GetWorld()); + it.Render(entitiesPipeline, &GetGameState()->GetWorld()); + entitiesPipelineInstance->Render(0, 24); } //Render selected block Vector selectedBlock = GetGameState()->GetSelectionStatus().selectedBlock; if (selectedBlock != Vector()) { -#ifndef __APPLE__ - glLineWidth(2.0f); -#endif { glm::mat4 model = glm::mat4(1.0); model = glm::translate(model, selectedBlock.glm()); model = glm::translate(model,glm::vec3(0.5f,0.5f,0.5f)); model = glm::scale(model,glm::vec3(1.01f,1.01f,1.01f)); - entityShader->SetUniform("model", model); - entityShader->SetUniform("color", glm::vec3(0, 0, 0)); - glCheckError(); - glDrawArrays(GL_LINES, 0, 24); + entitiesPipeline->SetShaderParameter("model", model); + entitiesPipeline->SetShaderParameter("color", glm::vec3(0, 0, 0)); + entitiesPipelineInstance->Render(0, 24); } } //Render raycast hit const bool renderHit = false; if (renderHit) { - VectorF hit = GetGameState()->GetSelectionStatus().raycastHit; -#ifndef __APPLE__ - glLineWidth(2.0f); -#endif + VectorF hit = GetGameState()->GetSelectionStatus().raycastHit; { glm::mat4 model; model = glm::translate(model, hit.glm()); - model = glm::scale(model,glm::vec3(0.3f,0.3f,0.3f)); - entityShader->SetUniform("model", model); + model = glm::scale(model, glm::vec3(0.3f, 0.3f, 0.3f)); + //entityShader->SetUniform("model", model); + entitiesPipeline->SetShaderParameter("model", model); if (selectedBlock == Vector()) - entityShader->SetUniform("color", glm::vec3(0.7f, 0, 0)); + entitiesPipeline->SetShaderParameter("color", glm::vec3(0.7f, 0.0f, 0.0f)); else - entityShader->SetUniform("color", glm::vec3(0, 0, 0.7f)); - glCheckError(); - glDrawArrays(GL_LINE_STRIP, 0, 36); + entitiesPipeline->SetShaderParameter("color", glm::vec3(0.0f, 0.0f, 0.7f)); + entitiesPipelineInstance->Render(0, 24); } } -#ifndef __APPLE__ - glLineWidth(1.0); -#endif - glCheckError(); //Render sky renderState.TimeOfDay = GetGameState()->GetTimeStatus().timeOfDay; @@ -399,80 +384,187 @@ void RendererWorld::Render(RenderState & renderState) { glCheckError(); //Render sections - auto rawGlobalTime = (std::chrono::high_resolution_clock::now() - globalTimeStart); - float globalTime = rawGlobalTime.count() / 1000000000.0f; - /*Shader* blockShader = AssetManager::GetAsset("/altcraft/shaders/face")->shader.get(); - blockShader->Activate(); - blockShader->SetUniform("DayTime", mixLevel); - blockShader->SetUniform("projView", projView); - blockShader->SetUniform("GlobalTime", globalTime); - glCheckError(); - */ - sectionsPipeline->Activate(); - sectionsPipeline->SetShaderParameter("DayTime", mixLevel); - sectionsPipeline->SetShaderParameter("projView", projView); - - Frustum frustum(projView); + auto rawGlobalTime = (std::chrono::high_resolution_clock::now() - globalTimeStart); + float globalTime = rawGlobalTime.count() / 1000000000.0f; + sectionsPipeline->Activate(); + sectionsPipeline->SetShaderParameter("DayTime", mixLevel); + sectionsPipeline->SetShaderParameter("projView", projView); + + Frustum frustum(projView); size_t culledSections = sections.size(); - unsigned int renderedFaces = 0; + unsigned int renderedFaces = 0; for (auto& section : sections) { - glm::vec3 point{ - section.second.GetPosition().x * 16 + 8, - section.second.GetPosition().y * 16 + 8, - section.second.GetPosition().z * 16 + 8 - }; + glm::vec3 point{ + section.second.GetPosition().x * 16 + 8, + section.second.GetPosition().y * 16 + 8, + section.second.GetPosition().z * 16 + 8 + }; - bool isVisible = frustum.TestSphere(point, 16.0f); + bool isVisible = frustum.TestSphere(point, 16.0f); if (!isVisible) { culledSections--; continue; } section.second.Render(); - renderedFaces += section.second.numOfFaces; + renderedFaces += section.second.numOfFaces; } DebugInfo::culledSections = culledSections; - DebugInfo::renderFaces = renderedFaces; - glCheckError(); + DebugInfo::renderFaces = renderedFaces; } void RendererWorld::PrepareRender() { - std::string sectionVertexSource, sectionPixelSource; - { - auto vertAsset = AssetManager::GetAssetByAssetName("/altcraft/shaders/vert/face"); - sectionVertexSource = std::string((char*)vertAsset->data.data(), (char*)vertAsset->data.data() + vertAsset->data.size()); + std::string sectionVertexSource, sectionPixelSource; + { + auto vertAsset = AssetManager::GetAssetByAssetName("/altcraft/shaders/vert/face"); + sectionVertexSource = std::string((char*)vertAsset->data.data(), (char*)vertAsset->data.data() + vertAsset->data.size()); - auto pixelAsset = AssetManager::GetAssetByAssetName("/altcraft/shaders/frag/face"); - sectionPixelSource = std::string((char*)pixelAsset->data.data(), (char*)pixelAsset->data.data() + pixelAsset->data.size()); - } + auto pixelAsset = AssetManager::GetAssetByAssetName("/altcraft/shaders/frag/face"); + sectionPixelSource = std::string((char*)pixelAsset->data.data(), (char*)pixelAsset->data.data() + pixelAsset->data.size()); + } - auto gal = Gal::GetImplementation(); - { - auto sectionsPLC = gal->CreatePipelineConfig(); - sectionsPLC->SetTarget(gal->GetDefaultFramebuffer()); - sectionsPLC->AddShaderParameter("projView", Gal::Type::Mat4); - sectionsPLC->AddShaderParameter("DayTime", Gal::Type::Float); - sectionsPLC->AddShaderParameter("GlobalTime", Gal::Type::Float); - sectionsPLC->AddShaderParameter("MinLightLevel", Gal::Type::Float); - sectionsPLC->AddShaderParameter("textureAtlas", Gal::Type::Int32); - sectionsPLC->SetVertexShader(gal->LoadVertexShader(sectionVertexSource)); - sectionsPLC->SetPixelShader(gal->LoadPixelShader(sectionPixelSource)); - sectionsPLC->SetPrimitive(Gal::Primitive::TriangleFan); - sectionsBufferBinding = sectionsPLC->BindVertexBuffer({ - {"position", Gal::Type::Vec3, 4, 1}, - {"uv", Gal::Type::Vec2, 4, 1}, - {"uvLayer", Gal::Type::Float, 1, 1}, - {"animation", Gal::Type::Float, 1, 1}, - {"color", Gal::Type::Vec3, 1, 1}, - {"light", Gal::Type::Vec2, 1, 1}, - {"", Gal::Type::Uint8, 20, 1} - }); - sectionsPipeline = gal->BuildPipeline(sectionsPLC); - sectionsPipeline->SetShaderParameter("MinLightLevel", 0.2f); - sectionsPipeline->SetShaderParameter("textureAtlas", 0); - } - + std::string entitiesVertexSource, entitiesPixelSource; + { + auto vertAsset = AssetManager::GetAssetByAssetName("/altcraft/shaders/vert/entity"); + entitiesVertexSource = std::string((char*)vertAsset->data.data(), (char*)vertAsset->data.data() + vertAsset->data.size()); + + auto pixelAsset = AssetManager::GetAssetByAssetName("/altcraft/shaders/frag/entity"); + entitiesPixelSource = std::string((char*)pixelAsset->data.data(), (char*)pixelAsset->data.data() + pixelAsset->data.size()); + } + + auto gal = Gal::GetImplementation(); + { + auto sectionsPLC = gal->CreatePipelineConfig(); + sectionsPLC->SetTarget(gal->GetDefaultFramebuffer()); + sectionsPLC->AddShaderParameter("projView", Gal::Type::Mat4); + sectionsPLC->AddShaderParameter("DayTime", Gal::Type::Float); + sectionsPLC->AddShaderParameter("GlobalTime", Gal::Type::Float); + sectionsPLC->AddShaderParameter("MinLightLevel", Gal::Type::Float); + sectionsPLC->AddShaderParameter("textureAtlas", Gal::Type::Int32); + sectionsPLC->SetVertexShader(gal->LoadVertexShader(sectionVertexSource)); + sectionsPLC->SetPixelShader(gal->LoadPixelShader(sectionPixelSource)); + sectionsPLC->SetPrimitive(Gal::Primitive::TriangleFan); + sectionsBufferBinding = sectionsPLC->BindVertexBuffer({ + {"position", Gal::Type::Vec3, 4, 1}, + {"uv", Gal::Type::Vec2, 4, 1}, + {"uvLayer", Gal::Type::Float, 1, 1}, + {"animation", Gal::Type::Float, 1, 1}, + {"color", Gal::Type::Vec3, 1, 1}, + {"light", Gal::Type::Vec2, 1, 1}, + {"", Gal::Type::Uint8, 20, 1} + }); + sectionsPipeline = gal->BuildPipeline(sectionsPLC); + sectionsPipeline->SetShaderParameter("MinLightLevel", 0.2f); + sectionsPipeline->SetShaderParameter("textureAtlas", 0); + } + + { + auto entitiesPLC = gal->CreatePipelineConfig(); + entitiesPLC->SetTarget(gal->GetDefaultFramebuffer()); + entitiesPLC->AddShaderParameter("view", Gal::Type::Mat4); + entitiesPLC->AddShaderParameter("projection", Gal::Type::Mat4); + entitiesPLC->AddShaderParameter("model", Gal::Type::Mat4); + entitiesPLC->AddShaderParameter("color", Gal::Type::Vec3); + entitiesPLC->SetVertexShader(gal->LoadVertexShader(entitiesVertexSource)); + entitiesPLC->SetPixelShader(gal->LoadPixelShader(entitiesPixelSource)); + entitiesPLC->SetPrimitive(Gal::Primitive::Line); + auto entitiesPosBB = entitiesPLC->BindVertexBuffer({ + {"position", Gal::Type::Vec3}, + }); + auto entitiesUvBB = entitiesPLC->BindVertexBuffer({ + {"uvPosition", Gal::Type::Vec2}, + }); + + entitiesPipeline = gal->BuildPipeline(entitiesPLC); + + constexpr float vertices[] = { + -0.5f, 0.5f, 0.5f, + -0.5f, -0.5f, 0.5f, + -0.5f, -0.5f, 0.5f, + 0.5f, -0.5f, 0.5f, + 0.5f, -0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + -0.5f, 0.5f, 0.5f, + -0.5f, 0.5f, -0.5f, + -0.5f, -0.5f, -0.5f, + -0.5f, -0.5f, -0.5f, + 0.5f, -0.5f, -0.5f, + 0.5f, -0.5f, -0.5f, + 0.5f, 0.5f, -0.5f, + 0.5f, 0.5f, -0.5f, + -0.5f, 0.5f, -0.5f, + -0.5f, -0.5f, -0.5f, + -0.5f, -0.5f, 0.5f, + -0.5f, 0.5f, 0.5f, + -0.5f, 0.5f, -0.5f, + 0.5f, -0.5f, -0.5f, + 0.5f, -0.5f, 0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, 0.5f, -0.5f + }; + + constexpr float uvs[] = { + //Z+ + 0.0f, 1.0f, + 0.0f, 0.0f, + 1.0f, 0.0f, + 0.0f, 1.0f, + 1.0f, 0.0f, + 1.0f, 1.0f, + + //Z- + 1.0f, 0.0f, + 1.0f, 1.0f, + 0.0f, 0.0f, + 0.0f, 0.0f, + 1.0f, 1.0f, + 0.0f, 1.0f, + + //X+ + 0.0f, 0.0f, + 1.0f, 0.0f, + 0.0f, 1.0f, + 0.0f, 1.0f, + 1.0f, 0.0f, + 1.0f, 1.0f, + + //X- + 0.0f, 0.0f, + 1.0f, 1.0f, + 0.0f, 1.0f, + 0.0f, 0.0f, + 1.0f, 0.0f, + 1.0f, 1.0f, + + //Y+ + 0.0f, 0.0f, + 1.0f, 1.0f, + 0.0f, 1.0f, + 0.0f, 0.0f, + 1.0f, 0.0f, + 1.0f, 1.0f, + + //Y- + 1.0f, 0.0f, + 0.0f, 1.0f, + 0.0f, 0.0f, + 1.0f, 1.0f, + 0.0f, 1.0f, + 1.0f, 0.0f, + }; + + entitiesPosBuffer = gal->CreateBuffer(); + entitiesPosBuffer->SetData({ reinterpret_cast(vertices), reinterpret_cast(vertices + sizeof(vertices)) }); + entitiesUvBuffer = gal->CreateBuffer(); + entitiesUvBuffer->SetData({ reinterpret_cast(uvs), reinterpret_cast(uvs + sizeof(uvs)) }); + + entitiesPipelineInstance = entitiesPipeline->CreateInstance({ + {entitiesPosBB, entitiesPosBuffer}, + {entitiesUvBB, entitiesUvBuffer}, + }); + } TextureCoord sunTexture = AssetManager::GetTexture("/minecraft/textures/environment/sun"); TextureCoord moonTexture = AssetManager::GetTexture("/minecraft/textures/environment/moon_phases"); -- cgit v1.2.3 From da9cff10a320b2ee144cb34a281a116f1d2f49cf Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Wed, 17 Nov 2021 13:11:36 +0500 Subject: Optimized entities rendering --- src/RendererWorld.cpp | 223 +++++++++++++++++++++++++++++++------------------- 1 file changed, 140 insertions(+), 83 deletions(-) (limited to 'src/RendererWorld.cpp') diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp index 03d575b..4bec197 100644 --- a/src/RendererWorld.cpp +++ b/src/RendererWorld.cpp @@ -293,14 +293,14 @@ void RendererWorld::Render(RenderState & renderState) { glm::mat4 projView = projection * view; //Render Entities + constexpr size_t entitiesVerticesCount = 240; entitiesPipeline->Activate(); - entitiesPipeline->SetShaderParameter("projection", projection); - entitiesPipeline->SetShaderParameter("view", view); + entitiesPipeline->SetShaderParameter("projView", projView); entitiesPipelineInstance->Activate(); for (auto& it : entities) { it.Render(entitiesPipeline, &GetGameState()->GetWorld()); - entitiesPipelineInstance->Render(0, 24); + entitiesPipelineInstance->Render(0, entitiesVerticesCount); } //Render selected block @@ -313,7 +313,7 @@ void RendererWorld::Render(RenderState & renderState) { model = glm::scale(model,glm::vec3(1.01f,1.01f,1.01f)); entitiesPipeline->SetShaderParameter("model", model); entitiesPipeline->SetShaderParameter("color", glm::vec3(0, 0, 0)); - entitiesPipelineInstance->Render(0, 24); + entitiesPipelineInstance->Render(0, entitiesVerticesCount); } } @@ -331,7 +331,7 @@ void RendererWorld::Render(RenderState & renderState) { entitiesPipeline->SetShaderParameter("color", glm::vec3(0.7f, 0.0f, 0.0f)); else entitiesPipeline->SetShaderParameter("color", glm::vec3(0.0f, 0.0f, 0.7f)); - entitiesPipelineInstance->Render(0, 24); + entitiesPipelineInstance->Render(0, entitiesVerticesCount); } } @@ -462,107 +462,164 @@ void RendererWorld::PrepareRender() { { auto entitiesPLC = gal->CreatePipelineConfig(); entitiesPLC->SetTarget(gal->GetDefaultFramebuffer()); - entitiesPLC->AddShaderParameter("view", Gal::Type::Mat4); - entitiesPLC->AddShaderParameter("projection", Gal::Type::Mat4); + entitiesPLC->AddShaderParameter("projView", Gal::Type::Mat4); entitiesPLC->AddShaderParameter("model", Gal::Type::Mat4); entitiesPLC->AddShaderParameter("color", Gal::Type::Vec3); entitiesPLC->SetVertexShader(gal->LoadVertexShader(entitiesVertexSource)); entitiesPLC->SetPixelShader(gal->LoadPixelShader(entitiesPixelSource)); - entitiesPLC->SetPrimitive(Gal::Primitive::Line); + entitiesPLC->SetPrimitive(Gal::Primitive::Triangle); auto entitiesPosBB = entitiesPLC->BindVertexBuffer({ {"position", Gal::Type::Vec3}, }); - auto entitiesUvBB = entitiesPLC->BindVertexBuffer({ - {"uvPosition", Gal::Type::Vec2}, - }); + auto entitiesIndicesBB = entitiesPLC->BindIndexBuffer(); entitiesPipeline = gal->BuildPipeline(entitiesPLC); + constexpr float lw = 0.485f; // line width + constexpr float vertices[] = { - -0.5f, 0.5f, 0.5f, - -0.5f, -0.5f, 0.5f, - -0.5f, -0.5f, 0.5f, - 0.5f, -0.5f, 0.5f, - 0.5f, -0.5f, 0.5f, - 0.5f, 0.5f, 0.5f, - 0.5f, 0.5f, 0.5f, - -0.5f, 0.5f, 0.5f, - -0.5f, 0.5f, -0.5f, - -0.5f, -0.5f, -0.5f, - -0.5f, -0.5f, -0.5f, - 0.5f, -0.5f, -0.5f, - 0.5f, -0.5f, -0.5f, - 0.5f, 0.5f, -0.5f, + 0.0f, 0.0f, 0.0f, 0.5f, 0.5f, -0.5f, + 0.5f, -0.5f, -0.5f, + 0.5f, 0.5f, 0.5f, + 0.5f, -0.5f, 0.5f, -0.5f, 0.5f, -0.5f, -0.5f, -0.5f, -0.5f, - -0.5f, -0.5f, 0.5f, -0.5f, 0.5f, 0.5f, - -0.5f, 0.5f, -0.5f, - 0.5f, -0.5f, -0.5f, - 0.5f, -0.5f, 0.5f, - 0.5f, 0.5f, 0.5f, - 0.5f, 0.5f, -0.5f + -0.5f, -0.5f, 0.5f, + -0.5f, lw, 0.5f, + 0.5f, lw, -0.5f, + 0.5f, lw, 0.5f, + -0.5f, lw, -0.5f, + 0.5f, -lw, -0.5f, + 0.5f, -lw, 0.5f, + -0.5f, -lw, -0.5f, + -0.5f, -lw, 0.5f, + -0.5f, -0.5f, lw, + 0.5f, 0.5f, lw, + 0.5f, lw, lw, + 0.5f, -lw, lw, + -0.5f, 0.5f, lw, + 0.5f, -0.5f, lw, + -0.5f, lw, lw, + -0.5f, -lw, lw, + -0.5f, 0.5f, -lw, + 0.5f, -0.5f, -lw, + -0.5f, lw, -lw, + -0.5f, -lw, -lw, + -0.5f, -0.5f, -lw, + 0.5f, 0.5f, -lw, + 0.5f, lw, -lw, + 0.5f, -lw, -lw, + -lw, lw, 0.5f, + -lw, -lw, 0.5f, + -lw, lw, -0.5f, + -lw, -0.5f, lw, + -lw, -0.5f, -lw, + -lw, -lw, -0.5f, + -lw, 0.5f, lw, + -lw, 0.5f, -lw, + lw, lw, -0.5f, + lw, -lw, -0.5f, + lw, lw, 0.5f, + lw, 0.5f, lw, + lw, 0.5f, -lw, + lw, -lw, 0.5f, + lw, -0.5f, lw, + lw, -0.5f, -lw, }; - constexpr float uvs[] = { - //Z+ - 0.0f, 1.0f, - 0.0f, 0.0f, - 1.0f, 0.0f, - 0.0f, 1.0f, - 1.0f, 0.0f, - 1.0f, 1.0f, - - //Z- - 1.0f, 0.0f, - 1.0f, 1.0f, - 0.0f, 0.0f, - 0.0f, 0.0f, - 1.0f, 1.0f, - 0.0f, 1.0f, - - //X+ - 0.0f, 0.0f, - 1.0f, 0.0f, - 0.0f, 1.0f, - 0.0f, 1.0f, - 1.0f, 0.0f, - 1.0f, 1.0f, - - //X- - 0.0f, 0.0f, - 1.0f, 1.0f, - 0.0f, 1.0f, - 0.0f, 0.0f, - 1.0f, 0.0f, - 1.0f, 1.0f, - - //Y+ - 0.0f, 0.0f, - 1.0f, 1.0f, - 0.0f, 1.0f, - 0.0f, 0.0f, - 1.0f, 0.0f, - 1.0f, 1.0f, - - //Y- - 1.0f, 0.0f, - 0.0f, 1.0f, - 0.0f, 0.0f, - 1.0f, 1.0f, - 0.0f, 1.0f, - 1.0f, 0.0f, + constexpr int indices[] = { + 47, 26, 22, + 7, 33, 43, + 18, 11, 19, + 12, 28, 27, + 31, 13, 10, + 43, 14, 11, + 25, 12, 27, + 20, 4, 22, + 1, 41, 35, + 3, 18, 44, + 9, 24, 16, + 28, 6, 29, + 45, 30, 1, + 11, 20, 19, + 35, 15, 12, + 39, 25, 21, + 2, 6, 38, + 45, 18, 30, + 37, 29, 6, + 8, 4, 46, + 10, 42, 41, + 8, 17, 36, + 9, 34, 33, + 37, 17, 29, + 47, 48, 26, + 11, 3, 43, + 3, 7, 43, + 7, 9, 33, + 1, 30, 10, + 30, 18, 31, + 10, 30, 31, + 18, 3, 11, + 19, 31, 18, + 12, 15, 28, + 31, 32, 13, + 43, 46, 14, + 7, 21, 9, + 21, 25, 23, + 9, 21, 23, + 25, 5, 12, + 27, 23, 25, + 13, 32, 2, + 32, 20, 26, + 2, 32, 26, + 20, 14, 4, + 22, 26, 20, + 12, 5, 35, + 5, 1, 35, + 1, 10, 41, + 44, 39, 3, + 39, 21, 7, + 3, 39, 7, + 9, 23, 24, + 16, 24, 8, + 24, 28, 17, + 8, 24, 17, + 28, 15, 6, + 29, 17, 28, + 1, 5, 40, + 5, 25, 40, + 40, 45, 1, + 11, 14, 20, + 35, 38, 15, + 39, 40, 25, + 15, 38, 6, + 38, 42, 2, + 42, 13, 2, + 45, 44, 18, + 6, 2, 48, + 2, 26, 48, + 48, 37, 6, + 14, 46, 4, + 46, 34, 8, + 34, 16, 8, + 10, 13, 42, + 36, 47, 8, + 47, 22, 4, + 8, 47, 4, + 9, 16, 34, + 37, 36, 17, }; entitiesPosBuffer = gal->CreateBuffer(); - entitiesPosBuffer->SetData({ reinterpret_cast(vertices), reinterpret_cast(vertices + sizeof(vertices)) }); - entitiesUvBuffer = gal->CreateBuffer(); - entitiesUvBuffer->SetData({ reinterpret_cast(uvs), reinterpret_cast(uvs + sizeof(uvs)) }); + entitiesPosBuffer->SetData({ reinterpret_cast(vertices), reinterpret_cast(vertices) + sizeof(vertices) }); + entitiesIndexBuffer = gal->CreateBuffer(); + entitiesIndexBuffer->SetData({ reinterpret_cast(indices), reinterpret_cast(indices) + sizeof(indices) }); entitiesPipelineInstance = entitiesPipeline->CreateInstance({ {entitiesPosBB, entitiesPosBuffer}, - {entitiesUvBB, entitiesUvBuffer}, + {entitiesIndicesBB, entitiesIndexBuffer} }); } -- cgit v1.2.3 From 8ab6abaae252050bf0ee03cd2a988c0e4e502718 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Fri, 19 Nov 2021 11:48:37 +0500 Subject: Changed sky rendering to Gal --- src/RendererWorld.cpp | 192 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 137 insertions(+), 55 deletions(-) (limited to 'src/RendererWorld.cpp') diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp index 4bec197..cadad3f 100644 --- a/src/RendererWorld.cpp +++ b/src/RendererWorld.cpp @@ -337,51 +337,48 @@ void RendererWorld::Render(RenderState & renderState) { //Render sky renderState.TimeOfDay = GetGameState()->GetTimeStatus().timeOfDay; - Shader *skyShader = AssetManager::GetAsset("/altcraft/shaders/sky")->shader.get(); - skyShader->Activate(); - skyShader->SetUniform("projection", projection); - skyShader->SetUniform("view", view); - glm::mat4 model = glm::mat4(1.0); - model = glm::translate(model, GetGameState()->GetPlayer()->pos.glm()); - const float scale = 1000000.0f; - model = glm::scale(model, glm::vec3(scale, scale, scale)); - float shift = GetGameState()->GetTimeStatus().interpolatedTimeOfDay / 24000.0f; - if (shift < 0) - shift *= -1.0f; - model = glm::rotate(model, glm::radians(90.0f), glm::vec3(0, 1.0f, 0.0f)); - model = glm::rotate(model, glm::radians(360.0f * shift), glm::vec3(-1.0f, 0.0f, 0.0f)); - skyShader->SetUniform("model", model); - - glCheckError(); - - const int sunriseMin = 22000; - const int sunriseMax = 23500; - const int moonriseMin = 12000; - const int moonriseMax = 13500; - const float sunriseLength = sunriseMax - sunriseMin; - const float moonriseLength = moonriseMax - moonriseMin; - - float mixLevel = 0; - float dayTime = GetGameState()->GetTimeStatus().interpolatedTimeOfDay; - if (dayTime < 0) - dayTime *= -1; - while (dayTime > 24000) - dayTime -= 24000; - if (dayTime > 0 && dayTime < moonriseMin || dayTime > sunriseMax) //day - mixLevel = 1.0; - if (dayTime > moonriseMax && dayTime < sunriseMin) //night - mixLevel = 0.0; - if (dayTime >= sunriseMin && dayTime <= sunriseMax) //sunrise - mixLevel = (dayTime - sunriseMin) / sunriseLength; - if (dayTime >= moonriseMin && dayTime <= moonriseMax) { //moonrise - float timePassed = (dayTime - moonriseMin); - mixLevel = 1.0 - (timePassed / moonriseLength); - } - skyShader->SetUniform("DayTime", mixLevel); + glm::mat4 model = glm::mat4(1.0); + model = glm::translate(model, GetGameState()->GetPlayer()->pos.glm()); + const float scale = 1000000.0f; + model = glm::scale(model, glm::vec3(scale, scale, scale)); + float shift = GetGameState()->GetTimeStatus().interpolatedTimeOfDay / 24000.0f; + if (shift < 0) + shift *= -1.0f; + model = glm::rotate(model, glm::radians(90.0f), glm::vec3(0, 1.0f, 0.0f)); + model = glm::rotate(model, glm::radians(360.0f * shift), glm::vec3(-1.0f, 0.0f, 0.0f)); + + const int sunriseMin = 22000; + const int sunriseMax = 23500; + const int moonriseMin = 12000; + const int moonriseMax = 13500; + const float sunriseLength = sunriseMax - sunriseMin; + const float moonriseLength = moonriseMax - moonriseMin; + + float mixLevel = 0; + float dayTime = GetGameState()->GetTimeStatus().interpolatedTimeOfDay; + if (dayTime < 0) + dayTime *= -1; + while (dayTime > 24000) + dayTime -= 24000; + if (dayTime > 0 && dayTime < moonriseMin || dayTime > sunriseMax) //day + mixLevel = 1.0; + if (dayTime > moonriseMax && dayTime < sunriseMin) //night + mixLevel = 0.0; + if (dayTime >= sunriseMin && dayTime <= sunriseMax) //sunrise + mixLevel = (dayTime - sunriseMin) / sunriseLength; + if (dayTime >= moonriseMin && dayTime <= moonriseMax) { //moonrise + float timePassed = (dayTime - moonriseMin); + mixLevel = 1.0 - (timePassed / moonriseLength); + } + + skyPipeline->Activate(); + skyPipeline->SetShaderParameter("projView", projView); + skyPipeline->SetShaderParameter("model", model); + skyPipeline->SetShaderParameter("DayTime", mixLevel); + skyPipelineInstance->Activate(); + skyPipelineInstance->Render(0, 36); - rendererSky.Render(renderState); - glCheckError(); //Render sections auto rawGlobalTime = (std::chrono::high_resolution_clock::now() - globalTimeStart); @@ -433,6 +430,15 @@ void RendererWorld::PrepareRender() { entitiesPixelSource = std::string((char*)pixelAsset->data.data(), (char*)pixelAsset->data.data() + pixelAsset->data.size()); } + std::string skyVertexSource, skyPixelSource; + { + auto vertAsset = AssetManager::GetAssetByAssetName("/altcraft/shaders/vert/sky"); + skyVertexSource = std::string((char*)vertAsset->data.data(), (char*)vertAsset->data.data() + vertAsset->data.size()); + + auto pixelAsset = AssetManager::GetAssetByAssetName("/altcraft/shaders/frag/sky"); + skyPixelSource = std::string((char*)pixelAsset->data.data(), (char*)pixelAsset->data.data() + pixelAsset->data.size()); + } + auto gal = Gal::GetImplementation(); { auto sectionsPLC = gal->CreatePipelineConfig(); @@ -623,18 +629,94 @@ void RendererWorld::PrepareRender() { }); } - TextureCoord sunTexture = AssetManager::GetTexture("/minecraft/textures/environment/sun"); - TextureCoord moonTexture = AssetManager::GetTexture("/minecraft/textures/environment/moon_phases"); - moonTexture.w /= 4.0f; //First phase will be fine for now - moonTexture.h /= 2.0f; - - Shader *sky = AssetManager::GetAsset("/altcraft/shaders/sky")->shader.get(); - sky->Activate(); - sky->SetUniform("textureAtlas", 0); - sky->SetUniform("sunTexture", glm::vec4(sunTexture.x, sunTexture.y, sunTexture.w, sunTexture.h)); - sky->SetUniform("sunTextureLayer", (float)sunTexture.layer); - sky->SetUniform("moonTexture", glm::vec4(moonTexture.x, moonTexture.y, moonTexture.w, moonTexture.h)); - sky->SetUniform("moonTextureLayer", (float)moonTexture.layer); + { + auto skyPPC = gal->CreatePipelineConfig(); + skyPPC->SetTarget(gal->GetDefaultFramebuffer()); + skyPPC->AddShaderParameter("textureAtlas", Gal::Type::Int32); + skyPPC->AddShaderParameter("sunTexture", Gal::Type::Vec4); + skyPPC->AddShaderParameter("sunTextureLayer", Gal::Type::Float); + skyPPC->AddShaderParameter("moonTexture", Gal::Type::Vec4); + skyPPC->AddShaderParameter("moonTextureLayer", Gal::Type::Float); + skyPPC->AddShaderParameter("DayTime", Gal::Type::Float); + skyPPC->AddShaderParameter("projView", Gal::Type::Mat4); + skyPPC->AddShaderParameter("model", Gal::Type::Mat4); + skyPPC->SetVertexShader(gal->LoadVertexShader(skyVertexSource)); + skyPPC->SetPixelShader(gal->LoadPixelShader(skyPixelSource)); + auto skyPosUvBB = skyPPC->BindVertexBuffer({ + {"position", Gal::Type::Vec3}, + {"", Gal::Type::Vec2}, + }); + + constexpr float vertices[] = { + //Z+ Positions UVs + -0.5f, -0.5f, 0.5f, 0.0f, 1.0f, + -0.5f, 0.5f, 0.5f, 0.0f, 0.0f, + 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, + 0.5f, -0.5f, 0.5f, 0.0f, 1.0f, + -0.5f, 0.5f, 0.5f, 1.0f, 0.0f, + 0.5f, 0.5f, 0.5f, 1.0f, 1.0f, + + //Z- + -0.5f, 0.5f, -0.5f, 1.0f, 0.0f, + -0.5f, -0.5f, -0.5f, 1.0f, 1.0f, + 0.5f, -0.5f, -0.5f, 0.0f, 0.0f, + -0.5f, 0.5f, -0.5f, 0.0f, 0.0f, + 0.5f, -0.5f, -0.5f, 1.0f, 1.0f, + 0.5f, 0.5f, -0.5f, 0.0f, 1.0f, + + //X+ + -0.5f, -0.5f, 0.5f, 0.0f, 0.0f, + -0.5f, -0.5f, -0.5f, 1.0f, 0.0f, + -0.5f, 0.5f, -0.5f, 0.0f, 1.0f, + -0.5f, -0.5f, 0.5f, 0.0f, 1.0f, + -0.5f, 0.5f, -0.5f, 1.0f, 0.0f, + -0.5f, 0.5f, 0.5f, 1.0f, 1.0f, + + //X- + 0.5f, 0.5f, -0.5f, 0.0f, 0.0f, + 0.5f, -0.5f, 0.5f, 1.0f, 1.0f, + 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, + 0.5f, -0.5f, -0.5f, 0.0f, 0.0f, + 0.5f, -0.5f, 0.5f, 1.0f, 0.0f, + 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, + + //Y+ + -0.5f, 0.5f, 0.5f, 0.0f, 0.0f, + 0.5f, 0.5f, -0.5f, 1.0f, 1.0f, + 0.5f, 0.5f, 0.5f, 0.0f, 1.0f, + -0.5f, 0.5f, -0.5f, 0.0f, 0.0f, + 0.5f, 0.5f, -0.5f, 1.0f, 0.0f, + -0.5f, 0.5f, 0.5f, 1.0f, 1.0f, + + //Y- + 0.5f, -0.5f, -0.5f, 1.0f, 0.0f, + -0.5f, -0.5f, 0.5f, 0.0f, 1.0f, + 0.5f, -0.5f, 0.5f, 0.0f, 0.0f, + 0.5f, -0.5f, -0.5f, 1.0f, 1.0f, + -0.5f, -0.5f, -0.5f, 0.0f, 1.0f, + -0.5f, -0.5f, 0.5f, 1.0f, 0.0f, + }; + + TextureCoord sunTexture = AssetManager::GetTexture("/minecraft/textures/environment/sun"); + TextureCoord moonTexture = AssetManager::GetTexture("/minecraft/textures/environment/moon_phases"); + moonTexture.w /= 4.0f; // First phase will be fine for now + moonTexture.h /= 2.0f; + + skyPipeline = gal->BuildPipeline(skyPPC); + skyPipeline->Activate(); + skyPipeline->SetShaderParameter("textureAtlas", 0); + skyPipeline->SetShaderParameter("sunTexture", glm::vec4(sunTexture.x, sunTexture.y, sunTexture.w, sunTexture.h)); + skyPipeline->SetShaderParameter("sunTextureLayer", static_cast(sunTexture.layer)); + skyPipeline->SetShaderParameter("moonTexture", glm::vec4(moonTexture.x, moonTexture.y, moonTexture.w, moonTexture.h)); + skyPipeline->SetShaderParameter("moonTextureLayer", static_cast(moonTexture.layer)); + + skyBuffer = gal->CreateBuffer(); + skyBuffer->SetData({ reinterpret_cast(vertices), reinterpret_cast(vertices) + sizeof(vertices) }); + + skyPipelineInstance = skyPipeline->CreateInstance({ + {skyPosUvBB, skyBuffer} + }); + } } void RendererWorld::Update(double timeToUpdate) { -- cgit v1.2.3 From b99f058de08063cb1632a9ef35e4edb10097f31b Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Fri, 19 Nov 2021 15:02:11 +0500 Subject: Changed TextureAtlas to Gal --- src/RendererWorld.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/RendererWorld.cpp') diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp index cadad3f..5970160 100644 --- a/src/RendererWorld.cpp +++ b/src/RendererWorld.cpp @@ -447,7 +447,7 @@ void RendererWorld::PrepareRender() { sectionsPLC->AddShaderParameter("DayTime", Gal::Type::Float); sectionsPLC->AddShaderParameter("GlobalTime", Gal::Type::Float); sectionsPLC->AddShaderParameter("MinLightLevel", Gal::Type::Float); - sectionsPLC->AddShaderParameter("textureAtlas", Gal::Type::Int32); + sectionsPLC->AddStaticTexture("textureAtlas", AssetManager::GetTextureAtlas()); sectionsPLC->SetVertexShader(gal->LoadVertexShader(sectionVertexSource)); sectionsPLC->SetPixelShader(gal->LoadPixelShader(sectionPixelSource)); sectionsPLC->SetPrimitive(Gal::Primitive::TriangleFan); @@ -462,7 +462,6 @@ void RendererWorld::PrepareRender() { }); sectionsPipeline = gal->BuildPipeline(sectionsPLC); sectionsPipeline->SetShaderParameter("MinLightLevel", 0.2f); - sectionsPipeline->SetShaderParameter("textureAtlas", 0); } { @@ -632,7 +631,6 @@ void RendererWorld::PrepareRender() { { auto skyPPC = gal->CreatePipelineConfig(); skyPPC->SetTarget(gal->GetDefaultFramebuffer()); - skyPPC->AddShaderParameter("textureAtlas", Gal::Type::Int32); skyPPC->AddShaderParameter("sunTexture", Gal::Type::Vec4); skyPPC->AddShaderParameter("sunTextureLayer", Gal::Type::Float); skyPPC->AddShaderParameter("moonTexture", Gal::Type::Vec4); @@ -640,6 +638,7 @@ void RendererWorld::PrepareRender() { skyPPC->AddShaderParameter("DayTime", Gal::Type::Float); skyPPC->AddShaderParameter("projView", Gal::Type::Mat4); skyPPC->AddShaderParameter("model", Gal::Type::Mat4); + skyPPC->AddStaticTexture("textureAtlas", AssetManager::GetTextureAtlas()); skyPPC->SetVertexShader(gal->LoadVertexShader(skyVertexSource)); skyPPC->SetPixelShader(gal->LoadPixelShader(skyPixelSource)); auto skyPosUvBB = skyPPC->BindVertexBuffer({ @@ -704,7 +703,6 @@ void RendererWorld::PrepareRender() { skyPipeline = gal->BuildPipeline(skyPPC); skyPipeline->Activate(); - skyPipeline->SetShaderParameter("textureAtlas", 0); skyPipeline->SetShaderParameter("sunTexture", glm::vec4(sunTexture.x, sunTexture.y, sunTexture.w, sunTexture.h)); skyPipeline->SetShaderParameter("sunTextureLayer", static_cast(sunTexture.layer)); skyPipeline->SetShaderParameter("moonTexture", glm::vec4(moonTexture.x, moonTexture.y, moonTexture.w, moonTexture.h)); -- cgit v1.2.3 From b837000b88e34cf297380c99ea608a1517fdf26d Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sat, 20 Nov 2021 00:09:45 +0500 Subject: Added framebuffer to Gal --- src/RendererWorld.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/RendererWorld.cpp') diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp index 5970160..e4a1589 100644 --- a/src/RendererWorld.cpp +++ b/src/RendererWorld.cpp @@ -153,7 +153,7 @@ void RendererWorld::UpdateAllSections(VectorF playerPos) { } } -RendererWorld::RendererWorld() { +RendererWorld::RendererWorld(std::shared_ptr target) { OPTICK_EVENT(); MaxRenderingDistance = 2; numOfWorkers = _max(1, (signed int) std::thread::hardware_concurrency() - 2); @@ -162,7 +162,7 @@ RendererWorld::RendererWorld() { globalTimeStart = std::chrono::high_resolution_clock::now(); - PrepareRender(); + PrepareRender(target); listener->RegisterHandler("DeleteSectionRender", [this](const Event& eventData) { OPTICK_EVENT("EV_DeleteSectionRender"); @@ -411,7 +411,7 @@ void RendererWorld::Render(RenderState & renderState) { DebugInfo::renderFaces = renderedFaces; } -void RendererWorld::PrepareRender() { +void RendererWorld::PrepareRender(std::shared_ptr target) { std::string sectionVertexSource, sectionPixelSource; { auto vertAsset = AssetManager::GetAssetByAssetName("/altcraft/shaders/vert/face"); @@ -442,7 +442,7 @@ void RendererWorld::PrepareRender() { auto gal = Gal::GetImplementation(); { auto sectionsPLC = gal->CreatePipelineConfig(); - sectionsPLC->SetTarget(gal->GetDefaultFramebuffer()); + sectionsPLC->SetTarget(target); sectionsPLC->AddShaderParameter("projView", Gal::Type::Mat4); sectionsPLC->AddShaderParameter("DayTime", Gal::Type::Float); sectionsPLC->AddShaderParameter("GlobalTime", Gal::Type::Float); @@ -466,7 +466,7 @@ void RendererWorld::PrepareRender() { { auto entitiesPLC = gal->CreatePipelineConfig(); - entitiesPLC->SetTarget(gal->GetDefaultFramebuffer()); + entitiesPLC->SetTarget(target); entitiesPLC->AddShaderParameter("projView", Gal::Type::Mat4); entitiesPLC->AddShaderParameter("model", Gal::Type::Mat4); entitiesPLC->AddShaderParameter("color", Gal::Type::Vec3); @@ -630,7 +630,7 @@ void RendererWorld::PrepareRender() { { auto skyPPC = gal->CreatePipelineConfig(); - skyPPC->SetTarget(gal->GetDefaultFramebuffer()); + skyPPC->SetTarget(target); skyPPC->AddShaderParameter("sunTexture", Gal::Type::Vec4); skyPPC->AddShaderParameter("sunTextureLayer", Gal::Type::Float); skyPPC->AddShaderParameter("moonTexture", Gal::Type::Vec4); -- cgit v1.2.3 From 83c61036966c4c358a094cabe27c8de60082200d Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sat, 20 Nov 2021 00:29:28 +0500 Subject: Removed every reference to OpenGL except GalOgl.cpp --- src/RendererWorld.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'src/RendererWorld.cpp') diff --git a/src/RendererWorld.cpp b/src/RendererWorld.cpp index e4a1589..cb4551f 100644 --- a/src/RendererWorld.cpp +++ b/src/RendererWorld.cpp @@ -8,8 +8,6 @@ #include "Frustum.hpp" #include "Event.hpp" #include "AssetManager.hpp" -#include "Renderer.hpp" -#include "Shader.hpp" #include "GameState.hpp" #include "Section.hpp" #include "RendererSectionData.hpp" @@ -259,8 +257,7 @@ RendererWorld::RendererWorld(std::shared_ptr target) { listener->RegisterHandler("SetMinLightLevel", [this](const Event& eventData) { auto value = eventData.get(); - AssetManager::GetAsset("/altcraft/shaders/face")->shader->Activate(); - AssetManager::GetAsset("/altcraft/shaders/face")->shader->SetUniform("MinLightLevel", value); + sectionsPipeline->SetShaderParameter("MinLightLevel", value); }); for (int i = 0; i < numOfWorkers; i++) @@ -282,11 +279,11 @@ RendererWorld::~RendererWorld() { DebugInfo::readyRenderer = 0; } -void RendererWorld::Render(RenderState & renderState) { +void RendererWorld::Render(float screenRatio) { OPTICK_EVENT(); //Common glm::mat4 projection = glm::perspective( - glm::radians(70.0f), (float) renderState.WindowWidth / (float) renderState.WindowHeight, + glm::radians(70.0f), screenRatio, 0.1f, 10000000.0f ); glm::mat4 view = GetGameState()->GetViewMatrix(); @@ -336,8 +333,6 @@ void RendererWorld::Render(RenderState & renderState) { } //Render sky - renderState.TimeOfDay = GetGameState()->GetTimeStatus().timeOfDay; - glm::mat4 model = glm::mat4(1.0); model = glm::translate(model, GetGameState()->GetPlayer()->pos.glm()); const float scale = 1000000.0f; -- cgit v1.2.3