Progress done, changing workstation
This commit is contained in:
parent
81446dee6a
commit
ea937db226
@ -201,6 +201,8 @@
|
|||||||
<None Include="fog.frag" />
|
<None Include="fog.frag" />
|
||||||
<None Include="fog.vert" />
|
<None Include="fog.vert" />
|
||||||
<None Include="base_light.vert" />
|
<None Include="base_light.vert" />
|
||||||
|
<None Include="GBufferVisual.frag" />
|
||||||
|
<None Include="GBufferVisual.vert" />
|
||||||
<None Include="light_pov.frag" />
|
<None Include="light_pov.frag" />
|
||||||
<None Include="light_pov.vert" />
|
<None Include="light_pov.vert" />
|
||||||
<None Include="nmap.frag" />
|
<None Include="nmap.frag" />
|
||||||
|
|||||||
@ -25,6 +25,9 @@
|
|||||||
<Filter Include="MankyuCode">
|
<Filter Include="MankyuCode">
|
||||||
<UniqueIdentifier>{b0c228ca-8e29-48df-a9f6-59fb58accad5}</UniqueIdentifier>
|
<UniqueIdentifier>{b0c228ca-8e29-48df-a9f6-59fb58accad5}</UniqueIdentifier>
|
||||||
</Filter>
|
</Filter>
|
||||||
|
<Filter Include="Shaders\PPShaders">
|
||||||
|
<UniqueIdentifier>{be4b14ab-faab-4412-8a5b-ce9c1510772f}</UniqueIdentifier>
|
||||||
|
</Filter>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="Source.cpp">
|
<ClCompile Include="Source.cpp">
|
||||||
@ -217,23 +220,33 @@
|
|||||||
<None Include="skybox.frag">
|
<None Include="skybox.frag">
|
||||||
<Filter>Shaders</Filter>
|
<Filter>Shaders</Filter>
|
||||||
</None>
|
</None>
|
||||||
<None Include="textureViewer.vert">
|
<None Include="light_pov.frag" />
|
||||||
<Filter>MankyuCode</Filter>
|
<None Include="light_pov.vert" />
|
||||||
</None>
|
<None Include="shadow_light.frag" />
|
||||||
|
<None Include="shadow_light.vert" />
|
||||||
<None Include="textureViewer.frag">
|
<None Include="textureViewer.frag">
|
||||||
<Filter>MankyuCode</Filter>
|
<Filter>Shaders\PPShaders</Filter>
|
||||||
</None>
|
</None>
|
||||||
<None Include="DSGeometryPass.vert">
|
<None Include="textureViewer.vert">
|
||||||
<Filter>Shaders</Filter>
|
<Filter>Shaders\PPShaders</Filter>
|
||||||
</None>
|
</None>
|
||||||
<None Include="DSGeometryPass.frag">
|
<None Include="GBufferVisual.vert">
|
||||||
<Filter>Shaders</Filter>
|
<Filter>Shaders\PPShaders</Filter>
|
||||||
</None>
|
</None>
|
||||||
<None Include="DSLightPass.vert">
|
<None Include="GBufferVisual.frag">
|
||||||
<Filter>Shaders</Filter>
|
<Filter>Shaders\PPShaders</Filter>
|
||||||
</None>
|
</None>
|
||||||
<None Include="DSLightPass.frag">
|
<None Include="DSLightPass.frag">
|
||||||
<Filter>Shaders</Filter>
|
<Filter>Shaders\PPShaders</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="DSGeometryPass.frag">
|
||||||
|
<Filter>Shaders\PPShaders</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="DSGeometryPass.vert">
|
||||||
|
<Filter>Shaders\PPShaders</Filter>
|
||||||
|
</None>
|
||||||
|
<None Include="DSLightPass.vert">
|
||||||
|
<Filter>Shaders\PPShaders</Filter>
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -1,10 +1,24 @@
|
|||||||
#version 440
|
#version 440
|
||||||
//Copy of simple.frag
|
layout (location = 0) out vec3 gPosition;
|
||||||
|
layout (location = 1) out vec3 gNormal;
|
||||||
|
layout (location = 2) out vec4 gAlbedoSpec;
|
||||||
|
|
||||||
in vec3 f_color;
|
in vec2 TexCoords;
|
||||||
out vec4 FragColors;
|
in vec3 FragPos;
|
||||||
|
in vec3 Normal;
|
||||||
|
|
||||||
|
//uniform sampler2D texture_diffuse1;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColors = vec4(f_color, 1.f);
|
// store the fragment position vector in the first gbuffer texture
|
||||||
|
gPosition = FragPos;
|
||||||
|
// also store the per-fragment normals into the gbuffer
|
||||||
|
gNormal = normalize(Normal);
|
||||||
|
// and the diffuse per-fragment color
|
||||||
|
gAlbedoSpec.rgb = vec3(1, 1, 1);
|
||||||
|
//gAlbedoSpec.rgb = texture(texture_diffuse1, TexCoords).rgb;
|
||||||
|
// store specular intensity in gAlbedoSpec's alpha component
|
||||||
|
//gAlbedoSpec.a = texture(texture_specular1, TexCoords).r;
|
||||||
|
gAlbedoSpec.a = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,19 @@
|
|||||||
#version 440
|
#version 440
|
||||||
// Copy of simple.vert
|
|
||||||
|
|
||||||
layout(location=0) in vec3 coord3d;
|
layout(location=0) in vec3 coord3d;
|
||||||
layout(location=1) in vec3 v_normal;
|
layout(location=1) in vec3 v_normal;
|
||||||
layout(location=2) in vec3 v_color;
|
|
||||||
layout(location=3) in vec2 v_texmap;
|
layout(location=3) in vec2 v_texmap;
|
||||||
|
|
||||||
|
out vec2 TexCoords;
|
||||||
out vec3 f_color;
|
out vec3 FragPos;
|
||||||
|
out vec3 Normal;
|
||||||
|
|
||||||
uniform mat4 mvp;
|
uniform mat4 mvp;
|
||||||
|
|
||||||
void main(void)
|
void main(void)
|
||||||
{
|
{
|
||||||
f_color = v_color;
|
Normal = v_normal;
|
||||||
|
TexCoords = v_texmap;
|
||||||
gl_Position = mvp * vec4(coord3d, 1.0f);
|
gl_Position = mvp * vec4(coord3d, 1.0f);
|
||||||
|
FragPos = gl_Position.xyz;
|
||||||
}
|
}
|
||||||
37
BaseGLProject/GBufferVisual.frag
Normal file
37
BaseGLProject/GBufferVisual.frag
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#version 430
|
||||||
|
out vec4 FragColor;
|
||||||
|
|
||||||
|
in vec2 TexCoords;
|
||||||
|
|
||||||
|
uniform sampler2D gPosition;
|
||||||
|
uniform sampler2D gNormal;
|
||||||
|
uniform sampler2D gAlbedoSpec;
|
||||||
|
|
||||||
|
subroutine vec4 shading_t();
|
||||||
|
subroutine uniform shading_t Shading;
|
||||||
|
|
||||||
|
subroutine(shading_t)
|
||||||
|
vec4 DisplayAlbedo()
|
||||||
|
{
|
||||||
|
vec3 Albedo = texture(gAlbedoSpec, TexCoords).rgb;
|
||||||
|
return vec4(Albedo, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
subroutine(shading_t)
|
||||||
|
vec4 DisplayPositions()
|
||||||
|
{
|
||||||
|
vec3 FragPos = texture(gPosition, TexCoords).rgb;
|
||||||
|
return vec4(FragPos, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
subroutine(shading_t)
|
||||||
|
vec4 DisplayNormals()
|
||||||
|
{
|
||||||
|
vec3 Normal = texture(gNormal, TexCoords).rgb;
|
||||||
|
return vec4(Normal, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void main(void)
|
||||||
|
{
|
||||||
|
FragColor = Shading();
|
||||||
|
}
|
||||||
12
BaseGLProject/GBufferVisual.vert
Normal file
12
BaseGLProject/GBufferVisual.vert
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
layout(location = 0) in vec2 vPosition;
|
||||||
|
layout(location = 1) in vec2 vUV;
|
||||||
|
|
||||||
|
out vec2 TexCoords;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = vec4(vPosition,0.0,1.0);
|
||||||
|
TexCoords = vUV;
|
||||||
|
}
|
||||||
@ -14,7 +14,8 @@ void Multipass::setDrawBuffers()
|
|||||||
{
|
{
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, _fboId);
|
glBindFramebuffer(GL_FRAMEBUFFER, _fboId);
|
||||||
glDrawBuffers(_draw_buffers_size, _draw_buffers);
|
glDrawBuffers(_draw_buffers_size, _draw_buffers);
|
||||||
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
|
int framebuffer_status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||||
|
if (framebuffer_status != GL_FRAMEBUFFER_COMPLETE)
|
||||||
throw std::runtime_error("Error during framebuffer initialisation");
|
throw std::runtime_error("Error during framebuffer initialisation");
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
}
|
}
|
||||||
@ -35,7 +36,7 @@ Multipass::~Multipass()
|
|||||||
glDeleteFramebuffers(1, &_fboId);
|
glDeleteFramebuffers(1, &_fboId);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Multipass::addTexture(const std::string & tex_name, GLuint filter, GLuint type, GLuint type_2,
|
void Multipass::addTexture(const std::string & tex_name, GLuint filter, GLuint type, GLuint type_2, GLuint type_3,
|
||||||
bool depth, SceneContext &scnctx, GLuint height, GLuint width)
|
bool depth, SceneContext &scnctx, GLuint height, GLuint width)
|
||||||
{
|
{
|
||||||
height = (height == 0) ? scnctx.height : height;
|
height = (height == 0) ? scnctx.height : height;
|
||||||
@ -44,7 +45,7 @@ void Multipass::addTexture(const std::string & tex_name, GLuint filter, GLuint t
|
|||||||
glBindFramebuffer(GL_FRAMEBUFFER, _fboId);
|
glBindFramebuffer(GL_FRAMEBUFFER, _fboId);
|
||||||
glGenTextures(1, &_pass_textures[tex_name]);;
|
glGenTextures(1, &_pass_textures[tex_name]);;
|
||||||
glBindTexture(GL_TEXTURE_2D, _pass_textures[tex_name]);
|
glBindTexture(GL_TEXTURE_2D, _pass_textures[tex_name]);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type_2, GL_FLOAT, 0);
|
glTexImage2D(GL_TEXTURE_2D, 0, type, width, height, 0, type_2, type_3, 0);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
@ -66,14 +67,11 @@ void Multipass::enableFrameBufferTexture(const std::string tex_name)
|
|||||||
|
|
||||||
void Multipass::drawResultToScreen(SceneContext & scnctx)
|
void Multipass::drawResultToScreen(SceneContext & scnctx)
|
||||||
{
|
{
|
||||||
//EXAMPLE CODE
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
glViewport(0, 0, scnctx.width, scnctx.height);
|
glViewport(0, 0, scnctx.width, scnctx.height);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
shader->enable();
|
shader->enable();
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, _pass_textures[_current_tex]);
|
|
||||||
shader->addUniform("tex", 0);
|
|
||||||
glBindVertexArray(_quad_vao);
|
glBindVertexArray(_quad_vao);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, _quad_vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, _quad_vbo);
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
|
|||||||
@ -15,7 +15,7 @@ public:
|
|||||||
void setDrawBuffers();
|
void setDrawBuffers();
|
||||||
void bindToFrameBuffer(GLenum type, GLenum texture, std::string texName);
|
void bindToFrameBuffer(GLenum type, GLenum texture, std::string texName);
|
||||||
|
|
||||||
void addTexture(const std::string &tex_name, GLuint filter, GLuint type, GLuint type_2,
|
void addTexture(const std::string &tex_name, GLuint filter, GLuint type, GLuint type_2, GLuint type_3,
|
||||||
bool depth, SceneContext &scnctx, GLuint height = 0, GLuint width = 0);
|
bool depth, SceneContext &scnctx, GLuint height = 0, GLuint width = 0);
|
||||||
|
|
||||||
void enableFrameBufferTexture(const std::string tex_name);
|
void enableFrameBufferTexture(const std::string tex_name);
|
||||||
|
|||||||
@ -117,10 +117,13 @@ void MyGlWindow::shaderSetup()
|
|||||||
shaders["Skybox"]->addUniform("RefractionIndex", glm::vec3(0.65, 0.67, 0.69));
|
shaders["Skybox"]->addUniform("RefractionIndex", glm::vec3(0.65, 0.67, 0.69));
|
||||||
|
|
||||||
shaders["DSGeometryPass"] = new Shader("DSGeometryPass.vert", "DSGeometryPass.frag");
|
shaders["DSGeometryPass"] = new Shader("DSGeometryPass.vert", "DSGeometryPass.frag");
|
||||||
shaders["DSGeometryPass"]->uniformFlags = MVP_FLAG | KA_FLAG | KD_FLAG | KS_FLAG | SHINE_FLAG;
|
shaders["DSGeometryPass"]->uniformFlags = MVP_FLAG;
|
||||||
|
|
||||||
shaders["DSLightPass"] = new Shader("DSLightPass.vert", "DSLightPass.frag");
|
shaders["DSLightPass"] = new Shader("DSLightPass.vert", "DSLightPass.frag");
|
||||||
shaders["DSLightPass"]->uniformFlags = LIGHTS_FLAG;
|
shaders["DSLightPass"]->uniformFlags = LIGHTS_FLAG;
|
||||||
|
|
||||||
|
shaders["GBufferVisual"] = new Shader("GBufferVisual.vert", "GBufferVisual.frag");
|
||||||
|
shaders["GBufferVisual"]->uniformFlags = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyGlWindow::lightSetup()
|
void MyGlWindow::lightSetup()
|
||||||
@ -139,23 +142,29 @@ void MyGlWindow::lightSetup()
|
|||||||
|
|
||||||
void MyGlWindow::multipassSetup()
|
void MyGlWindow::multipassSetup()
|
||||||
{
|
{
|
||||||
//_multipassManager.shader = shaders["ShadowLight"];
|
_multipassManager.shader = shaders["GBufferVisual"];
|
||||||
_multipassManager.addTexture("position_buffer", GL_NEAREST, GL_RGB, GL_FLOAT, false, _scnctx);
|
_multipassManager.addTexture("position_buffer", GL_NEAREST, GL_RGB16F, GL_RGB, GL_FLOAT, false, _scnctx);
|
||||||
_multipassManager.addTexture("normal_buffer", GL_NEAREST, GL_RGB, GL_RGB, false, _scnctx);
|
_multipassManager.addTexture("normal_buffer", GL_NEAREST, GL_RGB16F, GL_RGB, GL_UNSIGNED_BYTE, false, _scnctx);
|
||||||
_multipassManager.addTexture("color_buffer", GL_NEAREST, GL_RGB, GL_RGB, false, _scnctx);
|
_multipassManager.addTexture("color_buffer", GL_NEAREST, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, false, _scnctx);
|
||||||
_multipassManager.bindToFrameBuffer(GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, "position_buffer");
|
_multipassManager.bindToFrameBuffer(GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, "position_buffer");
|
||||||
_multipassManager.bindToFrameBuffer(GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, "normal_buffer");
|
_multipassManager.bindToFrameBuffer(GL_COLOR_ATTACHMENT1, GL_TEXTURE_2D, "normal_buffer");
|
||||||
_multipassManager.bindToFrameBuffer(GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, "color_buffer");
|
_multipassManager.bindToFrameBuffer(GL_COLOR_ATTACHMENT2, GL_TEXTURE_2D, "color_buffer");
|
||||||
|
|
||||||
//_multipassManager.setDrawBuffers();
|
_multipassManager.setDrawBuffers();
|
||||||
|
|
||||||
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "depthing");
|
//Deferred lighting shader
|
||||||
|
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "DisplayAlbedo");
|
||||||
|
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "DisplayPositions");
|
||||||
|
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "DisplayNormals");
|
||||||
|
|
||||||
|
//Standard post-process shader
|
||||||
|
/*_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "depthing");
|
||||||
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "blurring");
|
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "blurring");
|
||||||
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "sharpening");
|
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "sharpening");
|
||||||
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "sepia");
|
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "sepia");
|
||||||
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "grayscale");
|
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "grayscale");
|
||||||
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "sobel_filter");
|
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "sobel_filter");
|
||||||
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "absolutely_no_postprocess");
|
_multipassManager.shader->addSubroutine(GL_FRAGMENT_SHADER, "absolutely_no_postprocess");*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyGlWindow::setup()
|
void MyGlWindow::setup()
|
||||||
@ -174,7 +183,7 @@ void MyGlWindow::setup()
|
|||||||
|
|
||||||
Dataset moddata;
|
Dataset moddata;
|
||||||
moddata.checkeredFloor(100, 100, glm::vec3(0.1, 0.1, 0.1), glm::vec3(0.7, 0.7, 0.7));
|
moddata.checkeredFloor(100, 100, glm::vec3(0.1, 0.1, 0.1), glm::vec3(0.7, 0.7, 0.7));
|
||||||
meshes.emplace("Floor", new Mesh(moddata, shaders["BaseLight"]));
|
meshes.emplace("Floor", new Mesh(moddata, shaders["DSGeometryPass"]));
|
||||||
|
|
||||||
moddata.simpleCube();
|
moddata.simpleCube();
|
||||||
|
|
||||||
@ -185,7 +194,7 @@ void MyGlWindow::setup()
|
|||||||
for (int i = 0; i < 30; i++)
|
for (int i = 0; i < 30; i++)
|
||||||
{
|
{
|
||||||
std::string cube_name = "Cube" + std::to_string(i);
|
std::string cube_name = "Cube" + std::to_string(i);
|
||||||
meshes.emplace(cube_name, new Mesh(moddata, shaders["BaseLight"]));
|
meshes.emplace(cube_name, new Mesh(moddata, shaders["DSGeometryPass"]));
|
||||||
|
|
||||||
float pos_x = std::rand() % 100 - 50;
|
float pos_x = std::rand() % 100 - 50;
|
||||||
float pos_z = std::rand() % 100 - 50;
|
float pos_z = std::rand() % 100 - 50;
|
||||||
@ -224,11 +233,12 @@ void MyGlWindow::draw()
|
|||||||
glViewport(0, 0, _scnctx.width, _scnctx.height);
|
glViewport(0, 0, _scnctx.width, _scnctx.height);
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
|
_multipassManager.enableFrameBufferTexture("color_buffer");
|
||||||
|
|
||||||
for (auto it = meshes.begin(); it != meshes.end(); it++)
|
for (auto it = meshes.begin(); it != meshes.end(); it++)
|
||||||
(*it).second->draw(_scnctx);
|
(*it).second->draw(_scnctx);
|
||||||
|
|
||||||
//_multipassManager.drawResultToScreen(_scnctx);
|
_multipassManager.drawResultToScreen(_scnctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user