WIP
DrawScreenQuad implemented and working. Started work on HDR coloring.
This commit is contained in:
@@ -0,0 +1,38 @@
|
|||||||
|
#ifndef DrawFinalPass_h__
|
||||||
|
#define DrawFinalPass_h__
|
||||||
|
|
||||||
|
#include "IRenderer.h"
|
||||||
|
#include "DrawFinalPassState.h"
|
||||||
|
#include "LightCullingPass.h"
|
||||||
|
#include "FrameBuffer.h"
|
||||||
|
#include "ShaderProgram.h"
|
||||||
|
#include "Util/UnorderedMapVec2.h"
|
||||||
|
#include "Texture.h"
|
||||||
|
|
||||||
|
class DrawFinalPass
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass);
|
||||||
|
~DrawFinalPass() { }
|
||||||
|
void InitializeTextures();
|
||||||
|
void InitializeFrameBuffers();
|
||||||
|
void InitializeShaderPrograms();
|
||||||
|
|
||||||
|
void Draw(RenderScene& scene);
|
||||||
|
|
||||||
|
//Getters
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
||||||
|
|
||||||
|
Texture* m_WhiteTexture;
|
||||||
|
|
||||||
|
const IRenderer* m_Renderer;
|
||||||
|
const LightCullingPass* m_LightCullingPass;
|
||||||
|
|
||||||
|
ShaderProgram* m_ForwardPlusProgram;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -17,11 +17,13 @@ public:
|
|||||||
void InitializeTextures();
|
void InitializeTextures();
|
||||||
void InitializeFrameBuffers();
|
void InitializeFrameBuffers();
|
||||||
void InitializeShaderPrograms();
|
void InitializeShaderPrograms();
|
||||||
|
|
||||||
void Draw(RenderScene& scene);
|
void Draw(RenderScene& scene);
|
||||||
|
|
||||||
//Getters
|
//Todo: Should not be public
|
||||||
|
FrameBuffer m_BloomFrameBuffer;
|
||||||
|
GLuint m_BloomTexture;
|
||||||
|
GLuint m_SceneTexture;
|
||||||
|
GLuint m_DepthBuffer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
||||||
@@ -32,7 +34,6 @@ private:
|
|||||||
const LightCullingPass* m_LightCullingPass;
|
const LightCullingPass* m_LightCullingPass;
|
||||||
|
|
||||||
ShaderProgram* m_ForwardPlusProgram;
|
ShaderProgram* m_ForwardPlusProgram;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
#ifndef DrawScreenQuadPass_h__
|
||||||
|
#define DrawScreenQuadPass_h__
|
||||||
|
|
||||||
|
#include "IRenderer.h"
|
||||||
|
#include "DrawScreenQuadPassState.h"
|
||||||
|
#include "FrameBuffer.h"
|
||||||
|
#include "ShaderProgram.h"
|
||||||
|
//#include "Util/UnorderedMapVec2.h"
|
||||||
|
#include "Texture.h"
|
||||||
|
|
||||||
|
class DrawScreenQuadPass
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DrawScreenQuadPass(IRenderer* renderer);
|
||||||
|
~DrawScreenQuadPass() { }
|
||||||
|
void InitializeFrameBuffers();
|
||||||
|
void InitializeShaderPrograms();
|
||||||
|
|
||||||
|
void Draw(GLuint texture);
|
||||||
|
private:
|
||||||
|
const IRenderer* m_Renderer;
|
||||||
|
|
||||||
|
ShaderProgram* m_DrawQuadProgram;
|
||||||
|
|
||||||
|
Model* m_ScreenQuad;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#ifndef DrawScreenQuadPassState_h__
|
||||||
|
#define DrawScreenQuadPassState_h__
|
||||||
|
|
||||||
|
#include "Rendering/RenderState.h"
|
||||||
|
|
||||||
|
class DrawScreenQuadPassState : public RenderState
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DrawScreenQuadPassState();
|
||||||
|
~DrawScreenQuadPassState();
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "DrawScenePass.h"
|
#include "DrawScenePass.h"
|
||||||
#include "LightCullingPass.h"
|
#include "LightCullingPass.h"
|
||||||
#include "DrawFinalPass.h"
|
#include "DrawFinalPass.h"
|
||||||
|
#include "DrawScreenQuadPass.h"
|
||||||
#include "../Core/EventBroker.h"
|
#include "../Core/EventBroker.h"
|
||||||
#include "ImGuiRenderPass.h"
|
#include "ImGuiRenderPass.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
@@ -48,6 +49,7 @@ private:
|
|||||||
LightCullingPass* m_LightCullingPass;
|
LightCullingPass* m_LightCullingPass;
|
||||||
ImGuiRenderPass* m_ImGuiRenderPass;
|
ImGuiRenderPass* m_ImGuiRenderPass;
|
||||||
DrawFinalPass* m_DrawFinalPass;
|
DrawFinalPass* m_DrawFinalPass;
|
||||||
|
DrawScreenQuadPass* m_DrawScreenQuadPass;
|
||||||
|
|
||||||
//----------------------Functions----------------------//
|
//----------------------Functions----------------------//
|
||||||
void InitializeWindow();
|
void InitializeWindow();
|
||||||
@@ -57,14 +59,13 @@ private:
|
|||||||
//TODO: Renderer: Get InputUpdate out of renderer
|
//TODO: Renderer: Get InputUpdate out of renderer
|
||||||
void InputUpdate(double dt);
|
void InputUpdate(double dt);
|
||||||
//void PickingPass(RenderQueueCollection& rq);
|
//void PickingPass(RenderQueueCollection& rq);
|
||||||
void DrawScreenQuad(GLuint textureToDraw);
|
//void DrawScreenQuad(GLuint textureToDraw);
|
||||||
|
|
||||||
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); }
|
||||||
void SortRenderJobsByDepth(RenderScene &scene);
|
void SortRenderJobsByDepth(RenderScene &scene);
|
||||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type);
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type);
|
||||||
//--------------------ShaderPrograms-------------------//
|
//--------------------ShaderPrograms-------------------//
|
||||||
ShaderProgram* m_BasicForwardProgram;
|
ShaderProgram* m_BasicForwardProgram;
|
||||||
ShaderProgram* m_DrawScreenQuadProgram;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -48,7 +48,8 @@ in VertexData{
|
|||||||
vec4 DiffuseColor;
|
vec4 DiffuseColor;
|
||||||
}Input;
|
}Input;
|
||||||
|
|
||||||
out vec4 fragmentColor;
|
out vec4 sceneColor;
|
||||||
|
out vec4 bloomColor;
|
||||||
|
|
||||||
vec4 scene_ambient = vec4(0.3,0.3,0.3,1);
|
vec4 scene_ambient = vec4(0.3,0.3,0.3,1);
|
||||||
|
|
||||||
@@ -121,6 +122,7 @@ void main()
|
|||||||
LightSource light = LightSources.List[l];
|
LightSource light = LightSources.List[l];
|
||||||
|
|
||||||
LightResult result;
|
LightResult result;
|
||||||
|
//These if statements should be removed.
|
||||||
if(light.Type == 1) { // point
|
if(light.Type == 1) { // point
|
||||||
result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff);
|
result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff);
|
||||||
} else if (light.Type == 2) { //Directional
|
} else if (light.Type == 2) { //Directional
|
||||||
@@ -131,19 +133,29 @@ void main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//fragmentColor += Input.DiffuseColor;
|
//sceneColor += Input.DiffuseColor;
|
||||||
fragmentColor += Input.DiffuseColor * (totalLighting.Diffuse + totalLighting.Specular) * texel * Color;
|
vec4 fragment = Input.DiffuseColor * (totalLighting.Diffuse + totalLighting.Specular) * texel * Color;
|
||||||
//fragmentColor += Input.DiffuseColor * (totalLighting.Diffuse) * texel * Color;
|
bloomColor = vec4(0.3, 0.8, 0.6, 1.0);
|
||||||
//fragmentColor += Input.DiffuseColor + vec4(0.0, LightGrids.Data[currentTile].Amount/3, 0, 1);
|
sceneColor = vec4(fragment.xyz, 1.0);
|
||||||
//fragmentColor = texel * Input.DiffuseColor * Color;
|
//These if statements should be removed.
|
||||||
//fragmentColor += vec4(currentTile/3600.f, 0, 0, 1);
|
/*
|
||||||
|
if(fragment.x > 0.5 || fragment.y > 0.5 || fragment.z > 0.5) {
|
||||||
|
bloomColor = fragment;
|
||||||
|
} else {
|
||||||
|
bloomColor = vec4(0.3, 0.5, 0.8, 1.0);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
//sceneColor += Input.DiffuseColor * (totalLighting.Diffuse) * texel * Color;
|
||||||
|
//sceneColor += Input.DiffuseColor + vec4(0.0, LightGrids.Data[currentTile].Amount/3, 0, 1);
|
||||||
|
//sceneColor = texel * Input.DiffuseColor * Color;
|
||||||
|
//sceneColor += vec4(currentTile/3600.f, 0, 0, 1);
|
||||||
|
|
||||||
//Tiled Debug Code
|
//Tiled Debug Code
|
||||||
/*
|
/*
|
||||||
if(int(gl_FragCoord.x)%16 == 0 || int(gl_FragCoord.y)%16 == 0 ) {
|
if(int(gl_FragCoord.x)%16 == 0 || int(gl_FragCoord.y)%16 == 0 ) {
|
||||||
fragmentColor += vec4(0.5, 0, 0, 0);
|
sceneColor += vec4(0.5, 0, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
fragmentColor += vec4(LightGrids.Data[int(tilePos.x + tilePos.y*80)].Amount/LightSources.List.length(), 0, 0, 1);
|
sceneColor += vec4(LightGrids.Data[int(tilePos.x + tilePos.y*80)].Amount/LightSources.List.length(), 0, 0, 1);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
#include "Rendering/DrawFinalPass.h"
|
||||||
|
|
||||||
|
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass)
|
||||||
|
{
|
||||||
|
m_Renderer = renderer;
|
||||||
|
m_LightCullingPass = lightCullingPass;
|
||||||
|
InitializeTextures();
|
||||||
|
InitializeShaderPrograms();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawFinalPass::InitializeTextures()
|
||||||
|
{
|
||||||
|
m_WhiteTexture = ResourceManager::Load<Texture>("Textures/Core/Blank.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawFinalPass::InitializeShaderPrograms()
|
||||||
|
{
|
||||||
|
m_ForwardPlusProgram = ResourceManager::Load<ShaderProgram>("#ForwardPlusProgram");
|
||||||
|
m_ForwardPlusProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlus.vert.glsl")));
|
||||||
|
m_ForwardPlusProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlus.frag.glsl")));
|
||||||
|
m_ForwardPlusProgram->Compile();
|
||||||
|
m_ForwardPlusProgram->Link();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawFinalPass::Draw(RenderScene& scene)
|
||||||
|
{
|
||||||
|
GLERROR("DrawFinalPass::Draw: Pre");
|
||||||
|
|
||||||
|
DrawFinalPassState state;
|
||||||
|
m_ForwardPlusProgram->Bind();
|
||||||
|
GLuint shaderHandle = m_ForwardPlusProgram->GetHandle();
|
||||||
|
|
||||||
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO());
|
||||||
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
|
||||||
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
|
||||||
|
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_Renderer->Camera()->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(m_Renderer->Camera()->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
|
||||||
|
|
||||||
|
//TODO: Render: Add code for more jobs than modeljobs.
|
||||||
|
for (auto &job : scene.ForwardJobs) {
|
||||||
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
|
if(modelJob) {
|
||||||
|
//TODO: Kolla upp "header/include/common" shader saken så man slipper skicka in asmycket uniforms
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
|
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(modelJob->Color));
|
||||||
|
|
||||||
|
if(modelJob->DiffuseTexture != nullptr) {
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture->m_Texture);
|
||||||
|
} else {
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
|
||||||
|
}
|
||||||
|
|
||||||
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, 0, modelJob->StartIndex);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GLERROR("DrawFinalPass::Draw: END");
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCulling
|
|||||||
m_LightCullingPass = lightCullingPass;
|
m_LightCullingPass = lightCullingPass;
|
||||||
InitializeTextures();
|
InitializeTextures();
|
||||||
InitializeShaderPrograms();
|
InitializeShaderPrograms();
|
||||||
|
InitializeFrameBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::InitializeTextures()
|
void DrawFinalPass::InitializeTextures()
|
||||||
@@ -13,6 +14,21 @@ void DrawFinalPass::InitializeTextures()
|
|||||||
m_WhiteTexture = ResourceManager::Load<Texture>("Textures/Core/Blank.png");
|
m_WhiteTexture = ResourceManager::Load<Texture>("Textures/Core/Blank.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawFinalPass::InitializeFrameBuffers()
|
||||||
|
{
|
||||||
|
glGenRenderbuffers(1, &m_DepthBuffer);
|
||||||
|
glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer);
|
||||||
|
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
|
||||||
|
|
||||||
|
GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->Resolution().Width, m_Renderer->Resolution().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
|
GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->Resolution().Width, m_Renderer->Resolution().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
|
|
||||||
|
m_BloomFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_ATTACHMENT)));
|
||||||
|
m_BloomFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SceneTexture, GL_COLOR_ATTACHMENT0)));
|
||||||
|
m_BloomFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1)));
|
||||||
|
m_BloomFrameBuffer.Generate();
|
||||||
|
}
|
||||||
|
|
||||||
void DrawFinalPass::InitializeShaderPrograms()
|
void DrawFinalPass::InitializeShaderPrograms()
|
||||||
{
|
{
|
||||||
m_ForwardPlusProgram = ResourceManager::Load<ShaderProgram>("#ForwardPlusProgram");
|
m_ForwardPlusProgram = ResourceManager::Load<ShaderProgram>("#ForwardPlusProgram");
|
||||||
@@ -26,6 +42,8 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
|||||||
{
|
{
|
||||||
GLERROR("DrawFinalPass::Draw: Pre");
|
GLERROR("DrawFinalPass::Draw: Pre");
|
||||||
|
|
||||||
|
m_BloomFrameBuffer.Bind(); //in i state
|
||||||
|
|
||||||
DrawFinalPassState state;
|
DrawFinalPassState state;
|
||||||
m_ForwardPlusProgram->Bind();
|
m_ForwardPlusProgram->Bind();
|
||||||
GLuint shaderHandle = m_ForwardPlusProgram->GetHandle();
|
GLuint shaderHandle = m_ForwardPlusProgram->GetHandle();
|
||||||
@@ -64,3 +82,15 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
|||||||
GLERROR("DrawFinalPass::Draw: END");
|
GLERROR("DrawFinalPass::Draw: END");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawFinalPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
||||||
|
{
|
||||||
|
glGenTextures(1, texture);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, *texture);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
|
||||||
|
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, nullptr);//TODO: Renderer: Fix the precision and Resolution
|
||||||
|
GLERROR("Texture initialization failed");
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
DrawFinalPassState::DrawFinalPassState()
|
DrawFinalPassState::DrawFinalPassState()
|
||||||
{
|
{
|
||||||
BindFramebuffer(0);
|
//BindFramebuffer(0);
|
||||||
Enable(GL_BLEND);
|
Enable(GL_BLEND);
|
||||||
BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
Enable(GL_DEPTH_TEST);
|
Enable(GL_DEPTH_TEST);
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#include "Rendering/DrawScreenQuadPass.h"
|
||||||
|
|
||||||
|
DrawScreenQuadPass::DrawScreenQuadPass(IRenderer* renderer)
|
||||||
|
{
|
||||||
|
m_Renderer = renderer;
|
||||||
|
|
||||||
|
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.obj");
|
||||||
|
|
||||||
|
InitializeShaderPrograms();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawScreenQuadPass::InitializeShaderPrograms()
|
||||||
|
{
|
||||||
|
m_DrawQuadProgram = ResourceManager::Load<ShaderProgram>("#DrawScreenQuadProgram");
|
||||||
|
m_DrawQuadProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/DrawScreenQuad.vert.glsl")));
|
||||||
|
m_DrawQuadProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/DrawScreenQuad.frag.glsl")));
|
||||||
|
m_DrawQuadProgram->Compile();
|
||||||
|
m_DrawQuadProgram->Link();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawScreenQuadPass::Draw(GLuint texture)
|
||||||
|
{
|
||||||
|
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
GLERROR("DrawScreenQuadPass::Draw: Pre");
|
||||||
|
|
||||||
|
DrawScreenQuadPassState state = DrawScreenQuadPassState();
|
||||||
|
m_DrawQuadProgram->Bind();
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
|
|
||||||
|
glBindVertexArray(m_ScreenQuad->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
||||||
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
||||||
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#include "Rendering/DrawScreenQuadPassState.h"
|
||||||
|
|
||||||
|
|
||||||
|
DrawScreenQuadPassState::DrawScreenQuadPassState()
|
||||||
|
{
|
||||||
|
GLERROR("---");
|
||||||
|
BindFramebuffer(0);
|
||||||
|
GLERROR("---");
|
||||||
|
Disable(GL_DEPTH_TEST);
|
||||||
|
Disable(GL_CULL_FACE);
|
||||||
|
Disable(GL_BLEND);
|
||||||
|
glClearColor(0.f, 0.f, 0.f, 1.f);
|
||||||
|
// ClearColor(glm::vec4(255.f / 255, 163.f / 255, 176.f / 255, 0.f));
|
||||||
|
Clear(GL_COLOR_BUFFER_BIT);
|
||||||
|
}
|
||||||
|
|
||||||
|
DrawScreenQuadPassState::~DrawScreenQuadPassState()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -55,8 +55,9 @@ void FrameBuffer::Generate()
|
|||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle);
|
||||||
GLERROR("FrameBuffer generate: glFramebufferRenderbuffer");
|
GLERROR("FrameBuffer generate: glFramebufferRenderbuffer");
|
||||||
if ( (*it)->m_Attachment != GL_COLOR_ATTACHMENT0 ||
|
if ( (*it)->m_Attachment != GL_COLOR_ATTACHMENT0 ||
|
||||||
|
(*it)->m_Attachment != GL_COLOR_ATTACHMENT1 ||
|
||||||
(*it)->m_Attachment != GL_DEPTH_ATTACHMENT ||
|
(*it)->m_Attachment != GL_DEPTH_ATTACHMENT ||
|
||||||
(*it)->m_Attachment != GL_STENCIL_ATTACHMENT)
|
(*it)->m_Attachment != GL_STENCIL_ATTACHMENT) //TODO: Viktor: Fixa detta
|
||||||
{
|
{
|
||||||
LOG_ERROR("RenderBuffer Attachment not valid.");
|
LOG_ERROR("RenderBuffer Attachment not valid.");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,15 +46,12 @@ void PickingPass::InitializeShaderPrograms()
|
|||||||
void PickingPass::Draw(RenderScene& scene)
|
void PickingPass::Draw(RenderScene& scene)
|
||||||
{
|
{
|
||||||
PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle());
|
PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle());
|
||||||
|
|
||||||
|
|
||||||
//TODO: Render: Add code for more jobs than modeljobs.
|
//TODO: Render: Add code for more jobs than modeljobs.
|
||||||
|
|
||||||
GLuint ShaderHandle = m_PickingProgram->GetHandle();
|
GLuint ShaderHandle = m_PickingProgram->GetHandle();
|
||||||
m_PickingProgram->Bind();
|
m_PickingProgram->Bind();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_Camera = scene.Camera;
|
m_Camera = scene.Camera;
|
||||||
|
|
||||||
for (auto &job : scene.ForwardJobs) {
|
for (auto &job : scene.ForwardJobs) {
|
||||||
@@ -95,11 +92,9 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
m_PickingBuffer.Unbind();
|
m_PickingBuffer.Unbind();
|
||||||
GLERROR("PickingPass Error");
|
GLERROR("PickingPass Error");
|
||||||
|
|
||||||
|
|
||||||
delete state;
|
delete state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,12 +69,6 @@ void Renderer::InitializeWindow()
|
|||||||
void Renderer::InitializeShaders()
|
void Renderer::InitializeShaders()
|
||||||
{
|
{
|
||||||
m_BasicForwardProgram = ResourceManager::Load<ShaderProgram>("#m_BasicForwardProgram");
|
m_BasicForwardProgram = ResourceManager::Load<ShaderProgram>("#m_BasicForwardProgram");
|
||||||
|
|
||||||
m_DrawScreenQuadProgram = ResourceManager::Load<ShaderProgram>("#DrawScreenQuadProgram");
|
|
||||||
m_DrawScreenQuadProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/DrawScreenQuad.vert.glsl")));
|
|
||||||
m_DrawScreenQuadProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/DrawScreenQuad.frag.glsl")));
|
|
||||||
m_DrawScreenQuadProgram->Compile();
|
|
||||||
m_DrawScreenQuadProgram->Link();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::InputUpdate(double dt)
|
void Renderer::InputUpdate(double dt)
|
||||||
@@ -105,6 +99,8 @@ void Renderer::Draw(RenderFrame& frame)
|
|||||||
m_LightCullingPass->FillLightList(*scene);
|
m_LightCullingPass->FillLightList(*scene);
|
||||||
m_LightCullingPass->CullLights(*scene);
|
m_LightCullingPass->CullLights(*scene);
|
||||||
m_DrawFinalPass->Draw(*scene);
|
m_DrawFinalPass->Draw(*scene);
|
||||||
|
m_DrawScreenQuadPass->Draw(m_DrawFinalPass->m_SceneTexture);
|
||||||
|
//m_DrawScreenQuadPass->Draw(m_DrawFinalPass->m_BloomTexture);
|
||||||
//m_DrawScenePass->Draw(rq);
|
//m_DrawScenePass->Draw(rq);
|
||||||
|
|
||||||
GLERROR("Renderer::Draw m_DrawScenePass->Draw");
|
GLERROR("Renderer::Draw m_DrawScenePass->Draw");
|
||||||
@@ -119,27 +115,6 @@ PickData Renderer::Pick(glm::vec2 screenCoord)
|
|||||||
return m_PickingPass->Pick(screenCoord);
|
return m_PickingPass->Pick(screenCoord);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::DrawScreenQuad(GLuint textureToDraw)
|
|
||||||
{
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
||||||
|
|
||||||
glDisable(GL_DEPTH_TEST);
|
|
||||||
glDisable(GL_CULL_FACE);
|
|
||||||
|
|
||||||
glClearColor(0.f, 0.f, 0.f, 1.f);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
|
|
||||||
|
|
||||||
m_DrawScreenQuadProgram->Bind();
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, textureToDraw);
|
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Renderer::InitializeTextures()
|
void Renderer::InitializeTextures()
|
||||||
{
|
{
|
||||||
m_ErrorTexture = ResourceManager::Load<Texture>("Textures/Core/ErrorTexture.png");
|
m_ErrorTexture = ResourceManager::Load<Texture>("Textures/Core/ErrorTexture.png");
|
||||||
@@ -171,4 +146,5 @@ void Renderer::InitializeRenderPasses()
|
|||||||
m_PickingPass = new PickingPass(this, m_EventBroker);
|
m_PickingPass = new PickingPass(this, m_EventBroker);
|
||||||
m_LightCullingPass = new LightCullingPass(this);
|
m_LightCullingPass = new LightCullingPass(this);
|
||||||
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass);
|
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass);
|
||||||
|
m_DrawScreenQuadPass = new DrawScreenQuadPass(this);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user