Defender shield should now be working
This commit is contained in:
@@ -17,7 +17,7 @@ public:
|
|||||||
void InitializeFrameBuffers();
|
void InitializeFrameBuffers();
|
||||||
void InitializeShaderPrograms();
|
void InitializeShaderPrograms();
|
||||||
|
|
||||||
void Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure);
|
void Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLfloat gamma, GLfloat exposure);
|
||||||
private:
|
private:
|
||||||
const IRenderer* m_Renderer;
|
const IRenderer* m_Renderer;
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ private:
|
|||||||
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
||||||
void DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
void DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
||||||
void DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
void DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
||||||
|
void DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
||||||
|
|
||||||
void BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene);
|
void BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene);
|
||||||
void BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene);
|
void BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene);
|
||||||
@@ -57,6 +58,10 @@ private:
|
|||||||
GLuint m_BloomTextureLowRes;
|
GLuint m_BloomTextureLowRes;
|
||||||
GLuint m_SceneTextureLowRes;
|
GLuint m_SceneTextureLowRes;
|
||||||
GLuint m_DepthBuffer;
|
GLuint m_DepthBuffer;
|
||||||
|
GLuint m_DepthBufferLowRes;
|
||||||
|
|
||||||
|
//maqke this component based i guess?
|
||||||
|
GLuint m_ShieldPixelRate = 16;
|
||||||
|
|
||||||
const IRenderer* m_Renderer;
|
const IRenderer* m_Renderer;
|
||||||
const LightCullingPass* m_LightCullingPass;
|
const LightCullingPass* m_LightCullingPass;
|
||||||
@@ -64,6 +69,7 @@ private:
|
|||||||
ShaderProgram* m_ForwardPlusProgram;
|
ShaderProgram* m_ForwardPlusProgram;
|
||||||
ShaderProgram* m_ExplosionEffectProgram;
|
ShaderProgram* m_ExplosionEffectProgram;
|
||||||
ShaderProgram* m_ShieldToStencilProgram;
|
ShaderProgram* m_ShieldToStencilProgram;
|
||||||
|
ShaderProgram* m_FillDepthBufferProgram;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
layout (binding = 0) uniform sampler2D SceneTexture;
|
layout (binding = 0) uniform sampler2D SceneTexture;
|
||||||
layout (binding = 1) uniform sampler2D BloomTexture;
|
layout (binding = 1) uniform sampler2D BloomTexture;
|
||||||
|
layout (binding = 2) uniform sampler2D SceneTextureLowRes;
|
||||||
|
layout (binding = 3) uniform sampler2D BloomTextureLowRes;
|
||||||
uniform float Exposure;
|
uniform float Exposure;
|
||||||
uniform float Gamma;
|
uniform float Gamma;
|
||||||
|
|
||||||
@@ -15,10 +17,19 @@ void main()
|
|||||||
{
|
{
|
||||||
vec4 hdrColor = texture(SceneTexture, Input.TextureCoordinate);
|
vec4 hdrColor = texture(SceneTexture, Input.TextureCoordinate);
|
||||||
vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate);
|
vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate);
|
||||||
|
vec4 hdrColorLowRes = texture(SceneTextureLowRes, Input.TextureCoordinate);
|
||||||
|
vec4 bloomColorLowRes = texture(BloomTextureLowRes, Input.TextureCoordinate);
|
||||||
hdrColor += bloomColor;
|
hdrColor += bloomColor;
|
||||||
|
hdrColorLowRes;
|
||||||
|
|
||||||
|
float hdrColorsum = hdrColorLowRes.r + hdrColorLowRes.g + hdrColorLowRes.b;
|
||||||
//Toon mapping thingy
|
//Toon mapping thingy
|
||||||
vec3 result = vec3(1.0) - exp(-hdrColor.rgb * Exposure);
|
vec3 result;
|
||||||
|
if(hdrColorsum > 0.0) {
|
||||||
|
result = vec3(1.0) - exp(-hdrColorLowRes.rgb * Exposure);
|
||||||
|
} else {
|
||||||
|
result = vec3(1.0) - exp(-hdrColor.rgb * Exposure);
|
||||||
|
}
|
||||||
|
|
||||||
//gamme correction
|
//gamme correction
|
||||||
result = pow(result, vec3(1.0 / Gamma));
|
result = pow(result, vec3(1.0 / Gamma));
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
in VertexData{
|
||||||
|
vec3 Position;
|
||||||
|
}Input;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
uniform mat4 M;
|
||||||
|
uniform mat4 V;
|
||||||
|
uniform mat4 P;
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 Position;
|
||||||
|
layout(location = 5) in vec4 BoneIndices;
|
||||||
|
layout(location = 6) in vec4 BoneWeights;
|
||||||
|
|
||||||
|
|
||||||
|
out VertexData{
|
||||||
|
vec3 Position;
|
||||||
|
}Output;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = P * V * M * vec4(Position, 1.0);
|
||||||
|
|
||||||
|
Output.Position = Position;
|
||||||
|
}
|
||||||
@@ -9,7 +9,7 @@ out vec4 fragmentColor;
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
fragmentColor = vec4(0.5, 0.5, 0.5, 0.2);
|
fragmentColor = vec4(0.5, 0.0, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ DrawColorCorrectionPass::DrawColorCorrectionPass(IRenderer* renderer)
|
|||||||
|
|
||||||
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
|
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
|
||||||
|
|
||||||
//m_Exposure = 0.4; //TODO: Renderer: Fixa så att denna går att ändra på genom komponent eller setting.
|
|
||||||
|
|
||||||
InitializeShaderPrograms();
|
InitializeShaderPrograms();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -20,7 +18,7 @@ void DrawColorCorrectionPass::InitializeShaderPrograms()
|
|||||||
m_ColorCorrectionProgram->Link();
|
m_ColorCorrectionProgram->Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure)
|
void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLfloat gamma, GLfloat exposure)
|
||||||
{
|
{
|
||||||
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
GLERROR("DrawScreenQuadPass::Draw: Pre");
|
GLERROR("DrawScreenQuadPass::Draw: Pre");
|
||||||
@@ -35,6 +33,10 @@ void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLf
|
|||||||
glBindTexture(GL_TEXTURE_2D, sceneTexture);
|
glBindTexture(GL_TEXTURE_2D, sceneTexture);
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, bloomTexture);
|
glBindTexture(GL_TEXTURE_2D, bloomTexture);
|
||||||
|
glActiveTexture(GL_TEXTURE2);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, sceneTextureLowRes);
|
||||||
|
glActiveTexture(GL_TEXTURE3);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, bloomTextureLowRes);
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
glBindVertexArray(m_ScreenQuad->VAO);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
||||||
|
|||||||
@@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass)
|
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass)
|
||||||
{
|
{
|
||||||
|
//TODO: Make sure that uniforms are not sent into shader if not needed.
|
||||||
m_Renderer = renderer;
|
m_Renderer = renderer;
|
||||||
m_LightCullingPass = lightCullingPass;
|
m_LightCullingPass = lightCullingPass;
|
||||||
|
m_ShieldPixelRate = 8;
|
||||||
InitializeTextures();
|
InitializeTextures();
|
||||||
InitializeShaderPrograms();
|
InitializeShaderPrograms();
|
||||||
InitializeFrameBuffers();
|
InitializeFrameBuffers();
|
||||||
@@ -37,13 +39,18 @@ void DrawFinalPass::InitializeFrameBuffers()
|
|||||||
m_FinalPassFrameBuffer.Generate();
|
m_FinalPassFrameBuffer.Generate();
|
||||||
GLERROR("FBO generation");
|
GLERROR("FBO generation");
|
||||||
|
|
||||||
GenerateTexture(&m_SceneTextureLowRes, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width/16, m_Renderer->GetViewportSize().Height/16), GL_RGB16F, GL_RGB, GL_FLOAT);
|
glGenRenderbuffers(1, &m_DepthBufferLowRes);
|
||||||
|
glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBufferLowRes);
|
||||||
|
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, (int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate));
|
||||||
|
GLERROR("RenderBufferLowRes generation");
|
||||||
|
|
||||||
|
GenerateTexture(&m_SceneTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
//GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
//GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
GenerateTexture(&m_BloomTextureLowRes, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width/16, m_Renderer->GetViewportSize().Height/16), GL_RGB16F, GL_RGB, GL_FLOAT);
|
GenerateTexture(&m_BloomTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
//GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4);
|
//GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4);
|
||||||
//GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT);
|
//GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT);
|
||||||
|
|
||||||
m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT)));
|
m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBufferLowRes, GL_DEPTH_STENCIL_ATTACHMENT)));
|
||||||
//m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_StencilTexture, GL_STENCIL_ATTACHMENT)));
|
//m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_StencilTexture, GL_STENCIL_ATTACHMENT)));
|
||||||
m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SceneTextureLowRes, GL_COLOR_ATTACHMENT0)));
|
m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SceneTextureLowRes, GL_COLOR_ATTACHMENT0)));
|
||||||
m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTextureLowRes, GL_COLOR_ATTACHMENT1)));
|
m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTextureLowRes, GL_COLOR_ATTACHMENT1)));
|
||||||
@@ -79,6 +86,12 @@ void DrawFinalPass::InitializeShaderPrograms()
|
|||||||
m_ShieldToStencilProgram->Link();
|
m_ShieldToStencilProgram->Link();
|
||||||
GLERROR("Creating Shield program");
|
GLERROR("Creating Shield program");
|
||||||
|
|
||||||
|
m_FillDepthBufferProgram = ResourceManager::Load<ShaderProgram>("#FillDepthBufferProgram");
|
||||||
|
m_FillDepthBufferProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FillDepthBuffer.vert.glsl")));
|
||||||
|
m_FillDepthBufferProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl")));
|
||||||
|
m_FillDepthBufferProgram->Compile();
|
||||||
|
m_FillDepthBufferProgram->Link();
|
||||||
|
GLERROR("Creating DepthFill program");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::Draw(RenderScene& scene)
|
void DrawFinalPass::Draw(RenderScene& scene)
|
||||||
@@ -122,36 +135,59 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
|||||||
|
|
||||||
DrawFinalPassState* stateLowRes = new DrawFinalPassState(m_FinalPassFrameBufferLowRes.GetHandle());
|
DrawFinalPassState* stateLowRes = new DrawFinalPassState(m_FinalPassFrameBufferLowRes.GetHandle());
|
||||||
//Draw the lowres texture that will be shown behind the shield.
|
//Draw the lowres texture that will be shown behind the shield.
|
||||||
if (scene.ClearDepth) {
|
state->Enable(GL_SCISSOR_TEST);
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
state->Enable(GL_DEPTH_TEST);
|
||||||
}
|
//TODO: Viewports and scissor should be in state
|
||||||
//TODO: Do we need check for this or will it be per scene always?
|
glViewport(0, 0, m_Renderer->GetViewportSize().Width/m_ShieldPixelRate, m_Renderer->GetViewportSize().Height/m_ShieldPixelRate);
|
||||||
//glClearStencil(0x00);
|
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
//glClear(GL_STENCIL_BUFFER_BIT);
|
|
||||||
|
|
||||||
//state->StencilMask(0x00);
|
glClearStencil(0x00);
|
||||||
//state->StencilFunc(GL_ALWAYS, 1, 0xFF);
|
glClear(GL_STENCIL_BUFFER_BIT);
|
||||||
state->Disable(GL_STENCIL_TEST);
|
|
||||||
state->Disable(GL_DEPTH_TEST);
|
//TODO: This should not be here...
|
||||||
|
state->StencilFunc(GL_ALWAYS, 1, 0xFF);
|
||||||
|
state->StencilMask(0x00);
|
||||||
|
DrawToDepthBuffer(scene.Jobs.OpaqueObjects, scene);
|
||||||
|
DrawToDepthBuffer(scene.Jobs.TransparentObjects, scene);
|
||||||
|
|
||||||
|
//Draw shields to stencil pass
|
||||||
|
state->StencilFunc(GL_ALWAYS, 1, 0xFF);
|
||||||
|
state->StencilMask(0xFF);
|
||||||
|
state->Enable(GL_DEPTH_TEST);
|
||||||
|
DrawShieldToStencilBuffer(scene.Jobs.ShieldObjects, scene);
|
||||||
|
GLERROR("StencilPass");
|
||||||
|
|
||||||
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
state->Enable(GL_DEPTH_TEST);
|
||||||
|
state->StencilFunc(GL_LEQUAL, 1, 0xFF);
|
||||||
|
state->StencilMask(0x00);
|
||||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
||||||
GLERROR("OpaqueObjects");
|
GLERROR("OpaqueObjects");
|
||||||
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
||||||
GLERROR("TransparentObjects");
|
GLERROR("TransparentObjects");
|
||||||
|
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
delete stateLowRes;
|
delete stateLowRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DrawFinalPass::ClearBuffer()
|
void DrawFinalPass::ClearBuffer()
|
||||||
{
|
{
|
||||||
|
m_FinalPassFrameBufferLowRes.Bind();
|
||||||
|
glViewport(0, 0, m_Renderer->GetViewportSize().Width/m_ShieldPixelRate, m_Renderer->GetViewportSize().Height/m_ShieldPixelRate);
|
||||||
|
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
glDisable(GL_SCISSOR_TEST);
|
||||||
|
m_FinalPassFrameBufferLowRes.Unbind();
|
||||||
|
|
||||||
m_FinalPassFrameBuffer.Bind();
|
m_FinalPassFrameBuffer.Bind();
|
||||||
|
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
m_FinalPassFrameBuffer.Unbind();
|
m_FinalPassFrameBuffer.Unbind();
|
||||||
|
|
||||||
m_FinalPassFrameBufferLowRes.Bind();
|
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
m_FinalPassFrameBufferLowRes.Unbind();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
void DrawFinalPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
||||||
@@ -385,6 +421,39 @@ void DrawFinalPass::DrawShieldedModelRenderQueue(std::list<std::shared_ptr<Rende
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DrawFinalPass::DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
|
||||||
|
{
|
||||||
|
m_FillDepthBufferProgram->Bind();
|
||||||
|
GLuint shaderHandle = m_FillDepthBufferProgram->GetHandle();
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
|
||||||
|
for (auto &job : jobs) {
|
||||||
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
|
|
||||||
|
//bind uniforms
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
|
|
||||||
|
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||||
|
|
||||||
|
if (modelJob->Animation != nullptr) {
|
||||||
|
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones(*modelJob->Animation, modelJob->AnimationTime);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//draw
|
||||||
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int)));
|
||||||
|
if (GLERROR("models end")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene)
|
void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene)
|
||||||
{
|
{
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ void Renderer::Draw(RenderFrame& frame)
|
|||||||
}
|
}
|
||||||
m_DrawBloomPass->Draw(m_DrawFinalPass->BloomTexture());
|
m_DrawBloomPass->Draw(m_DrawFinalPass->BloomTexture());
|
||||||
if (m_DebugTextureToDraw == 0) {
|
if (m_DebugTextureToDraw == 0) {
|
||||||
m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), frame.Gamma, frame.Exposure);
|
m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), m_DrawFinalPass->SceneTextureLowRes(), m_DrawFinalPass->BloomTextureLowRes(), frame.Gamma, frame.Exposure);
|
||||||
}
|
}
|
||||||
if (m_DebugTextureToDraw == 1) {
|
if (m_DebugTextureToDraw == 1) {
|
||||||
m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTexture());
|
m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTexture());
|
||||||
|
|||||||
Reference in New Issue
Block a user