-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changing shadow class to contain an array of shadowmaps since shadow …
…algorithms like variance shadow mapping and cascade shadow mapping need multiple shadow maps. Also, the shadow maps can contain a number of framebuffers if the shadows need to apply post processing. Next, the shadow class has a virtual function for applying post processing to shadows since algorithms like variance shadow mapping need bluring to work correctly. For one thing, the texture class suffered a total refactor so repetitive code like creating or loading the texture has been modularized. On the other hand, the Framebuffer class now better fits the needs of the system. Finally, the light classes have been change to match the Shadow class.
- Loading branch information
Showing
25 changed files
with
668 additions
and
406 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef GAUSSIAN_BLUR | ||
#define GAUSSIAN_BLUR | ||
|
||
#include <string> | ||
#include "../graphics/framebuffer.hpp" | ||
#include "../graphics/post_process.hpp" | ||
|
||
namespace nitro | ||
{ | ||
namespace core | ||
{ | ||
class GaussianBlur : public graphics::PostProcess | ||
{ | ||
public: | ||
|
||
GaussianBlur(int width, int height); | ||
void Process(const graphics::Shader& shader, graphics::Texture& in, graphics::Texture& out) override; | ||
|
||
private: | ||
graphics::Framebuffer framebuffer_; | ||
void Subprocess(const graphics::Shader& shader, graphics::Texture& in, graphics::Texture& out, bool vertical); | ||
}; | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef POST_PROCESS | ||
#define POST_PROCESS | ||
|
||
#include "./shader.hpp" | ||
#include "./texture.hpp" | ||
|
||
namespace nitro | ||
{ | ||
namespace graphics | ||
{ | ||
struct PostProcess | ||
{ | ||
virtual ~PostProcess() = default; | ||
virtual void Process(const Shader& shader, Texture& in, Texture& out) = 0; | ||
}; | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,26 @@ | ||
#version 410 core | ||
#version 330 core | ||
out vec4 FragColor; | ||
|
||
in vec2 TexCoords; | ||
|
||
uniform sampler2D image; | ||
uniform bool vertical; | ||
|
||
|
||
void main() | ||
{ | ||
float kernel[5] = float[](0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162); | ||
|
||
//texel size | ||
vec2 texel_size = 1.0 / textureSize(image, 0); | ||
vec3 result = texture(image, TexCoords).rgb * kernel[0]; | ||
vec2 offset = vertical ? vec2(0, 1) : vec2(1, 0); | ||
|
||
for(int i = 1; i < 5; i++) | ||
{ | ||
result += texture(image, TexCoords + offset * i * texel_size).rgb * kernel[i]; | ||
result += texture(image, TexCoords - offset * i * texel_size).rgb * kernel[i]; | ||
} | ||
|
||
FragColor = vec4(result, 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,12 @@ | ||
#version 410 core | ||
|
||
layout (location = 0) in vec3 aPosition; | ||
layout (location = 1) in vec2 aTexCoord; | ||
|
||
out vec2 TexCoords; | ||
|
||
void main() | ||
{ | ||
TexCoords = aTexCoord; | ||
gl_Position = vec4(aPosition, 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.