Fixed transparency

This commit is contained in:
Tleety
2014-06-02 22:15:52 +02:00
parent 179c5c1feb
commit f5f6a5cf3a
3 changed files with 19 additions and 21 deletions
+3 -3
View File
@@ -324,11 +324,11 @@ void GameWorld::Initialize()
{ {
auto tree = CreateEntity(); auto tree = CreateEntity();
auto transform = AddComponent<Components::Transform>(tree); auto transform = AddComponent<Components::Transform>(tree);
transform->Position = glm::vec3(0, 10, 0); transform->Position = glm::vec3(0, -10, 0);
auto physics = AddComponent<Components::Physics>(tree); auto physics = AddComponent<Components::Physics>(tree);
physics->Mass = 100.f; physics->Mass = 100.f;
physics->MotionType = Components::Physics::MotionTypeEnum::Dynamic; physics->MotionType = Components::Physics::MotionTypeEnum::Keyframed;
physics->CollisionEvent = false; physics->CollisionEvent = false;
//physics->LinearDamping = 3.f; //physics->LinearDamping = 3.f;
physics->CalculateCenterOfMass = true; physics->CalculateCenterOfMass = true;
@@ -565,7 +565,7 @@ void GameWorld::Initialize()
#pragma region Wall_Regin #pragma region Wall_Regin
for(int i = 0; i < 5; i++) for(int i = 10; i < 0; i++)
{ {
EntityID Wall = CreateWall(glm::vec3(i*10.f, -15.f, 0.f), glm::quat()); EntityID Wall = CreateWall(glm::vec3(i*10.f, -15.f, 0.f), glm::quat());
} }
+15 -17
View File
@@ -377,9 +377,9 @@ void Renderer::DrawWorld(RenderQueuePair &rq)
for(auto job : rq.Forward) for(auto job : rq.Forward)
{ {
glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height); glm::mat4 cameraProjection = m_Camera->ProjectionMatrix((float)m_Viewport.Width / m_Viewport.Height);
glm::mat4 cameraMatrix = cameraProjection * m_Camera->ViewMatrix(); glm::mat4 cameraMatrix = m_Camera->ViewMatrix();
glm::vec3 spritePos = glm::vec3(cameraMatrix * job->ModelMatrix * glm::vec4(1, 1, 1, 0)); glm::vec3 spritePos = glm::vec3((cameraMatrix * job->ModelMatrix) * glm::vec4(1, 1, 1, 1));
job->Depth = spritePos.z; job->Depth = spritePos.z;
} }
rq.Forward.Jobs.sort(Renderer::DepthSort); rq.Forward.Jobs.sort(Renderer::DepthSort);
@@ -389,7 +389,7 @@ void Renderer::DrawWorld(RenderQueuePair &rq)
/* /*
Base pass Base pass
*/ */
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbBasePass); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbBasePass);
glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height); glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
glScissor(m_Scissor.X, m_Height - m_Scissor.Y - m_Scissor.Height, m_Scissor.Width, m_Scissor.Height); glScissor(m_Scissor.X, m_Height - m_Scissor.Y - m_Scissor.Height, m_Scissor.Width, m_Scissor.Height);
//glViewport(0, 0, m_Width, m_Height); //glViewport(0, 0, m_Width, m_Height);
@@ -475,10 +475,10 @@ void Renderer::ForwardRendering(RenderQueue &rq)
glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height); glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
// Clear G-buffer // Clear G-buffer
GLenum attachments[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 }; GLenum attachments[] = { GL_COLOR_ATTACHMENT0, GL_NONE , GL_NONE , GL_NONE };
glDrawBuffers(4, attachments); glDrawBuffers(4, attachments);
glClearColor(0.f, 0.f, 0.f, 0.f); //glClearColor(0.f, 0.f, 0.f, 1.f);
glClear(GL_COLOR_BUFFER_BIT); //glClear(GL_COLOR_BUFFER_BIT);
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@@ -512,23 +512,21 @@ void Renderer::ForwardRendering(RenderQueue &rq)
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture); glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture);
if (modelJob->NormalTexture != 0) /*if (modelJob->NormalTexture != 0)
{ {
glActiveTexture(GL_TEXTURE2); glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture); glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture);
} }
if (modelJob->SpecularTexture) if (modelJob->SpecularTexture)
{ {
glActiveTexture(GL_TEXTURE3); glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, modelJob->SpecularTexture); glBindTexture(GL_TEXTURE_2D, modelJob->SpecularTexture);
} }*/
glDrawArrays(GL_TRIANGLES, modelJob->StartIndex, modelJob->EndIndex - modelJob->StartIndex + 1); glDrawArrays(GL_TRIANGLES, modelJob->StartIndex, modelJob->EndIndex - modelJob->StartIndex + 1);
continue; continue;
} }
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job); auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
if (spriteJob) if (spriteJob)
{ {
@@ -559,9 +557,9 @@ void Renderer::ForwardRendering(RenderQueue &rq)
glViewport(0, 0, m_Width, m_Height); glViewport(0, 0, m_Width, m_Height);
glScissor(0, 0, m_Width, m_Height); glScissor(0, 0, m_Width, m_Height);
glDepthMask(GL_FALSE);
glDisable(GL_DEPTH_TEST); glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND); glDisable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
m_FinalForwardPassProgram.Bind(); m_FinalForwardPassProgram.Bind();
//ShaderProgramHandle = m_FinalForwardPassProgram.GetHandle(); //ShaderProgramHandle = m_FinalForwardPassProgram.GetHandle();
@@ -947,7 +945,7 @@ void Renderer::FrameBufferTextures()
//Generate and bind diffuse texture //Generate and bind diffuse texture
glGenTextures(1, &m_fDiffuseTexture); glGenTextures(1, &m_fDiffuseTexture);
glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture); glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_Width, m_Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+1 -1
View File
@@ -219,7 +219,7 @@ private:
void CreateNormalMapTangent(); void CreateNormalMapTangent();
void ForwardRendering(RenderQueue &rq); void ForwardRendering(RenderQueue &rq);
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth > j->Depth); } static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
GLuint CreateQuad(); GLuint CreateQuad();
void DrawDebugShadowMap(); void DrawDebugShadowMap();