Fixed some transparency bugs and started on component based camera

This commit is contained in:
viktorljung
2015-12-14 19:10:00 +01:00
parent 6723e71fee
commit 05b78265be
17 changed files with 160 additions and 72 deletions
+1
View File
@@ -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);
}
+7 -1
View File
@@ -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));
+38 -14
View File
@@ -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);
}
}
}
}
+1 -31
View File
@@ -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");