Working shadows, no cascade blend yet
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
#include "ShadowPassState.h"
|
||||
#include "imgui/imgui.h"
|
||||
|
||||
#define MAX_SPLITS 5
|
||||
#define MAX_SPLITS 3
|
||||
#define MAP_SIZE 216.f
|
||||
|
||||
enum NearFar { Near = 0, Far = 1 };
|
||||
enum LRBT { Left = 0, Right = 1, Bottom = 2, Top = 3 };
|
||||
@@ -19,6 +20,18 @@ struct ShadowCamera{
|
||||
std::array<glm::vec3, 8> frustumCorners;
|
||||
};
|
||||
|
||||
struct Frustum
|
||||
{
|
||||
float NearClip;
|
||||
float FarClip;
|
||||
float FOV;
|
||||
float AspectRatio;
|
||||
glm::vec3 MiddlePoint;
|
||||
float Radius;
|
||||
std::array<float, 4> LRTB;
|
||||
std::array<glm::vec3, 8> CornerPoint;
|
||||
};
|
||||
|
||||
class ShadowPass
|
||||
{
|
||||
public:
|
||||
@@ -31,15 +44,23 @@ public:
|
||||
void ClearBuffer();
|
||||
void Draw(RenderScene& scene);
|
||||
|
||||
GLuint DepthMap() const { return m_DepthMap[m_ShadowLevel]; }
|
||||
glm::mat4 lightP() const { return m_LightProjection[m_ShadowLevel]; }
|
||||
glm::mat4 lightV() const { return m_LightView[m_ShadowLevel]; }
|
||||
GLuint DepthMap(int level) const { return m_DepthMap[level]; }
|
||||
std::array<glm::mat4, MAX_SPLITS> lightP() const { return m_LightProjection; }
|
||||
std::array<glm::mat4, MAX_SPLITS> lightV() const { return m_LightView; }
|
||||
std::array<float, MAX_SPLITS> farDistance() const { return { m_shadFrusta[0].FarClip, m_shadFrusta[1].FarClip, m_shadFrusta[2].FarClip }; }
|
||||
int CurrentNrOfSplits() const { return m_CurrentNrOfSplits; }
|
||||
private:
|
||||
void UpdateFrustumPoints(Frustum& frustum, glm::vec3 camera_position, glm::vec3 view_dir, glm::mat4 p, glm::mat4 v);
|
||||
void UpdateSplitDist(std::array<Frustum, MAX_SPLITS>& frusta, float near_distance, float far_distance);
|
||||
glm::mat4 ApplyCropMatrix(Frustum& frustum, glm::mat4 m, glm::mat4 v);
|
||||
|
||||
glm::mat4 CalculateFrustum(RenderScene & scene, std::shared_ptr<DirectionalLightJob> directionalLightJob, ShadowCamera shad_cam);
|
||||
std::array<glm::vec3, 8> UpdateFrustumPoints(Camera* cam, glm::vec3 center, glm::vec3 view_dir);
|
||||
void UpdateSplitDist(std::array<ShadowCamera, MAX_SPLITS> shadow_cams, float far_distance, float near_distance);
|
||||
glm::mat4 FindNewFrustum(ShadowCamera shadow_cam);
|
||||
glm::mat4 FindNewFrustum(Frustum frustum, glm::mat4 v, glm::mat4 p);
|
||||
void InitializeCameras(RenderScene & scene);
|
||||
float FindRadius(Frustum& frustum);
|
||||
void PointsToLightspace(Frustum& frustum, glm::mat4 v);
|
||||
void RadiusToLightspace(Frustum& frustum, glm::mat4 v);
|
||||
|
||||
|
||||
EventBroker* m_EventBroker;
|
||||
const IRenderer* m_Renderer;
|
||||
@@ -63,9 +84,11 @@ private:
|
||||
int m_ShadowLevel = 0;
|
||||
|
||||
int m_CurrentNrOfSplits = 3;
|
||||
float m_SplitWeight = 0.5f;
|
||||
float m_SplitWeight = 0.75f;
|
||||
|
||||
std::array<ShadowCamera, MAX_SPLITS> m_shadCams;
|
||||
//std::array<ShadowCamera, MAX_SPLITS> m_shadCams;
|
||||
Frustum m_MainCamera;
|
||||
std::array<Frustum, MAX_SPLITS> m_shadFrusta;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user