diff --git a/src/Common/Logger.h b/src/Common/Logger.h index 2d01397..c407e18 100644 --- a/src/Common/Logger.h +++ b/src/Common/Logger.h @@ -1,3 +1,8 @@ +/* + Todo: + The timestamp is not in localtime, + fix or disclaim +*/ #ifndef LOGGER_H #define LOGGER_H @@ -134,7 +139,8 @@ void Logger::logRAM( std::string_view message, Args&&... args ) { - auto now = std::chrono::system_clock::now(); + auto now { std::chrono::system_clock::now() }; + now = std::chrono::zoned_time{ std::chrono::current_zone(), now }; auto timestamp = std::format("{:%Y-%m-%d %H:%M}", now); auto start = logBuffer.size(); diff --git a/src/Engine/engine/engine.h b/src/Engine/engine/engine.h index 3ed4fd1..8968dcf 100644 --- a/src/Engine/engine/engine.h +++ b/src/Engine/engine/engine.h @@ -568,7 +568,7 @@ void Engine::run() { int currentID = currentBackgroundEffect; if (prevID != currentID) { //_logger.logRAM(ENGINE, EINFO, "Background shader changed"); - _logger.logFatal(ENGINE, "Background shader changed !"); + //_logger.logFatal(ENGINE, "Background shader changed !"); } prevID = currentID; @@ -1489,8 +1489,9 @@ void Engine::initMeshPipeline() { pipelineBuilder.setCullMode(VK_CULL_MODE_NONE, VK_FRONT_FACE_CLOCKWISE); // No multisampling pipelineBuilder.setMultisamplingNone(); - // No blending - pipelineBuilder.disableBlending(); + // Blending + //pipelineBuilder.disableBlending(); + pipelineBuilder.enableBlendingAdditive(); pipelineBuilder.enableDepthtest( true, @@ -1862,6 +1863,7 @@ void Engine::buildImgui() { } ImGui::End(); + #ifdef DEBUG // Stats if(ImGui::Begin("Stats")) { // Todo: @@ -1870,15 +1872,20 @@ void Engine::buildImgui() { // Etc... ImGui::TextWrapped("GPU memory usage : %.2f KiB", _gpuMemusage/1024.0f); ImGui::TextWrapped("Swapchain dimensions : %ix%i", _swapchainExtent.width, _swapchainExtent.height); + if(ImGui::Button("Crash (debug)")) { + _logger.logFatal(ENGINE, "Crash ! (debug)"); + } } ImGui::End(); + #endif - + #ifdef DEBUG // Memory editor if(ImGui::Begin("Memory")) { _memEdit.DrawContents(this, sizeof(*this), (size_t)this); } ImGui::End(); + #endif // Finish everything ImGui::Render(); @@ -2040,11 +2047,18 @@ void Engine::drawGeometry( // Draw the rectangle vkCmdDrawIndexed(cmd, 6, 1, 0, 0, 0); + // Makes it turn + static auto startTime = std::chrono::high_resolution_clock::now(); + + auto currentTime = std::chrono::high_resolution_clock::now(); + float time = std::chrono::duration(currentTime - startTime).count(); + + // Model + glm::mat4 model = rotate(glm::mat4(1.0f), time/10 * glm::radians(90.0f), glm::vec3(0.0f, 0.0f, 1.0f)); // turn // Correct the matrix glm::mat4 view = glm::translate(glm::vec3{ 0, 0, -5}); // Camera projection - glm::mat4 projection = glm::perspective( glm::radians(70.0f), (float)_drawExtent.width / (float)_drawExtent.height, @@ -2053,7 +2067,7 @@ void Engine::drawGeometry( ); // Invert the Y direction projection[1][1] *= -1; - pushConstants.worldMatrix = projection * view; + pushConstants.worldMatrix = projection * view * model; pushConstants.vertexBuffer = testMeshes[2]->meshBuffers.vertexBufferAddress; vkCmdPushConstants( diff --git a/src/Engine/engine/pipelines.h b/src/Engine/engine/pipelines.h index 6617cd9..5651fac 100644 --- a/src/Engine/engine/pipelines.h +++ b/src/Engine/engine/pipelines.h @@ -63,7 +63,9 @@ class PipelineBuilder { void setMultisamplingNone(); - void disableBlending (); + void enableBlendingAdditive(); + void enableBlendingAlphaBlend(); + void disableBlending(); void setColorAttachmentFormat( VkFormat format @@ -333,6 +335,28 @@ void PipelineBuilder::setMultisamplingNone() { _multisampling.alphaToOneEnable = VK_FALSE; } +void PipelineBuilder::enableBlendingAdditive() { + _colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; + _colorBlendAttachment.blendEnable = VK_TRUE; + _colorBlendAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; + _colorBlendAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_ONE; + _colorBlendAttachment.colorBlendOp = VK_BLEND_OP_ADD; + _colorBlendAttachment.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE; + _colorBlendAttachment.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO; + _colorBlendAttachment.alphaBlendOp = VK_BLEND_OP_ADD; +} + +void PipelineBuilder::enableBlendingAlphaBlend() { + _colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT; + _colorBlendAttachment.blendEnable = VK_TRUE; + _colorBlendAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA; + _colorBlendAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA; + _colorBlendAttachment.colorBlendOp = VK_BLEND_OP_ADD; + _colorBlendAttachment.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE; + _colorBlendAttachment.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO; + _colorBlendAttachment.alphaBlendOp = VK_BLEND_OP_ADD; +} + void PipelineBuilder::disableBlending() { // Default write mask _colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;