mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 16:36:54 +02:00
introducing the light Clusters
This commit is contained in:
parent
a4df8a84b7
commit
25616be7c1
2 changed files with 52 additions and 2 deletions
|
@ -15,11 +15,61 @@
|
||||||
|
|
||||||
#include "LightStage.h"
|
#include "LightStage.h"
|
||||||
|
|
||||||
class ViewFrustum;
|
#include <ViewFrustum.h>
|
||||||
|
/*
|
||||||
|
class FrustumGrid {
|
||||||
|
public:
|
||||||
|
float _near { 0.1f };
|
||||||
|
float _nearPrime { 1.0f };
|
||||||
|
float _farPrime { 400.0f };
|
||||||
|
float _far { 10000.0f };
|
||||||
|
|
||||||
|
glm::uvec3 _dims { 16, 16, 16 };
|
||||||
|
|
||||||
|
float viewToLinearDepth(float depth) const {
|
||||||
|
float nDepth = -depth;
|
||||||
|
float ldepth = (nDepth - _nearPrime) / (_farPrime - _nearPrime);
|
||||||
|
|
||||||
|
if (ldepth < 0.0f) {
|
||||||
|
return (nDepth - _near) / (_nearPrime - _near) - 1.0f;
|
||||||
|
}
|
||||||
|
if (ldepth > 1.0f) {
|
||||||
|
return (nDepth - _farPrime) / (_far - _farPrime) + 1.0f;
|
||||||
|
}
|
||||||
|
return ldepth;
|
||||||
|
}
|
||||||
|
|
||||||
|
float linearToGridDepth(float depth) const {
|
||||||
|
return depth / (float) _dims.z;
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::vec2 linearToGridXY(const glm::vec3& cpos) const {
|
||||||
|
return glm::vec2(cpos.x / (float) _dims.x, cpos.y / (float) _dims.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
int gridDepthToLayer(float gridDepth) const {
|
||||||
|
return (int) gridDepth;
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::ivec3 viewToGridPos(const glm::vec3& pos) const {
|
||||||
|
|
||||||
|
return glm::ivec3(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
*/
|
||||||
class LightClusters {
|
class LightClusters {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
LightClusters();
|
||||||
|
|
||||||
|
|
||||||
|
void updateFrustum(const ViewFrustum& frustum);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
ViewFrustum _frustum;
|
||||||
|
|
||||||
LightStagePointer _lightStage;
|
LightStagePointer _lightStage;
|
||||||
|
|
||||||
gpu::BufferPointer _lightIndicesBuffer;
|
gpu::BufferPointer _lightIndicesBuffer;
|
||||||
|
|
|
@ -110,5 +110,5 @@ public:
|
||||||
|
|
||||||
Shadows _shadows;
|
Shadows _shadows;
|
||||||
};
|
};
|
||||||
|
using LightStagePointer = std::shared_ptr<LightStage>;
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue