This commit is contained in:
ohyzha
2024-07-19 10:17:45 +03:00
parent cfb8b76801
commit a28b4ab53c
7 changed files with 57 additions and 62 deletions

View File

@@ -21,11 +21,6 @@
#include "Base/EngineConfiguration.hpp"
#include "Controller/FreeCamCameraController.hpp"
#pragma clang diagnostic push
#pragma ide diagnostic ignored "cert-msc50-cpp"
#pragma ide diagnostic ignored "cppcoreguidelines-narrowing-conversions"
namespace OpenVulkano
{
using namespace Scene;
@@ -38,8 +33,7 @@ namespace OpenVulkano
struct BillboardControlBlock
{
glm::vec2 quadSize;
glm::vec2 windowSize;
Math::Vector2f quadSize;
bool isFixedSize;
};
@@ -56,14 +50,16 @@ namespace OpenVulkano
m_quadBillboardShader.AddShaderProgram(OpenVulkano::ShaderProgramType::VERTEX, "Shader/billboardFromSinglePoint");
m_quadBillboardShader.AddShaderProgram(OpenVulkano::ShaderProgramType::GEOMETRY, "Shader/billboardFromSinglePoint");
m_quadBillboardShader.AddShaderProgram(OpenVulkano::ShaderProgramType::FRAGMENT, "Shader/billboard");
m_quadBillboardShader.AddShaderProgram(OpenVulkano::ShaderProgramType::FRAGMENT, "Shader/basicTexture");
m_quadBillboardShader.AddVertexInputDescription(OpenVulkano::Vertex::GetVertexInputDescription());
m_quadBillboardShader.AddDescriptorSetLayoutBinding(Texture::DESCRIPTOR_SET_LAYOUT_BINDING);
m_quadBillboardShader.AddDescriptorSetLayoutBinding(UniformBuffer::DESCRIPTOR_SET_LAYOUT_BINDING);
m_quadBillboardShader.topology = Topology::POINT_LIST;
m_shader.AddShaderProgram(OpenVulkano::ShaderProgramType::VERTEX, "Shader/billboard");
m_shader.AddShaderProgram(OpenVulkano::ShaderProgramType::FRAGMENT, "Shader/billboard");
m_shader.AddShaderProgram(OpenVulkano::ShaderProgramType::FRAGMENT, "Shader/basic");
m_shader.AddVertexInputDescription(OpenVulkano::Vertex::GetVertexInputDescription());
m_shader.AddDescriptorSetLayoutBinding(Texture::DESCRIPTOR_SET_LAYOUT_BINDING);
m_shader.AddDescriptorSetLayoutBinding(UniformBuffer::DESCRIPTOR_SET_LAYOUT_BINDING);
m_shader.cullMode = CullMode::NONE;
@@ -72,12 +68,13 @@ namespace OpenVulkano
constexpr int cntDrawables = quadsCnt + otherCnt;
m_bbContolBlock.quadSize = { 100.f, 100.f };
m_bbContolBlock.windowSize = { 0, 0 }; // will be initialized on first frame
m_bbContolBlock.isFixedSize = false;
m_uniBuffer.Init(sizeof(BillboardControlBlock), &m_bbContolBlock);
m_uniBuffer.setId = 3;
m_drawablesPool.resize(cntDrawables);
m_nodesPool.resize(cntDrawables);
m_geo.reserve(cntDrawables);
m_texturedMat.texture = &Texture::PLACEHOLDER;
for (uint32_t i = 0; i < cntDrawables; i++)
{
@@ -88,9 +85,12 @@ namespace OpenVulkano
geo = new Geometry();
geo->Init(1, 0);
geo->vertices[0].position = glm::vec3(1 + i, i, 0);
geo->vertices[0].color = glm::vec4(1, 0, 0, 1);
if (i >= 1 && i <= 3)
geo->vertices[0].color = glm::vec4(1, 1, 1, 1);
else
geo->vertices[0].color = glm::vec4(1, 0, 0, 1);
m_nodesPool[i].SetMatrix(Math::Utils::translate(glm::mat4x4(1.f), Vector3f(-5 + std::rand() % 5, -5 + std::rand() % 5, std::rand() % 5)));
m_drawablesPool[i].Init(&m_quadBillboardShader, geo, &m_mat, &m_uniBuffer);
m_drawablesPool[i].Init(&m_quadBillboardShader, geo, &m_texturedMat, &m_uniBuffer);
}
else
{
@@ -101,7 +101,6 @@ namespace OpenVulkano
m_geo.push_back(geo);
m_scene.GetRoot()->AddChild(&m_nodesPool[i]);
m_nodesPool[i].AddDrawable(&m_drawablesPool[i]);
m_nodesPool[i].SetUpdateFrequency(UpdateFrequency::Always);
}
GetGraphicsAppManager()->GetRenderer()->SetScene(&m_scene);
@@ -119,14 +118,6 @@ namespace OpenVulkano
void Tick() override
{
static bool firstFrame = true;
if (firstFrame)
{
glm::vec2 sz = GetGraphicsAppManager()->GetWindow()->GetSize();
m_bbContolBlock.windowSize = sz;
m_uniBuffer.updated = true;
firstFrame = false;
}
m_camController.Tick();
}
@@ -145,6 +136,7 @@ namespace OpenVulkano
UniformBuffer m_uniBuffer;
OpenVulkano::FreeCamCameraController m_camController;
Material m_mat;
Material m_texturedMat;
Shader m_shader;
Shader m_quadBillboardShader;
std::vector<SimpleDrawable> m_drawablesPool;