From 25616be7c1b51858fbb5d9ead6603a8debc15682 Mon Sep 17 00:00:00 2001 From: sam Date: Thu, 8 Sep 2016 02:16:13 -0700 Subject: [PATCH] introducing the light Clusters --- libraries/render-utils/src/LightClusters.h | 52 +++++++++++++++++++++- libraries/render-utils/src/LightStage.h | 2 +- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/libraries/render-utils/src/LightClusters.h b/libraries/render-utils/src/LightClusters.h index 3557ec0ed0..b3a2271b2e 100644 --- a/libraries/render-utils/src/LightClusters.h +++ b/libraries/render-utils/src/LightClusters.h @@ -15,11 +15,61 @@ #include "LightStage.h" -class ViewFrustum; +#include +/* +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 { public: + LightClusters(); + + + void updateFrustum(const ViewFrustum& frustum); + + + + ViewFrustum _frustum; + LightStagePointer _lightStage; gpu::BufferPointer _lightIndicesBuffer; diff --git a/libraries/render-utils/src/LightStage.h b/libraries/render-utils/src/LightStage.h index 4319eb80ba..b0d5c1749f 100644 --- a/libraries/render-utils/src/LightStage.h +++ b/libraries/render-utils/src/LightStage.h @@ -110,5 +110,5 @@ public: Shadows _shadows; }; - +using LightStagePointer = std::shared_ptr; #endif