diff options
Diffstat (limited to 'src/renderergl2/tr_scene.c')
-rw-r--r-- | src/renderergl2/tr_scene.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/renderergl2/tr_scene.c b/src/renderergl2/tr_scene.c index 42350365..51bb412e 100644 --- a/src/renderergl2/tr_scene.c +++ b/src/renderergl2/tr_scene.c @@ -499,9 +499,30 @@ void RE_RenderScene( const refdef_t *fd ) { // playing with even more shadows if(glRefConfig.framebufferObject && r_sunlightMode->integer && !( fd->rdflags & RDF_NOWORLDMODEL ) && (r_forceSun->integer || tr.sunShadows)) { - R_RenderSunShadowMaps(fd, 0); - R_RenderSunShadowMaps(fd, 1); - R_RenderSunShadowMaps(fd, 2); + if (r_shadowCascadeZFar != 0) + { + R_RenderSunShadowMaps(fd, 0); + R_RenderSunShadowMaps(fd, 1); + R_RenderSunShadowMaps(fd, 2); + } + else + { + Mat4Zero(tr.refdef.sunShadowMvp[0]); + Mat4Zero(tr.refdef.sunShadowMvp[1]); + Mat4Zero(tr.refdef.sunShadowMvp[2]); + } + + // only rerender last cascade if sun has changed position + if (r_forceSun->integer == 2 || !VectorCompare(tr.refdef.sunDir, tr.lastCascadeSunDirection)) + { + VectorCopy(tr.refdef.sunDir, tr.lastCascadeSunDirection); + R_RenderSunShadowMaps(fd, 3); + Mat4Copy(tr.refdef.sunShadowMvp[3], tr.lastCascadeSunMvp); + } + else + { + Mat4Copy(tr.lastCascadeSunMvp, tr.refdef.sunShadowMvp[3]); + } } // playing with cube maps |