Example #1
0
        public void TryAddShadowCaster(ShadowCaster shadowCaster)
        {
            if (!shadowCaster.SphereWorld.Intersects(frustumBoundingBox))
            {
                return;
            }
            if (!shadowCaster.BoxWorld.Intersects(frustumBoundingBox))
            {
                return;
            }

            for (int i = 0; i < splitCameras.Length; i++)
            {
                var lightCamera = splitCameras[i];

                bool shouldAdd = false;
                if (shadowCaster.SphereWorld.Intersects(lightCamera.Frustum))
                {
                    shouldAdd = true;
                }
                else if (shadowCaster.BoxWorld.Intersects(lightCamera.Frustum))
                {
                    shouldAdd = true;
                }

                if (shouldAdd)
                {
                    // 投影オブジェクトとして登録。
                    splitShadowCasters[i].Enqueue(shadowCaster);

                    // AABB の頂点を包含座標として登録。
                    // TODO:
                    // これをやると領域が広くなりすぎてカメラが遠方に移動してしまい、
                    // PSSM の恩恵が得られなくなる。
                    //splitLightCameras[i].AddLightVolumePoints(corners);

                    Monitor[i].ShadowCasterCount++;
                    Monitor.TotalShadowCasterCount++;

                    //break;
                }
            }
        }
Example #2
0
        public void TryAddShadowCaster(ShadowCaster shadowCaster)
        {
            if (!shadowCaster.SphereWorld.Intersects(frustumBoundingBox)) return;
            if (!shadowCaster.BoxWorld.Intersects(frustumBoundingBox)) return;

            for (int i = 0; i < splitCameras.Length; i++)
            {
                var lightCamera = splitCameras[i];

                bool shouldAdd = false;
                if (shadowCaster.SphereWorld.Intersects(lightCamera.Frustum))
                {
                    shouldAdd = true;
                }
                else if (shadowCaster.BoxWorld.Intersects(lightCamera.Frustum))
                {
                    shouldAdd = true;
                }

                if (shouldAdd)
                {
                    // 投影オブジェクトとして登録。
                    splitShadowCasters[i].Enqueue(shadowCaster);

                    // AABB の頂点を包含座標として登録。
                    // TODO:
                    // これをやると領域が広くなりすぎてカメラが遠方に移動してしまい、
                    // PSSM の恩恵が得られなくなる。
                    //splitLightCameras[i].AddLightVolumePoints(corners);

                    Monitor[i].ShadowCasterCount++;
                    Monitor.TotalShadowCasterCount++;

                    //break;
                }
            }
        }