Basic working deferred rendering
This commit is contained in:
+1
-1
@@ -67,7 +67,7 @@ void GameWorld::Initialize()
|
|||||||
model->ModelFile = "Models/Placeholders/PhysicsTest/PointLight.obj";
|
model->ModelFile = "Models/Placeholders/PhysicsTest/PointLight.obj";
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < 500; i++)
|
for(int i = 0; i < 0; i++)
|
||||||
{
|
{
|
||||||
auto ball = CreateEntity();
|
auto ball = CreateEntity();
|
||||||
auto transform = AddComponent<Components::Transform>(ball, "Transform");
|
auto transform = AddComponent<Components::Transform>(ball, "Transform");
|
||||||
|
|||||||
+184
-93
@@ -72,13 +72,11 @@ void Renderer::Initialize()
|
|||||||
glEnable(GL_DEPTH_TEST);
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
|
||||||
LoadContent();
|
LoadContent();
|
||||||
|
|
||||||
FrameBufferTextures();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::LoadContent()
|
void Renderer::LoadContent()
|
||||||
{
|
{
|
||||||
auto standardVS = std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex.glsl"));
|
/*auto standardVS = std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex.glsl"));
|
||||||
auto standardFS = std::shared_ptr<Shader>(new FragmentShader("Shaders/Fragment.glsl"));
|
auto standardFS = std::shared_ptr<Shader>(new FragmentShader("Shaders/Fragment.glsl"));
|
||||||
|
|
||||||
m_ShaderProgram.AddShader(standardVS);
|
m_ShaderProgram.AddShader(standardVS);
|
||||||
@@ -110,52 +108,26 @@ void Renderer::LoadContent()
|
|||||||
m_ShaderProgramSkybox.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Skybox.vert.glsl")));
|
m_ShaderProgramSkybox.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Skybox.vert.glsl")));
|
||||||
m_ShaderProgramSkybox.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Skybox.frag.glsl")));
|
m_ShaderProgramSkybox.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Skybox.frag.glsl")));
|
||||||
m_ShaderProgramSkybox.Compile();
|
m_ShaderProgramSkybox.Compile();
|
||||||
m_ShaderProgramSkybox.Link();
|
m_ShaderProgramSkybox.Link();*/
|
||||||
|
|
||||||
m_FirstPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/First_pass.vert.glsl")));
|
m_FirstPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex.glsl")));
|
||||||
m_FirstPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/First_pass.frag.glsl")));
|
m_FirstPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Fragment.glsl")));
|
||||||
m_FirstPassProgram.Compile();
|
m_FirstPassProgram.Compile();
|
||||||
BindFragDataLocation();
|
glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 0, "frag_Diffuse");
|
||||||
|
glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 1, "frag_Position");
|
||||||
|
glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 2, "frag_Normal");
|
||||||
m_FirstPassProgram.Link();
|
m_FirstPassProgram.Link();
|
||||||
|
|
||||||
m_SecondPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Second_pass.vert.glsl")));
|
m_SecondPassProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Vertex2.glsl")));
|
||||||
m_SecondPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Second_pass.frag.glsl")));
|
m_SecondPassProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Fragment2.glsl")));
|
||||||
m_SecondPassProgram.Compile();
|
m_SecondPassProgram.Compile();
|
||||||
m_SecondPassProgram.Link();
|
m_SecondPassProgram.Link();
|
||||||
|
|
||||||
m_Skybox = std::make_shared<Skybox>("Textures/Skybox/Sunset", "jpg");
|
|
||||||
|
|
||||||
m_DebugAABB = CreateAABB();
|
|
||||||
m_ScreenQuad = CreateQuad();
|
m_ScreenQuad = CreateQuad();
|
||||||
CreateShadowMap(m_ShadowMapRes);
|
|
||||||
|
FrameBufferTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::CreateShadowMap(int resolution)
|
|
||||||
{
|
|
||||||
glGenFramebuffers(1, &m_ShadowFrameBuffer);
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_ShadowFrameBuffer);
|
|
||||||
|
|
||||||
// Depth texture
|
|
||||||
glGenTextures(1, &m_ShadowDepthTexture);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_ShadowDepthTexture);
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT16, resolution, resolution, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
|
||||||
|
|
||||||
//glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_NONE );
|
|
||||||
//glTexParameteri( GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY );
|
|
||||||
|
|
||||||
glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_ShadowDepthTexture, 0);
|
|
||||||
glDrawBuffer(GL_NONE);
|
|
||||||
|
|
||||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
|
||||||
{
|
|
||||||
LOG_ERROR("Framebuffer incomplete!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void Renderer::Draw(double dt)
|
void Renderer::Draw(double dt)
|
||||||
{
|
{
|
||||||
glDisable(GL_BLEND);
|
glDisable(GL_BLEND);
|
||||||
@@ -550,7 +522,7 @@ void Renderer::FrameBufferTextures()
|
|||||||
glGenRenderbuffers(1, &m_fDepthBuffer);
|
glGenRenderbuffers(1, &m_fDepthBuffer);
|
||||||
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, m_fDepthBuffer);
|
glBindRenderbuffer(GL_RENDERBUFFER, m_fDepthBuffer);
|
||||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, WIDTH, HEIGHT);
|
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, WIDTH, HEIGHT);
|
||||||
|
|
||||||
//Generate and bind diffuse texture
|
//Generate and bind diffuse texture
|
||||||
glGenTextures(1, &m_fDiffuseTexture);
|
glGenTextures(1, &m_fDiffuseTexture);
|
||||||
@@ -579,15 +551,6 @@ void Renderer::FrameBufferTextures()
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
|
||||||
//Generate and bind blend texture
|
|
||||||
glGenTextures(1, &m_fBlendTexture);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_fBlendTexture);
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
|
||||||
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_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
||||||
|
|
||||||
//Bind fb
|
//Bind fb
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_fb);
|
glBindFramebuffer(GL_FRAMEBUFFER, m_fb);
|
||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_fDepthBuffer);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_fDepthBuffer);
|
||||||
@@ -596,73 +559,201 @@ void Renderer::FrameBufferTextures()
|
|||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_fDiffuseTexture, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_fDiffuseTexture, 0);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, m_fPositionTexture, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, m_fPositionTexture, 0);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, m_fNormalsTexture, 0);
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, m_fNormalsTexture, 0);
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, m_fBlendTexture, 0);
|
|
||||||
|
|
||||||
GLenum fbStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
GLenum fbStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
if(fbStatus != GL_FRAMEBUFFER_COMPLETE)
|
if(fbStatus != GL_FRAMEBUFFER_COMPLETE)
|
||||||
{
|
{
|
||||||
printf("DeferredLighting:Init: FrameBuffer incomplete: 0x%x\n", fbStatus);
|
LOG_ERROR("DeferredLighting:Init: FrameBuffer incomplete: 0x%x\n", fbStatus);
|
||||||
exit(1);
|
//exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//void Renderer::FrameBufferTextures()
|
||||||
|
//{
|
||||||
|
// m_fb = 0;
|
||||||
|
// m_fDepthBuffer = 0;
|
||||||
|
//
|
||||||
|
// glGenFramebuffers(1, &m_fb);
|
||||||
|
// glGenRenderbuffers(1, &m_fDepthBuffer);
|
||||||
|
//
|
||||||
|
// glBindRenderbuffer(GL_RENDERBUFFER, m_fDepthBuffer);
|
||||||
|
// glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, WIDTH, HEIGHT);
|
||||||
|
//
|
||||||
|
// //Generate and bind diffuse texture
|
||||||
|
// glGenTextures(1, &m_fDiffuseTexture);
|
||||||
|
// glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture);
|
||||||
|
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
// 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_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
//
|
||||||
|
// //Generate and bind position texture
|
||||||
|
// glGenTextures(1, &m_fPositionTexture);
|
||||||
|
// glBindTexture(GL_TEXTURE_2D, m_fPositionTexture);
|
||||||
|
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
// 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_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
//
|
||||||
|
// //Generate and bind normal texture
|
||||||
|
// glGenTextures(1, &m_fNormalsTexture);
|
||||||
|
// glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture);
|
||||||
|
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
// 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_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
//
|
||||||
|
// //Generate and bind blend texture
|
||||||
|
// glGenTextures(1, &m_fBlendTexture);
|
||||||
|
// glBindTexture(GL_TEXTURE_2D, m_fBlendTexture);
|
||||||
|
// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
// 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_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
// glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
//
|
||||||
|
// //Bind fb
|
||||||
|
// glBindFramebuffer(GL_FRAMEBUFFER, m_fb);
|
||||||
|
// glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_fDepthBuffer);
|
||||||
|
//
|
||||||
|
// //Attach textures to the FB
|
||||||
|
// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_fDiffuseTexture, 0);
|
||||||
|
// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, m_fPositionTexture, 0);
|
||||||
|
// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, m_fNormalsTexture, 0);
|
||||||
|
// glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT3, GL_TEXTURE_2D, m_fBlendTexture, 0);
|
||||||
|
//
|
||||||
|
// GLenum fbStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
|
// if(fbStatus != GL_FRAMEBUFFER_COMPLETE)
|
||||||
|
// {
|
||||||
|
// printf("DeferredLighting:Init: FrameBuffer incomplete: 0x%x\n", fbStatus);
|
||||||
|
// exit(1);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
//}
|
||||||
|
|
||||||
void Renderer::DrawFBO()
|
void Renderer::DrawFBO()
|
||||||
{
|
{
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fb);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fb);
|
||||||
|
|
||||||
GLenum windowBuffClear[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
|
// Clear G-buffer
|
||||||
glDrawBuffers(4, windowBuffClear);
|
GLenum windowBuffClear[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
|
||||||
|
glDrawBuffers(3, windowBuffClear);
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
// Execute the first render stage which will fill out the internal buffers with data(??)
|
// Execute the first render stage which will fill out the internal buffers with data(??)
|
||||||
//EnableRenderProgramStage1;
|
m_FirstPassProgram.Bind();
|
||||||
GLenum windowBuffOpaque[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_NONE };
|
GLenum windowBuffOpaque[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
|
||||||
glDrawBuffers(4, windowBuffOpaque);
|
glDrawBuffers(3, windowBuffOpaque);
|
||||||
//DrawTheWorld();
|
DrawFBOScene();
|
||||||
|
|
||||||
GLenum windowBuffTransp[] = { GL_NONE, GL_NONE, GL_NONE, GL_COLOR_ATTACHMENT3 };
|
// Draw to screen
|
||||||
glDrawBuffers(4, windowBuffTransp);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
//Depth buffer shall not be updated
|
|
||||||
glDepthMask(GL_FALSE);
|
|
||||||
//DrawTransparent items
|
|
||||||
glDepthMask(GL_TRUE);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||||
|
m_SecondPassProgram.Bind();
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
//Probably means to use the second_pass shader
|
////SetupDefferedStageUniforms(); // Probably what we do in FrameBufferTextures();
|
||||||
//EnableRenderProgramDeferredStage();
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
|
||||||
//SetupDefferedStageUniforms(); // Probably what we do in FrameBufferTextures();
|
|
||||||
//glEnableVertexAttribArray(fVertexIndex); // VertexIndex?
|
|
||||||
glActiveTexture(GL_TEXTURE3);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_fBlendTexture);
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE2);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture);
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_fPositionTexture);
|
glBindTexture(GL_TEXTURE_2D, m_fPositionTexture);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE2);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture);
|
glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture);
|
||||||
|
|
||||||
//DrawSimpleSquare(); //I guess this draw a square and put the textures on it
|
|
||||||
|
|
||||||
//glDisableVertexAttribArray(fVertexIndex); //VertexIndex?
|
|
||||||
|
|
||||||
|
glBindVertexArray(m_ScreenQuad);
|
||||||
|
glEnableVertexAttribArray(0);
|
||||||
|
glEnableVertexAttribArray(2);
|
||||||
|
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::BindFragDataLocation()
|
//void Renderer::DrawFBO()
|
||||||
{
|
//{
|
||||||
glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 0, "diffuseOutput");
|
// glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fb);
|
||||||
glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 1, "posOutput");
|
//
|
||||||
glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 2, "normOutput");
|
// GLenum windowBuffClear[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_COLOR_ATTACHMENT3 };
|
||||||
glBindFragDataLocation(m_FirstPassProgram.GetHandle(), 3, "blendOutput");
|
// glDrawBuffers(4, windowBuffClear);
|
||||||
|
// glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
|
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
//
|
||||||
|
// // Execute the first render stage which will fill out the internal buffers with data(??)
|
||||||
|
// //EnableRenderProgramStage1;
|
||||||
|
// m_FirstPassProgram.Bind();
|
||||||
|
// GLenum windowBuffOpaque[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2, GL_NONE };
|
||||||
|
// glDrawBuffers(4, windowBuffOpaque);
|
||||||
|
// DrawFBOScene();
|
||||||
|
//
|
||||||
|
// GLenum windowBuffTransp[] = { GL_NONE, GL_NONE, GL_NONE, GL_COLOR_ATTACHMENT3 };
|
||||||
|
// glDrawBuffers(4, windowBuffTransp);
|
||||||
|
// glEnable(GL_BLEND);
|
||||||
|
// glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
// //Depth buffer shall not be updated
|
||||||
|
// glDepthMask(GL_FALSE);
|
||||||
|
// //DrawTransparent items
|
||||||
|
// glDepthMask(GL_TRUE);
|
||||||
|
// glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
// glDisable(GL_BLEND);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||||
|
// //Probably means to use the second_pass shader
|
||||||
|
// //EnableRenderProgramDeferredStage();
|
||||||
|
// m_SecondPassProgram.Bind();
|
||||||
|
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||||
|
// //SetupDefferedStageUniforms(); // Probably what we do in FrameBufferTextures();
|
||||||
|
// glEnableVertexAttribArray(0);
|
||||||
|
// glActiveTexture(GL_TEXTURE0);
|
||||||
|
// glBindTexture(GL_TEXTURE_2D, m_fDiffuseTexture);
|
||||||
|
//
|
||||||
|
// glActiveTexture(GL_TEXTURE1);
|
||||||
|
// glBindTexture(GL_TEXTURE_2D, m_fPositionTexture);
|
||||||
|
//
|
||||||
|
// glActiveTexture(GL_TEXTURE2);
|
||||||
|
// glBindTexture(GL_TEXTURE_2D, m_fNormalsTexture);
|
||||||
|
//
|
||||||
|
// glActiveTexture(GL_TEXTURE3);
|
||||||
|
// glBindTexture(GL_TEXTURE_2D, m_fBlendTexture);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// //DrawSimpleSquare(); //I guess this draw a square and put the textures on it
|
||||||
|
// glBindVertexArray(m_ScreenQuad);
|
||||||
|
// glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||||
|
// glDisableVertexAttribArray(0);
|
||||||
|
//
|
||||||
|
//}
|
||||||
|
|
||||||
|
void Renderer::DrawFBOScene()
|
||||||
|
{
|
||||||
|
glm::mat4 cameraMatrix = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix();
|
||||||
|
glm::mat4 MVP;
|
||||||
|
for (auto tuple : ModelsToRender)
|
||||||
|
{
|
||||||
|
Model* model;
|
||||||
|
glm::mat4 modelMatrix;
|
||||||
|
bool visible;
|
||||||
|
std::tie(model, modelMatrix, visible, std::ignore) = tuple;
|
||||||
|
if (!visible)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
MVP = cameraMatrix * modelMatrix;
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(m_FirstPassProgram.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
||||||
|
glBindVertexArray(model->VAO);
|
||||||
|
for (auto texGroup : model->TextureGroups)
|
||||||
|
{
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, *texGroup.Texture);
|
||||||
|
glDrawArrays(GL_TRIANGLES, texGroup.StartIndex, texGroup.EndIndex - texGroup.StartIndex + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -84,7 +84,6 @@ private:
|
|||||||
glm::mat4 m_SunProjection;
|
glm::mat4 m_SunProjection;
|
||||||
|
|
||||||
GLuint m_DebugAABB;
|
GLuint m_DebugAABB;
|
||||||
GLuint m_ScreenQuad;
|
|
||||||
GLuint m_ShadowFrameBuffer;
|
GLuint m_ShadowFrameBuffer;
|
||||||
GLuint m_ShadowDepthTexture;
|
GLuint m_ShadowDepthTexture;
|
||||||
|
|
||||||
@@ -95,6 +94,7 @@ private:
|
|||||||
GLuint m_fb;
|
GLuint m_fb;
|
||||||
GLuint m_fDepthBuffer;
|
GLuint m_fDepthBuffer;
|
||||||
GLenum draw_bufs[2];
|
GLenum draw_bufs[2];
|
||||||
|
GLuint m_ScreenQuad;
|
||||||
|
|
||||||
std::shared_ptr<Camera> m_Camera;
|
std::shared_ptr<Camera> m_Camera;
|
||||||
|
|
||||||
@@ -114,6 +114,7 @@ private:
|
|||||||
void CreateShadowMap(int resolution);
|
void CreateShadowMap(int resolution);
|
||||||
void FrameBufferTextures();
|
void FrameBufferTextures();
|
||||||
void DrawFBO();
|
void DrawFBO();
|
||||||
|
void DrawFBOScene();
|
||||||
void BindFragDataLocation();
|
void BindFragDataLocation();
|
||||||
|
|
||||||
GLuint CreateQuad();
|
GLuint CreateQuad();
|
||||||
|
|||||||
@@ -103,6 +103,11 @@ void ShaderProgram::AddShader(std::shared_ptr<Shader> shader)
|
|||||||
|
|
||||||
void ShaderProgram::Compile()
|
void ShaderProgram::Compile()
|
||||||
{
|
{
|
||||||
|
if (m_ShaderProgramHandle == 0)
|
||||||
|
{
|
||||||
|
m_ShaderProgramHandle = glCreateProgram();
|
||||||
|
}
|
||||||
|
|
||||||
for (auto &shader : m_Shaders)
|
for (auto &shader : m_Shaders)
|
||||||
{
|
{
|
||||||
if (!shader->IsCompiled())
|
if (!shader->IsCompiled())
|
||||||
@@ -121,7 +126,7 @@ GLuint ShaderProgram::Link()
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOG_INFO("Linking shader program");
|
LOG_INFO("Linking shader program");
|
||||||
m_ShaderProgramHandle = glCreateProgram();
|
|
||||||
for (auto &shader : m_Shaders)
|
for (auto &shader : m_Shaders)
|
||||||
{
|
{
|
||||||
glAttachShader(m_ShaderProgramHandle, shader->GetHandle());
|
glAttachShader(m_ShaderProgramHandle, shader->GetHandle());
|
||||||
|
|||||||
+1
-1
@@ -61,7 +61,7 @@ class ShaderProgram
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ShaderProgram()
|
ShaderProgram()
|
||||||
: m_ShaderProgramHandle(0) { }
|
: m_ShaderProgramHandle(0) { }
|
||||||
~ShaderProgram();
|
~ShaderProgram();
|
||||||
|
|
||||||
void AddShader(std::shared_ptr<Shader> shader);
|
void AddShader(std::shared_ptr<Shader> shader);
|
||||||
|
|||||||
@@ -1,35 +0,0 @@
|
|||||||
#version 130
|
|
||||||
uniform sampler2D firstTexture;
|
|
||||||
in vec3 fragmentNormal;
|
|
||||||
in vec2 fragmentTexCoord;
|
|
||||||
in vec3 position;
|
|
||||||
layout (location = 0) out vec4 diffuseOutput;
|
|
||||||
layout (location = 1) out vec4 posOutput;
|
|
||||||
layout (location = 2) out vec4 normOutput;
|
|
||||||
layout (location = 3) out vec4 blendOutput;
|
|
||||||
|
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
posOutput.xyz = position;
|
|
||||||
normOutPut = vec4(fragmentNormal, 0);
|
|
||||||
vec4 clr = texture(firstTexture, fragmentTexCoord);
|
|
||||||
float alpha = clr.a;
|
|
||||||
if(alpha < 0.1)
|
|
||||||
discard; //Some optimizing
|
|
||||||
blendOutput.rgb = clr.rgb * clr.a; //Pre multiplied alpha
|
|
||||||
blendOutput.a = clr.a;
|
|
||||||
diffuseOutput = clr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*#version 400
|
|
||||||
|
|
||||||
in vec3 p_eye;
|
|
||||||
in vec3 n_eye;
|
|
||||||
|
|
||||||
layout (location = 0) out vec4 def_p; // "go to GL_COLOR_ATTACHMENT0"
|
|
||||||
layout (location = 1) out vec4 def_n; // "go to GL_COLOR_ATTACHMENT1"
|
|
||||||
|
|
||||||
void main () {
|
|
||||||
def_p = vec4(p_eye, 1.0);
|
|
||||||
def_n = vec4(n_eye, 1.0);
|
|
||||||
}*/
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
#version 130
|
|
||||||
|
|
||||||
precision mediump float;
|
|
||||||
uniform mat4 projectionMatrix;
|
|
||||||
uniform mat4 modelMatrix;
|
|
||||||
uniform mat4 viewMatrix;
|
|
||||||
|
|
||||||
in vec3 normal;
|
|
||||||
in vec2 texCoord;
|
|
||||||
in vec3 vertex;
|
|
||||||
|
|
||||||
in float intensity;
|
|
||||||
in float ambientLight;
|
|
||||||
|
|
||||||
out vec3 fragmentNormal;
|
|
||||||
out vec2 fragmentTexCoord;
|
|
||||||
out float extIntensity;
|
|
||||||
out float extAmbientLight;
|
|
||||||
|
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
fragmentTexCoord = texCoord;
|
|
||||||
fragmentNormal = normalize((modelMatrix*vec4(normal, 0.0).xyz);
|
|
||||||
gl_Position = vec3(modelMatrix * vertex); //Copy position to the fragment shader
|
|
||||||
extIntensity = intensity/255.0;
|
|
||||||
extAmbientLight = ambientLight/255.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*#version 400
|
|
||||||
|
|
||||||
layout(location = 0) in vec3 vp;
|
|
||||||
layout(location = 1) in vec3 vn;
|
|
||||||
layout(location = 2) in vec2 TextureCoord;
|
|
||||||
|
|
||||||
uniform mat4 P, V, M;
|
|
||||||
|
|
||||||
out vec3 p_eye;
|
|
||||||
out vec3 n_eye;
|
|
||||||
|
|
||||||
void main () {
|
|
||||||
p_eye = (V * M * vec4 (vp, 1.0)).xyz;
|
|
||||||
n_eye = (V * M * vec4 (vn, 0.0)).xyz;
|
|
||||||
gl_Position = P * vec4 (p_eye, 1.0);
|
|
||||||
}*/
|
|
||||||
+10
-97
@@ -1,113 +1,26 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
uniform mat4 model;
|
layout (binding=0) uniform sampler2D DiffuseTexture;
|
||||||
uniform mat4 view;
|
|
||||||
|
|
||||||
layout(binding=0) uniform sampler2D texture0;
|
|
||||||
layout(binding=1) uniform sampler2D shadowMap;
|
|
||||||
|
|
||||||
const int maxNumberOfLights = 82;
|
|
||||||
uniform int numberOfLights;
|
|
||||||
uniform vec3 position[maxNumberOfLights];
|
|
||||||
uniform vec3 specular[maxNumberOfLights];
|
|
||||||
uniform vec3 diffuse[maxNumberOfLights];
|
|
||||||
uniform float constantAttenuation[maxNumberOfLights];
|
|
||||||
uniform float linearAttenuation[maxNumberOfLights];
|
|
||||||
uniform float quadraticAttenuation[maxNumberOfLights];
|
|
||||||
uniform float spotExponent[maxNumberOfLights];
|
|
||||||
|
|
||||||
in VertexData
|
in VertexData
|
||||||
{
|
{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
vec2 TextureCoord;
|
vec2 TextureCoord;
|
||||||
vec3 ShadowCoord;
|
|
||||||
} Input;
|
} Input;
|
||||||
|
|
||||||
vec3 scene_ambient = vec3(0.5, 0.5, 0.5);
|
out vec4 frag_Diffuse;
|
||||||
|
out vec4 frag_Position;
|
||||||
out vec4 fragmentColor;
|
out vec4 frag_Normal;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
// Diffuse Texture
|
||||||
|
frag_Diffuse = texture2D(DiffuseTexture, Input.TextureCoord);
|
||||||
|
|
||||||
// Texture
|
// G-buffer Position
|
||||||
vec4 texel = texture2D(texture0, Input.TextureCoord);
|
frag_Position = vec4(Input.Position.xy, 0.0, 0.0);
|
||||||
//vec4 texel = (blend.x * texel0) + (blend.y * texel1) + (blend.z * texel2);
|
|
||||||
|
|
||||||
//
|
// G-buffer Normal
|
||||||
// Phong shading
|
frag_Normal = vec4(Input.Normal, 0.0);
|
||||||
//
|
|
||||||
|
|
||||||
// Ambient light
|
|
||||||
vec3 La = scene_ambient; // Ambient light
|
|
||||||
vec3 Ks = vec3(0.3, 0.3, 0.3); // Specular reflectance
|
|
||||||
vec3 Kd = vec3(1.0, 1.0, 1.0); // Diffuse reflectance
|
|
||||||
vec3 Ka = vec3(1.0, 1.0, 1.0); // Ambient reflectance
|
|
||||||
vec3 Is;
|
|
||||||
vec3 Id;
|
|
||||||
|
|
||||||
// Shadows
|
|
||||||
//float cosTheta = clamp(dot(Input.Normal, vec3(0, 1, 0)), 0.0, 1.0);
|
|
||||||
//float bias = 0.001 * tan(acos(cosTheta)); // cosTheta is dot( n,l ), clamped between 0 and 1
|
|
||||||
//bias = clamp(bias, 0.0, 0.01);
|
|
||||||
float visibility = 1.0;
|
|
||||||
if (Input.ShadowCoord.x >= 0.0 && Input.ShadowCoord.x <= 1.0 && Input.ShadowCoord.y >= 0.0 && Input.ShadowCoord.y <= 1.0)
|
|
||||||
{
|
|
||||||
float bias = 0.00005;
|
|
||||||
vec4 shadowMapValue = texture(shadowMap, Input.ShadowCoord.xy);
|
|
||||||
if (shadowMapValue.z < clamp(Input.ShadowCoord.z - bias, 0, 1))
|
|
||||||
{
|
|
||||||
visibility = 0.3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vec3 totalLighting = La * Ka * visibility;
|
|
||||||
|
|
||||||
float attenuation;
|
|
||||||
|
|
||||||
for(int i = 0; i < numberOfLights && i < maxNumberOfLights; i++)
|
|
||||||
{
|
|
||||||
// Light
|
|
||||||
//vec3 lightPosition = vec3(0, 0, 2);
|
|
||||||
vec3 Ls = specular[i]; // Specular light
|
|
||||||
vec3 Ld = diffuse[i]; // Diffuse light
|
|
||||||
|
|
||||||
vec3 lightPosView = vec3(view * vec4(position[i], 1.0));
|
|
||||||
vec3 surfacePosition = vec3(model * vec4(Input.Position, 1.0));
|
|
||||||
vec3 surfacePosView = vec3(view * vec4(surfacePosition, 1.0));
|
|
||||||
vec3 surfaceToLight = normalize(lightPosView - surfacePosView);
|
|
||||||
mat3 normalMatrix = transpose(inverse(mat3(view * model)));
|
|
||||||
vec3 surfaceNormal = normalize(normalMatrix * Input.Normal);
|
|
||||||
|
|
||||||
float dist = length(position[i] - surfacePosition);
|
|
||||||
|
|
||||||
attenuation = 1.0 / (constantAttenuation[i]
|
|
||||||
+ linearAttenuation[i] * dist
|
|
||||||
+ quadraticAttenuation[i] * pow(dist, 2.0));
|
|
||||||
//attenuation = attenuation * pow(clampedCosine, spotExponent[i]);
|
|
||||||
|
|
||||||
// Diffuse light
|
|
||||||
float dotProd = dot(surfaceToLight, surfaceNormal);
|
|
||||||
dotProd = max(dotProd, 0.0);
|
|
||||||
|
|
||||||
Id = Ld * Kd * abs(dotProd) * attenuation;
|
|
||||||
|
|
||||||
// Specular light
|
|
||||||
vec3 reflection = reflect(-surfaceToLight, surfaceNormal);
|
|
||||||
float dotSpecular = dot(reflection, normalize(-surfacePosView));
|
|
||||||
dotSpecular = max(dotSpecular, 0.0);
|
|
||||||
float specularFactor = pow(dotSpecular, 30.0); // Specular factor
|
|
||||||
|
|
||||||
Is = attenuation * Ls * Ks * specularFactor;
|
|
||||||
|
|
||||||
totalLighting = totalLighting + Id + Is;
|
|
||||||
}
|
|
||||||
|
|
||||||
fragmentColor = vec4(totalLighting, 1.0) * texel;
|
|
||||||
|
|
||||||
|
|
||||||
//fragmentColor = vec4(Id, 1.0) * texel;
|
|
||||||
|
|
||||||
//fragmentColor = texel;
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
layout (binding=0) uniform sampler2D DiffuseTexture;
|
||||||
|
layout (binding=1) uniform sampler2D PositionTexture;
|
||||||
|
layout (binding=2) uniform sampler2D NormalTexture;
|
||||||
|
|
||||||
|
in VertexData
|
||||||
|
{
|
||||||
|
vec3 Position;
|
||||||
|
vec3 Normal;
|
||||||
|
vec2 TextureCoord;
|
||||||
|
} Input;
|
||||||
|
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
FragColor = texture2D(DiffuseTexture, Input.TextureCoord);
|
||||||
|
}
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#version 130
|
|
||||||
|
|
||||||
uniform sampler2D diffuseTex; // The color information
|
|
||||||
uniform sampler2D posTex; // World position
|
|
||||||
uniform sampler2D normalTex; // Normals
|
|
||||||
uniform sampler2D blendTex; // A bitmap with colors to blend with.
|
|
||||||
uniform vec3 camera; // The coordinate of the camera
|
|
||||||
in vec2 position; // The world position
|
|
||||||
layout (location = 0) out vec4 fragColor;
|
|
||||||
|
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
// Load data, stored in textures, from the first stage rendering.
|
|
||||||
vec4 diffuse = texture2D(diffuseTex, position.xy);
|
|
||||||
vec4 blend = texture2D(blendTex, position.xy);
|
|
||||||
vec4 worldPos = texture2D(posTex, position.xy);
|
|
||||||
vec4 normal = texture2D(normalTex, position.xy);
|
|
||||||
// Use information about lamp coordinate (not shown here), the pixel
|
|
||||||
// coordinate (worldpos.xyz), the normal of this pixel (normal.xyz)
|
|
||||||
// to compute a lighting effect.
|
|
||||||
// Use this lighting effect to update 'diffuse'
|
|
||||||
vec4 preBlend = diffuse * lamp + specularGlare;
|
|
||||||
// manual blending, using premultiplied alpha.
|
|
||||||
fragColor = blend + preBlend*(1-blend.a);
|
|
||||||
// Some debug features. Enable any of them to get a visual representation
|
|
||||||
// of an internal buffer.
|
|
||||||
// fragColor = (normal+1)/2;
|
|
||||||
// fragColor = diffuse;
|
|
||||||
// fragColor = blend;
|
|
||||||
// fragColor = worldPos; // Scaling may be needed to range [0,1]
|
|
||||||
// fragColor = lamp*vec4(1,1,1,1);
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
#version 130
|
|
||||||
in vec4 vertex; out vec2 position;
|
|
||||||
|
|
||||||
void main(void)
|
|
||||||
{
|
|
||||||
gl_Position = vertex*2-1;
|
|
||||||
gl_Position.z = 0.0;
|
|
||||||
position = vertex.xy;
|
|
||||||
}
|
|
||||||
@@ -1,26 +1,23 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
uniform mat4 MVP;
|
uniform mat4 MVP;
|
||||||
uniform mat4 DepthMVP;
|
|
||||||
|
|
||||||
layout(location = 0) in vec3 Position;
|
layout (location = 0) in vec3 Position;
|
||||||
layout(location = 1) in vec3 Normal;
|
layout (location = 1) in vec3 Normal;
|
||||||
layout(location = 2) in vec2 TextureCoord;
|
layout (location = 2) in vec2 TextureCoord;
|
||||||
|
|
||||||
out VertexData
|
out VertexData
|
||||||
{
|
{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
vec2 TextureCoord;
|
vec2 TextureCoord;
|
||||||
vec3 ShadowCoord;
|
|
||||||
} Output;
|
} Output;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = MVP * vec4(Position, 1.0);
|
gl_Position = MVP * vec4(Position, 1.0);
|
||||||
|
|
||||||
Output.Position = Position;
|
Output.Position = gl_Position.xyz;
|
||||||
Output.Normal = Normal;
|
Output.Normal = Normal;
|
||||||
Output.TextureCoord = TextureCoord;
|
Output.TextureCoord = TextureCoord;
|
||||||
Output.ShadowCoord = vec3(DepthMVP * vec4(Position, 1.0));
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
layout (location = 0) in vec3 Position;
|
||||||
|
layout (location = 2) in vec2 TextureCoord;
|
||||||
|
|
||||||
|
out VertexData
|
||||||
|
{
|
||||||
|
vec3 Position;
|
||||||
|
vec2 TextureCoord;
|
||||||
|
} Output;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = vec4(Position, 1.0);
|
||||||
|
Output.Position = Position;
|
||||||
|
Output.TextureCoord = TextureCoord;
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<VSPerformanceSession Version="1.00">
|
||||||
|
<Options>
|
||||||
|
<Solution>Returngeance.sln</Solution>
|
||||||
|
<CollectionMethod>Sampling</CollectionMethod>
|
||||||
|
<AllocationMethod>None</AllocationMethod>
|
||||||
|
<AddReport>true</AddReport>
|
||||||
|
<ResourceBasedAnalysisSelected>true</ResourceBasedAnalysisSelected>
|
||||||
|
<UniqueReport>Timestamp</UniqueReport>
|
||||||
|
<SamplingMethod>Cycles</SamplingMethod>
|
||||||
|
<CycleCount>10000000</CycleCount>
|
||||||
|
<PageFaultCount>10</PageFaultCount>
|
||||||
|
<SysCallCount>10</SysCallCount>
|
||||||
|
<SamplingCounter Name="" ReloadValue="00000000000f4240" DisplayName="" />
|
||||||
|
<RelocateBinaries>false</RelocateBinaries>
|
||||||
|
<HardwareCounters EnableHWCounters="false" />
|
||||||
|
<EtwSettings />
|
||||||
|
<PdhSettings>
|
||||||
|
<PdhCountersEnabled>false</PdhCountersEnabled>
|
||||||
|
<PdhCountersRate>500</PdhCountersRate>
|
||||||
|
<PdhCounters>
|
||||||
|
<PdhCounter>\Memory\Pages/sec</PdhCounter>
|
||||||
|
<PdhCounter>\PhysicalDisk(_Total)\Avg. Disk Queue Length</PdhCounter>
|
||||||
|
<PdhCounter>\Processor(_Total)\% Processor Time</PdhCounter>
|
||||||
|
</PdhCounters>
|
||||||
|
</PdhSettings>
|
||||||
|
</Options>
|
||||||
|
<ExcludeSmallFuncs>true</ExcludeSmallFuncs>
|
||||||
|
<InteractionProfilingEnabled>false</InteractionProfilingEnabled>
|
||||||
|
<JScriptProfilingEnabled>false</JScriptProfilingEnabled>
|
||||||
|
<PreinstrumentEvent>
|
||||||
|
<InstrEventExclude>false</InstrEventExclude>
|
||||||
|
</PreinstrumentEvent>
|
||||||
|
<PostinstrumentEvent>
|
||||||
|
<InstrEventExclude>false</InstrEventExclude>
|
||||||
|
</PostinstrumentEvent>
|
||||||
|
<Binaries>
|
||||||
|
<ProjBinary>
|
||||||
|
<Path>bin\Debug\Returngeance.exe</Path>
|
||||||
|
<ArgumentTimestamp>01/01/0001 00:00:00</ArgumentTimestamp>
|
||||||
|
<Instrument>true</Instrument>
|
||||||
|
<Sample>true</Sample>
|
||||||
|
<ExternalWebsite>false</ExternalWebsite>
|
||||||
|
<InteractionProfilingEnabled>false</InteractionProfilingEnabled>
|
||||||
|
<IsLocalJavascript>false</IsLocalJavascript>
|
||||||
|
<IsWindowsStoreApp>false</IsWindowsStoreApp>
|
||||||
|
<IsWWA>false</IsWWA>
|
||||||
|
<LaunchProject>true</LaunchProject>
|
||||||
|
<OverrideProjectSettings>false</OverrideProjectSettings>
|
||||||
|
<LaunchMethod>Executable</LaunchMethod>
|
||||||
|
<ExecutablePath>bin\Debug\Returngeance.exe</ExecutablePath>
|
||||||
|
<StartupDirectory>..\bin\Debug</StartupDirectory>
|
||||||
|
<Arguments>
|
||||||
|
</Arguments>
|
||||||
|
<NetAppHost>IIS</NetAppHost>
|
||||||
|
<NetBrowser>InternetExplorer</NetBrowser>
|
||||||
|
<ExcludeSmallFuncs>true</ExcludeSmallFuncs>
|
||||||
|
<JScriptProfilingEnabled>false</JScriptProfilingEnabled>
|
||||||
|
<PreinstrumentEvent>
|
||||||
|
<InstrEventExclude>false</InstrEventExclude>
|
||||||
|
</PreinstrumentEvent>
|
||||||
|
<PostinstrumentEvent>
|
||||||
|
<InstrEventExclude>false</InstrEventExclude>
|
||||||
|
</PostinstrumentEvent>
|
||||||
|
<ProjRef>{E8B4A2A2-882B-402A-98A7-8B4F7233C8B3}|Returngeance\Returngeance.vcxproj</ProjRef>
|
||||||
|
<ProjPath>Returngeance\Returngeance.vcxproj</ProjPath>
|
||||||
|
<ProjName>Returngeance</ProjName>
|
||||||
|
</ProjBinary>
|
||||||
|
</Binaries>
|
||||||
|
<Reports>
|
||||||
|
<Report>
|
||||||
|
<Path>Returngeance140427.vsp</Path>
|
||||||
|
</Report>
|
||||||
|
<Report>
|
||||||
|
<Path>Returngeance140427(1).vsp</Path>
|
||||||
|
</Report>
|
||||||
|
</Reports>
|
||||||
|
<Launches>
|
||||||
|
<ProjBinary>
|
||||||
|
<Path>:PB:{E8B4A2A2-882B-402A-98A7-8B4F7233C8B3}|Returngeance\Returngeance.vcxproj</Path>
|
||||||
|
</ProjBinary>
|
||||||
|
</Launches>
|
||||||
|
</VSPerformanceSession>
|
||||||
@@ -39,4 +39,7 @@ Global
|
|||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
|
GlobalSection(Performance) = preSolution
|
||||||
|
HasPerformanceSessions = true
|
||||||
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -175,6 +175,7 @@
|
|||||||
</ExcludedFromBuild>
|
</ExcludedFromBuild>
|
||||||
</None>
|
</None>
|
||||||
<None Include="..\..\src\Shaders\Fragment.glsl" />
|
<None Include="..\..\src\Shaders\Fragment.glsl" />
|
||||||
|
<None Include="..\..\src\Shaders\Fragment2.glsl" />
|
||||||
<None Include="..\..\src\Shaders\Normals.frag.glsl" />
|
<None Include="..\..\src\Shaders\Normals.frag.glsl" />
|
||||||
<None Include="..\..\src\Shaders\Normals.geo.glsl" />
|
<None Include="..\..\src\Shaders\Normals.geo.glsl" />
|
||||||
<None Include="..\..\src\Shaders\Second_pass.frag.glsl">
|
<None Include="..\..\src\Shaders\Second_pass.frag.glsl">
|
||||||
@@ -188,6 +189,7 @@
|
|||||||
<None Include="..\..\src\Shaders\Skybox.frag.glsl" />
|
<None Include="..\..\src\Shaders\Skybox.frag.glsl" />
|
||||||
<None Include="..\..\src\Shaders\Skybox.vert.glsl" />
|
<None Include="..\..\src\Shaders\Skybox.vert.glsl" />
|
||||||
<None Include="..\..\src\Shaders\Vertex.glsl" />
|
<None Include="..\..\src\Shaders\Vertex.glsl" />
|
||||||
|
<None Include="..\..\src\Shaders\Vertex2.glsl" />
|
||||||
<None Include="..\..\src\Shaders\VisualizeDepth.frag.glsl" />
|
<None Include="..\..\src\Shaders\VisualizeDepth.frag.glsl" />
|
||||||
<None Include="..\..\src\Shaders\VisualizeDepth.vert.glsl" />
|
<None Include="..\..\src\Shaders\VisualizeDepth.vert.glsl" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
<ClCompile Include="..\..\src\main.cpp" />
|
<ClCompile Include="..\..\src\main.cpp" />
|
||||||
<ClCompile Include="..\..\src\GameWorld.cpp" />
|
<ClCompile Include="..\..\src\GameWorld.cpp" />
|
||||||
<ClCompile Include="..\..\src\World.cpp" />
|
<ClCompile Include="..\..\src\World.cpp" />
|
||||||
<ClCompile Include="..\..\src\ShaderProgram.cpp" />
|
|
||||||
<ClCompile Include="..\..\src\PrecompiledHeader.cpp" />
|
<ClCompile Include="..\..\src\PrecompiledHeader.cpp" />
|
||||||
<ClCompile Include="..\..\src\Systems\RenderSystem.cpp">
|
<ClCompile Include="..\..\src\Systems\RenderSystem.cpp">
|
||||||
<Filter>Rendering\Systems</Filter>
|
<Filter>Rendering\Systems</Filter>
|
||||||
@@ -50,6 +49,9 @@
|
|||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\src\ResourceManager.cpp" />
|
<ClCompile Include="..\..\src\ResourceManager.cpp" />
|
||||||
<ClCompile Include="..\..\src\Sound.cpp" />
|
<ClCompile Include="..\..\src\Sound.cpp" />
|
||||||
|
<ClCompile Include="..\..\src\ShaderProgram.cpp">
|
||||||
|
<Filter>Rendering</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Filter Include="Util">
|
<Filter Include="Util">
|
||||||
@@ -129,7 +131,6 @@
|
|||||||
<ClInclude Include="..\..\src\Color.h" />
|
<ClInclude Include="..\..\src\Color.h" />
|
||||||
<ClInclude Include="..\..\src\Engine.h" />
|
<ClInclude Include="..\..\src\Engine.h" />
|
||||||
<ClInclude Include="..\..\src\PrecompiledHeader.h" />
|
<ClInclude Include="..\..\src\PrecompiledHeader.h" />
|
||||||
<ClInclude Include="..\..\src\ShaderProgram.h" />
|
|
||||||
<ClInclude Include="..\..\src\Components\Model.h">
|
<ClInclude Include="..\..\src\Components\Model.h">
|
||||||
<Filter>Rendering\Components</Filter>
|
<Filter>Rendering\Components</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -217,6 +218,9 @@
|
|||||||
<ClInclude Include="..\..\src\Util\defferedUtil.h">
|
<ClInclude Include="..\..\src\Util\defferedUtil.h">
|
||||||
<Filter>Util</Filter>
|
<Filter>Util</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\ShaderProgram.h">
|
||||||
|
<Filter>Rendering</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\..\src\Shaders\AABB.frag.glsl">
|
<None Include="..\..\src\Shaders\AABB.frag.glsl">
|
||||||
@@ -264,5 +268,11 @@
|
|||||||
<None Include="..\..\src\Shaders\Second_pass.vert.glsl">
|
<None Include="..\..\src\Shaders\Second_pass.vert.glsl">
|
||||||
<Filter>Shaders</Filter>
|
<Filter>Shaders</Filter>
|
||||||
</None>
|
</None>
|
||||||
|
<None Include="..\..\src\Shaders\Vertex2.glsl">
|
||||||
|
<Filter>Shaders</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="..\..\src\Shaders\Fragment2.glsl">
|
||||||
|
<Filter>Shaders</Filter>
|
||||||
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user