Made getClosestLights output more lights to take advantage of the higher maxShadowSampleCount.
This commit is contained in:
parent
1ef8047f42
commit
67b44042bd
@ -649,7 +649,7 @@ void Graphics::render(double time)
|
|||||||
|
|
||||||
void Graphics::updateLights() {
|
void Graphics::updateLights() {
|
||||||
std::vector<std::shared_ptr<Light>> oldClosestLights = std::vector<std::shared_ptr<Light>>(*closestLights);
|
std::vector<std::shared_ptr<Light>> oldClosestLights = std::vector<std::shared_ptr<Light>>(*closestLights);
|
||||||
closestLights = level->getClosestLights();
|
closestLights = level->getClosestLights(maxShadowSampleCount);
|
||||||
if (closestLights->size() > 0) {
|
if (closestLights->size() > 0) {
|
||||||
lightingShader->use();
|
lightingShader->use();
|
||||||
lightingShader->setUniform("lightCount", (int) closestLights->size());
|
lightingShader->setUniform("lightCount", (int) closestLights->size());
|
||||||
@ -873,7 +873,7 @@ void Graphics::enqueueObjects(std::vector<std::vector<Object*>>* queue){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::initShadowRenderQueue() {
|
void Graphics::initShadowRenderQueue() {
|
||||||
closestLights = level->getClosestLights();
|
closestLights = level->getClosestLights(maxShadowSampleCount);
|
||||||
int maxLights = min((int)closestLights->size(), maxShadowSampleCount);
|
int maxLights = min((int)closestLights->size(), maxShadowSampleCount);
|
||||||
shadowRenderQueue = std::vector<ShadowRenderQueueSlot>(maxLights);
|
shadowRenderQueue = std::vector<ShadowRenderQueueSlot>(maxLights);
|
||||||
glViewport(0, 0, cube_size, cube_size);
|
glViewport(0, 0, cube_size, cube_size);
|
||||||
|
@ -468,14 +468,14 @@ bool Level::compareLightDistances(shared_ptr<Light> a, shared_ptr<Light> b) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<shared_ptr<Light>>* Level::getClosestLights() {
|
std::vector<shared_ptr<Light>>* Level::getClosestLights(unsigned int maximumAmount) {
|
||||||
closestLights = std::vector<shared_ptr<Light>>(lights);
|
closestLights = std::vector<shared_ptr<Light>>(lights);
|
||||||
std::sort(closestLights.begin(),
|
std::sort(closestLights.begin(),
|
||||||
closestLights.end(),
|
closestLights.end(),
|
||||||
[this](shared_ptr<Light> a, shared_ptr<Light> b) {return compareLightDistances(a, b); });
|
[this](shared_ptr<Light> a, shared_ptr<Light> b) {return compareLightDistances(a, b); });
|
||||||
if (lights.size() > 15) {
|
if (lights.size() > maximumAmount) {
|
||||||
closestLights = std::vector<shared_ptr<Light>>(&closestLights[0],
|
closestLights = std::vector<shared_ptr<Light>>(&closestLights[0],
|
||||||
&closestLights[15]);
|
&closestLights[maximumAmount]);
|
||||||
}
|
}
|
||||||
// sort pointers for faster comparisons
|
// sort pointers for faster comparisons
|
||||||
std::sort(closestLights.begin(), closestLights.end());
|
std::sort(closestLights.begin(), closestLights.end());
|
||||||
|
@ -86,7 +86,7 @@ class Level {
|
|||||||
void addToSpecificChunk(Object* object, int xPosition, int zPosition);
|
void addToSpecificChunk(Object* object, int xPosition, int zPosition);
|
||||||
void enqueueObjects(Graphics* graphics);
|
void enqueueObjects(Graphics* graphics);
|
||||||
void sortObjects(int textureCount);
|
void sortObjects(int textureCount);
|
||||||
std::vector<shared_ptr<Light>>* getClosestLights();
|
std::vector<shared_ptr<Light>>* getClosestLights(unsigned int maximumAmount);
|
||||||
int checkMaxSurroundingLights();
|
int checkMaxSurroundingLights();
|
||||||
private:
|
private:
|
||||||
std::vector<Chunk*> getSurroundingChunks(glm::vec3 center, int chunkRenderDistance);
|
std::vector<Chunk*> getSurroundingChunks(glm::vec3 center, int chunkRenderDistance);
|
||||||
|
Loading…
Reference in New Issue
Block a user