-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
486 additions
and
73 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
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,37 @@ | ||
#ifndef OWDS_GRAPHICS_OPNEGL_SHADOW_H | ||
#define OWDS_GRAPHICS_OPNEGL_SHADOW_H | ||
|
||
#include <array> | ||
|
||
#include "overworld/Engine/Graphics/OpenGL/Camera.h" | ||
|
||
namespace owds { | ||
class Shader; | ||
|
||
class Shadow | ||
{ | ||
public: | ||
void init(float near_plane, float far_plane); | ||
void bindFrameBuffer() const; | ||
void setUniforms(const Shader& shader, unsigned int texture_offset) const; | ||
void setLighntMatrices(); | ||
void computeLightSpaceMatrices(Camera ref_cam, const glm::vec3& light_dir); | ||
|
||
private: | ||
std::vector<glm::mat4> lightspace_matrices_; | ||
|
||
unsigned int matrices_uniform_buffer_; | ||
unsigned int depth_framebuffer_; | ||
unsigned int depth_maps_; | ||
unsigned int resolution_ = 4096; | ||
|
||
float near_plane_; | ||
float far_plane_; | ||
std::vector<float> shadow_cascade_levels_; | ||
|
||
glm::mat4 getLightSpaceMatrix(Camera& ref_cam, const glm::vec3& light_dir, float near_plane, float far_plane); | ||
}; | ||
|
||
} // namespace owds | ||
|
||
#endif // OWDS_GRAPHICS_OPNEGL_SHADOW_H |
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,5 @@ | ||
#version 330 core | ||
|
||
void main() | ||
{ | ||
} |
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,20 @@ | ||
#version 410 core | ||
|
||
layout(triangles, invocations = 5) in; | ||
layout(triangle_strip, max_vertices = 3) out; | ||
|
||
layout (std140) uniform LightSpaceMatrices | ||
{ | ||
mat4 light_space_matrices[16]; | ||
}; | ||
|
||
void main() | ||
{ | ||
for (int i = 0; i < 3; ++i) | ||
{ | ||
gl_Position = light_space_matrices[gl_InvocationID] * gl_in[i].gl_Position; | ||
gl_Layer = gl_InvocationID; | ||
EmitVertex(); | ||
} | ||
EndPrimitive(); | ||
} |
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,9 @@ | ||
#version 330 core | ||
layout (location = 0) in vec3 aPos; | ||
|
||
uniform mat4 model; | ||
|
||
void main() | ||
{ | ||
gl_Position = model * vec4(aPos, 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
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.