Fixed shadow flickering.
This commit is contained in:
parent
ea248caa47
commit
3ee8cfdbad
13
graphics.cc
13
graphics.cc
@ -218,6 +218,12 @@ void Graphics::render(double time)
|
|||||||
fullscreen_quad->render();
|
fullscreen_quad->render();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
double nextUpdate = lastUpdate + lightUpdateDelay;
|
||||||
|
if (time >= nextUpdate)
|
||||||
|
{
|
||||||
|
updateLights();
|
||||||
|
lastUpdate = time;
|
||||||
|
}
|
||||||
// At first render shadows
|
// At first render shadows
|
||||||
depthCubeShader->use();
|
depthCubeShader->use();
|
||||||
depthCubeShader->setUniform("farPlane", farPlane);
|
depthCubeShader->setUniform("farPlane", farPlane);
|
||||||
@ -309,12 +315,6 @@ void Graphics::render(double time)
|
|||||||
// TODO look into doing this less often, offload to another thread?
|
// TODO look into doing this less often, offload to another thread?
|
||||||
// TODO figure out how to deal with bigger numbers of lights. load the nearest on demand?
|
// TODO figure out how to deal with bigger numbers of lights. load the nearest on demand?
|
||||||
|
|
||||||
double nextUpdate = lastUpdate + lightUpdateDelay;
|
|
||||||
if (time >= nextUpdate)
|
|
||||||
{
|
|
||||||
updateLights();
|
|
||||||
lastUpdate = time;
|
|
||||||
}
|
|
||||||
|
|
||||||
// convert texture to homogenouse coordinates
|
// convert texture to homogenouse coordinates
|
||||||
glm::mat4 biasMatrix(
|
glm::mat4 biasMatrix(
|
||||||
@ -409,6 +409,7 @@ void Graphics::updateClosestLights() {
|
|||||||
void Graphics::updateLights() {
|
void Graphics::updateLights() {
|
||||||
updateClosestLights();
|
updateClosestLights();
|
||||||
if (closestLights.size() > 0) {
|
if (closestLights.size() > 0) {
|
||||||
|
lightingShader->use();
|
||||||
lightingShader->setUniform("lightCount", (int) closestLights.size());
|
lightingShader->setUniform("lightCount", (int) closestLights.size());
|
||||||
lightingShader->setUniform("maxShadowRenderCount", std::min((int) closestLights.size(), (int)maxShadowRenderCount));
|
lightingShader->setUniform("maxShadowRenderCount", std::min((int) closestLights.size(), (int)maxShadowRenderCount));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user