mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-29 08:00:56 -04:00
Implement a more sensible shadow map cascading system
This commit is contained in:
parent
617473c7da
commit
7cce2d6f87
@ -596,14 +596,34 @@ namespace SceneUtil
|
|||||||
if (numShadowMapsPerLight>1)
|
if (numShadowMapsPerLight>1)
|
||||||
{
|
{
|
||||||
// compute the start and end range in non-dimensional coords
|
// compute the start and end range in non-dimensional coords
|
||||||
#if 1
|
#if 0
|
||||||
double r_start = (sm_i == 0) ? -1.0 : (double(sm_i) / double(numShadowMapsPerLight)*2.0 - 1.0);
|
double r_start = (sm_i == 0) ? -1.0 : (double(sm_i) / double(numShadowMapsPerLight)*2.0 - 1.0);
|
||||||
double r_end = (sm_i + 1 == numShadowMapsPerLight) ? 1.0 : (double(sm_i + 1) / double(numShadowMapsPerLight)*2.0 - 1.0);
|
double r_end = (sm_i + 1 == numShadowMapsPerLight) ? 1.0 : (double(sm_i + 1) / double(numShadowMapsPerLight)*2.0 - 1.0);
|
||||||
#else
|
#elif 0
|
||||||
|
|
||||||
// hardwired for 2 splits
|
// hardwired for 2 splits
|
||||||
double r_start = (sm_i == 0) ? -1.0 : splitPoint;
|
double r_start = (sm_i == 0) ? -1.0 : splitPoint;
|
||||||
double r_end = (sm_i + 1 == numShadowMapsPerLight) ? 1.0 : splitPoint;
|
double r_end = (sm_i + 1 == numShadowMapsPerLight) ? 1.0 : splitPoint;
|
||||||
|
#else
|
||||||
|
double r_start, r_end;
|
||||||
|
// Split such that each shadow map covers a quarter of the area of the one after it
|
||||||
|
if (sm_i == 0)
|
||||||
|
r_start = -1.0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
r_start = (1 - pow(4.0, sm_i)) / (1 - pow(4.0, numShadowMapsPerLight));
|
||||||
|
r_start *= 2.0;
|
||||||
|
r_start -= 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sm_i + 1 == numShadowMapsPerLight)
|
||||||
|
r_end = 1.0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
r_end = (1 - pow(4.0, sm_i + 1)) / (1 - pow(4.0, numShadowMapsPerLight));
|
||||||
|
r_end *= 2.0;
|
||||||
|
r_end -= 1.0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// for all by the last shadowmap shift the r_end so that it overlaps slightly with the next shadowmap
|
// for all by the last shadowmap shift the r_end so that it overlaps slightly with the next shadowmap
|
||||||
|
Loading…
x
Reference in New Issue
Block a user