Basic transparancy working.
This commit is contained in:
@@ -9,7 +9,9 @@
|
||||
#include "Camera.h"
|
||||
#include "RenderQueue.h"
|
||||
#include "Model.h"
|
||||
#include "../Core/World.h"
|
||||
#include "../Core/World.h" //So temp
|
||||
#include "RenderQueueFactory.h" //So temp
|
||||
|
||||
|
||||
class IRenderer
|
||||
{
|
||||
|
||||
@@ -35,6 +35,8 @@ private:
|
||||
//----------------------Variables----------------------//
|
||||
EventBroker* m_EventBroker;
|
||||
|
||||
int m_bi = 0;
|
||||
|
||||
std::shared_ptr<DebugCameraInputController<Renderer>> m_DebugCameraInputController;
|
||||
|
||||
Texture* m_ErrorTexture;
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
DrawFinalPassState::DrawFinalPassState()
|
||||
{
|
||||
BindFramebuffer(0);
|
||||
|
||||
Enable(GL_BLEND);
|
||||
BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
Enable(GL_DEPTH_TEST);
|
||||
Enable(GL_CULL_FACE);
|
||||
ClearColor(glm::vec4(200.f / 255, 0.f / 255, 200.f / 255, 0.f));
|
||||
|
||||
@@ -68,7 +68,7 @@ void PickingPass::Draw(RenderQueueCollection& rq)
|
||||
pickColor[1] = color->second[1];
|
||||
} else {
|
||||
entityColors[modelJob->Entity] = glm::vec2(pickColor[0], pickColor[1]);
|
||||
if (r + 10 > 255) {
|
||||
if (r + 1 > 255) {
|
||||
r = 0;
|
||||
g += 1;
|
||||
} else {
|
||||
|
||||
@@ -91,7 +91,14 @@ void Renderer::Update(double dt)
|
||||
void Renderer::Draw(RenderQueueCollection& rq)
|
||||
{
|
||||
FillDepth(rq);
|
||||
|
||||
if (m_bi == 1) {
|
||||
for (auto i : rq.Forward) {
|
||||
printf("D: %f| \n", i->Depth);
|
||||
}
|
||||
m_bi = 0;
|
||||
printf("------THE END------");
|
||||
}
|
||||
m_bi++;
|
||||
m_PickingPass->Draw(rq);
|
||||
//DrawScreenQuad(m_PickingPass->PickingTexture());
|
||||
m_LightCullingPass->FillLightList(rq);
|
||||
@@ -128,8 +135,8 @@ void Renderer::DrawScreenQuad(GLuint textureToDraw)
|
||||
|
||||
void Renderer::InitializeTextures()
|
||||
{
|
||||
m_ErrorTexture=ResourceManager::Load<Texture>("Textures/Core/ErrorTexture.png");
|
||||
m_WhiteTexture=ResourceManager::Load<Texture>("Textures/Core/Blank.png");
|
||||
m_ErrorTexture = ResourceManager::Load<Texture>("Textures/Core/ErrorTexture.png");
|
||||
m_WhiteTexture = ResourceManager::Load<Texture>("Textures/Core/Blank.png");
|
||||
}
|
||||
|
||||
void Renderer::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type)
|
||||
@@ -140,7 +147,7 @@ void Renderer::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filterin
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, dimensions.x, dimensions.y, 0, format, type, NULL);//TODO: Renderer: Fix the precision and Resolution
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, dimensions.x, dimensions.y, 0, format, type, nullptr);//TODO: Renderer: Fix the precision and Resolution
|
||||
GLERROR("Texture initialization failed");
|
||||
}
|
||||
|
||||
@@ -152,14 +159,14 @@ void Renderer::InitializeRenderPasses()
|
||||
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass);
|
||||
}
|
||||
|
||||
//Temp func
|
||||
void Renderer::FillDepth(RenderQueueCollection& rq)
|
||||
{
|
||||
for(auto job : rq.Forward)
|
||||
{
|
||||
for(auto job : rq.Forward) {
|
||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||
glm::vec3 pos = m_World->GetComponent(modelJob->Entity, "Transform")["Position"];
|
||||
glm::vec3 worldpos = glm::vec3((m_Camera->ViewMatrix() * modelJob->ModelMatrix) * glm::vec4(pos, 1));
|
||||
job->Depth = worldpos.z;
|
||||
glm::vec3 abspos = RenderQueueFactory::AbsolutePosition(m_World, modelJob->Entity);
|
||||
glm::vec3 worldpos = glm::vec3(m_Camera->ViewMatrix() * glm::vec4(abspos, 1));
|
||||
modelJob->Depth = worldpos.z;
|
||||
}
|
||||
rq.Forward.Sort();
|
||||
rq.Forward.Jobs.sort(Renderer::DepthSort);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user