Fixed some transparency bugs and started on component based camera
This commit is contained in:
@@ -32,6 +32,7 @@ void DrawScenePass::Draw(RenderQueueCollection& rq)
|
||||
|
||||
DrawScenePassState state;
|
||||
|
||||
rq.Forward.Jobs.sort(DrawScenePass::DepthSort);
|
||||
|
||||
//TODO: Render: Add code for more jobs than modeljobs.
|
||||
for (auto &job : rq.Forward) {
|
||||
|
||||
@@ -8,6 +8,8 @@ DrawScenePassState::DrawScenePassState()
|
||||
GLERROR("---");
|
||||
Enable(GL_DEPTH_TEST);
|
||||
Enable(GL_CULL_FACE);
|
||||
Enable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
ClearColor(glm::vec4(255.f / 255, 163.f / 255, 176.f / 255, 0.f));
|
||||
Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
|
||||
@@ -78,7 +78,12 @@ RawModel::RawModel(std::string fileName)
|
||||
// Material diffuse color
|
||||
aiColor4D diffuse;
|
||||
material->Get(AI_MATKEY_COLOR_DIFFUSE, diffuse);
|
||||
desc.DiffuseVertexColor = glm::vec4(diffuse.r, diffuse.g, diffuse.b, diffuse.a);
|
||||
|
||||
float opacity;
|
||||
material->Get(AI_MATKEY_OPACITY, opacity);
|
||||
|
||||
desc.DiffuseVertexColor = glm::vec4(diffuse.r, diffuse.g, diffuse.b, opacity);
|
||||
|
||||
// Material specular color
|
||||
aiColor4D specular;
|
||||
material->Get(AI_MATKEY_COLOR_SPECULAR, specular);
|
||||
@@ -132,6 +137,7 @@ RawModel::RawModel(std::string fileName)
|
||||
matGroup.EndIndex = m_Indices.size() - 1;
|
||||
// Material shininess
|
||||
material->Get(AI_MATKEY_SHININESS, matGroup.Shininess);
|
||||
material->Get(AI_MATKEY_OPACITY, matGroup.Transparency);
|
||||
//LOG_DEBUG("Shininess: %f", matGroup.Shininess);
|
||||
// Diffuse texture
|
||||
//LOG_DEBUG("%i diffuse textures found", material->GetTextureCount(aiTextureType_DIFFUSE));
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
#include "Rendering/RenderQueueFactory.h"
|
||||
|
||||
|
||||
RenderQueueFactory::RenderQueueFactory()
|
||||
RenderQueueFactory::RenderQueueFactory(EventBroker* eventBroker)
|
||||
{
|
||||
m_RenderQueues = RenderQueueCollection();
|
||||
m_EventBroker = eventBroker;
|
||||
}
|
||||
|
||||
void RenderQueueFactory::Update(World* world)
|
||||
@@ -79,21 +80,44 @@ void RenderQueueFactory::FillModels(World* world, RenderQueue* renderQueue)
|
||||
Model* model = ResourceManager::Load<Model>(resource);
|
||||
|
||||
for (auto texGroup : model->TextureGroups) {
|
||||
ModelJob job;
|
||||
job.TextureID = (texGroup.Texture) ? texGroup.Texture->ResourceID : 0;
|
||||
job.DiffuseTexture = texGroup.Texture.get();
|
||||
job.NormalTexture = texGroup.NormalMap.get();
|
||||
job.SpecularTexture = texGroup.SpecularMap.get();
|
||||
job.Model = model;
|
||||
job.StartIndex = texGroup.StartIndex;
|
||||
job.EndIndex = texGroup.EndIndex;
|
||||
job.ModelMatrix = model->m_Matrix * ModelMatrix(world, modelC.EntityID);
|
||||
job.Color = color;
|
||||
|
||||
//TODO: RENDERER: Not sure if the best solution for pickingColor to entity link is this
|
||||
job.Entity = modelC.EntityID;
|
||||
if (color.a < 1.0f || texGroup.Transparency < 1.0f) {
|
||||
//transparent stuffs
|
||||
TransparentModelJob job;
|
||||
job.TextureID = (texGroup.Texture) ? texGroup.Texture->ResourceID : 0;
|
||||
job.DiffuseTexture = texGroup.Texture.get();
|
||||
job.NormalTexture = texGroup.NormalMap.get();
|
||||
job.SpecularTexture = texGroup.SpecularMap.get();
|
||||
job.Model = model;
|
||||
job.StartIndex = texGroup.StartIndex;
|
||||
job.EndIndex = texGroup.EndIndex;
|
||||
job.ModelMatrix = model->m_Matrix * ModelMatrix(world, modelC.EntityID);
|
||||
job.Color = color;
|
||||
|
||||
renderQueue->Add(job);
|
||||
job.Entity = modelC.EntityID;
|
||||
job.Depth = 10.f; //insert real viewspace depth here
|
||||
|
||||
renderQueue->Add(job);
|
||||
} else {
|
||||
ModelJob job;
|
||||
job.TextureID = (texGroup.Texture) ? texGroup.Texture->ResourceID : 0;
|
||||
job.DiffuseTexture = texGroup.Texture.get();
|
||||
job.NormalTexture = texGroup.NormalMap.get();
|
||||
job.SpecularTexture = texGroup.SpecularMap.get();
|
||||
job.Model = model;
|
||||
job.StartIndex = texGroup.StartIndex;
|
||||
job.EndIndex = texGroup.EndIndex;
|
||||
job.ModelMatrix = model->m_Matrix * ModelMatrix(world, modelC.EntityID);
|
||||
job.Color = color;
|
||||
|
||||
//TODO: RENDERER: Not sure if the best solution for pickingColor to entity link is this
|
||||
job.Entity = modelC.EntityID;
|
||||
|
||||
renderQueue->Add(job);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ void Renderer::Initialize()
|
||||
if (m_Camera == nullptr) {
|
||||
m_Camera = m_DefaultCamera;
|
||||
}
|
||||
|
||||
TEMPCreateLights();
|
||||
InitializeRenderPasses();
|
||||
|
||||
@@ -88,36 +89,6 @@ void Renderer::InitializeShaders()
|
||||
void Renderer::InputUpdate(double dt)
|
||||
{
|
||||
static DebugCameraInputController<Renderer> firstPersonInputController(m_EventBroker, -1);
|
||||
|
||||
glm::vec3 m_Position = m_Camera->Position();
|
||||
if (glfwGetKey(m_Window, GLFW_KEY_O) == GLFW_PRESS)
|
||||
{
|
||||
m_Position = glm::vec3(0.f, 0.f, 5.f);
|
||||
}
|
||||
if (glfwGetKey(m_Window, GLFW_KEY_W) == GLFW_PRESS)
|
||||
{
|
||||
m_Position += m_Camera->Forward() * m_CameraMoveSpeed * (float)dt;
|
||||
}
|
||||
if (glfwGetKey(m_Window, GLFW_KEY_S) == GLFW_PRESS)
|
||||
{
|
||||
m_Position -= m_Camera->Forward() * m_CameraMoveSpeed * (float)dt;
|
||||
}
|
||||
if (glfwGetKey(m_Window, GLFW_KEY_D) == GLFW_PRESS)
|
||||
{
|
||||
m_Position += m_Camera->Right() * m_CameraMoveSpeed * (float)dt;
|
||||
}
|
||||
if (glfwGetKey(m_Window, GLFW_KEY_A) == GLFW_PRESS)
|
||||
{
|
||||
m_Position -= m_Camera->Right() * m_CameraMoveSpeed * (float)dt;
|
||||
}
|
||||
if (glfwGetKey(m_Window, GLFW_KEY_LEFT_SHIFT) == GLFW_PRESS)
|
||||
{
|
||||
m_CameraMoveSpeed = 5.f;
|
||||
}
|
||||
else {
|
||||
m_CameraMoveSpeed = 0.5f;
|
||||
}
|
||||
|
||||
firstPersonInputController.Update(dt);
|
||||
m_Camera->SetOrientation(firstPersonInputController.Orientation());
|
||||
m_Camera->SetPosition(firstPersonInputController.Position());
|
||||
@@ -237,7 +208,6 @@ void Renderer::CalculateFrustum()
|
||||
{
|
||||
GLERROR("CalculateFrustum Error-1");
|
||||
m_CalculateFrustumProgram->Bind();
|
||||
|
||||
GLERROR("CalculateFrustum Error1");
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, m_FrustumSSBO);
|
||||
GLERROR("CalculateFrustum Error2");
|
||||
|
||||
+11
-9
@@ -14,10 +14,17 @@ Game::Game(int argc, char* argv[])
|
||||
// Create the core event broker
|
||||
m_EventBroker = new EventBroker();
|
||||
|
||||
m_RenderQueueFactory = new RenderQueueFactory();
|
||||
m_RenderQueueFactory = new RenderQueueFactory(m_EventBroker);
|
||||
|
||||
// Create a world
|
||||
m_World = new World();
|
||||
std::string mapToLoad = m_Config->Get<std::string>("Debug.LoadMap", "");
|
||||
if (!mapToLoad.empty()) {
|
||||
ResourceManager::Load<EntityXMLFile>(mapToLoad)->PopulateWorld(m_World);
|
||||
}
|
||||
|
||||
// Create the renderer
|
||||
m_Renderer = new Renderer(m_EventBroker);
|
||||
m_Renderer = new Renderer(m_EventBroker, m_World);
|
||||
m_Renderer->SetFullscreen(m_Config->Get<bool>("Video.Fullscreen", false));
|
||||
m_Renderer->SetVSYNC(m_Config->Get<bool>("Video.VSYNC", false));
|
||||
m_Renderer->SetResolution(Rectangle(
|
||||
@@ -27,7 +34,7 @@ Game::Game(int argc, char* argv[])
|
||||
m_Config->Get<int>("Video.Height", 720)
|
||||
));
|
||||
m_Renderer->Initialize();
|
||||
m_Renderer->Camera()->SetFOV(glm::radians(m_Config->Get<float>("Video.FOV", 90.f)));
|
||||
//m_Renderer->Camera()->SetFOV(glm::radians(m_Config->Get<float>("Video.FOV", 90.f)));
|
||||
|
||||
// Create input manager
|
||||
m_InputManager = new InputManager(m_Renderer->Window(), m_EventBroker);
|
||||
@@ -41,12 +48,7 @@ Game::Game(int argc, char* argv[])
|
||||
m_FrameStack->Width = m_Renderer->Resolution().Width;
|
||||
m_FrameStack->Height = m_Renderer->Resolution().Height;
|
||||
|
||||
// Create a world
|
||||
m_World = new World();
|
||||
std::string mapToLoad = m_Config->Get<std::string>("Debug.LoadMap", "");
|
||||
if (!mapToLoad.empty()) {
|
||||
ResourceManager::Load<EntityXMLFile>(mapToLoad)->PopulateWorld(m_World);
|
||||
}
|
||||
|
||||
|
||||
// Create system pipeline
|
||||
m_SystemPipeline = new SystemPipeline(m_EventBroker);
|
||||
|
||||
Reference in New Issue
Block a user