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() {
|
||||
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) {
|
||||
lightingShader->use();
|
||||
lightingShader->setUniform("lightCount", (int) closestLights->size());
|
||||
@ -873,7 +873,7 @@ void Graphics::enqueueObjects(std::vector<std::vector<Object*>>* queue){
|
||||
}
|
||||
|
||||
void Graphics::initShadowRenderQueue() {
|
||||
closestLights = level->getClosestLights();
|
||||
closestLights = level->getClosestLights(maxShadowSampleCount);
|
||||
int maxLights = min((int)closestLights->size(), maxShadowSampleCount);
|
||||
shadowRenderQueue = std::vector<ShadowRenderQueueSlot>(maxLights);
|
||||
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);
|
||||
std::sort(closestLights.begin(),
|
||||
closestLights.end(),
|
||||
[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[15]);
|
||||
&closestLights[maximumAmount]);
|
||||
}
|
||||
// sort pointers for faster comparisons
|
||||
std::sort(closestLights.begin(), closestLights.end());
|
||||
|
@ -86,7 +86,7 @@ class Level {
|
||||
void addToSpecificChunk(Object* object, int xPosition, int zPosition);
|
||||
void enqueueObjects(Graphics* graphics);
|
||||
void sortObjects(int textureCount);
|
||||
std::vector<shared_ptr<Light>>* getClosestLights();
|
||||
std::vector<shared_ptr<Light>>* getClosestLights(unsigned int maximumAmount);
|
||||
int checkMaxSurroundingLights();
|
||||
private:
|
||||
std::vector<Chunk*> getSurroundingChunks(glm::vec3 center, int chunkRenderDistance);
|
||||
|
Loading…
Reference in New Issue
Block a user