Beispiel #1
0
        private void Update()
        {
            if (raySource == null)
            {
                return;
            }

            if (m_OccluderProxies == null || m_OccluderProxies.Length == 0)
            {
                var occluders = PortalPrepareUtil.GetOccluderData();
                m_OccluderProxies = PortalPrepareUtil.GetOccluderProxies(occluders);
                foreach (Collider col in m_OccluderProxies)
                {
                    col.transform.SetParent(transform);
                }
            }

            var staticRenderers           = PortalPrepareUtil.GetStaticOccludeeRenderers();
            List <MeshRenderer> renderers = new List <MeshRenderer>();

            for (int i = 0; i < staticRenderers.Length; i++)
            {
                if (PortalVisibilityUtil.CheckAABBIntersection(raySource.position, raySource.forward, staticRenderers[i].bounds))
                {
                    Vector3 hitPosition;
                    if (PortalVisibilityUtil.CheckOcclusion(m_OccluderProxies, staticRenderers[i], raySource.position, raySource.forward, out hitPosition))
                    {
                        renderers.AddIfUnique(staticRenderers[i]);
                    }
                }
            }
            m_PassedRenderers = renderers.ToArray();
        }
Beispiel #2
0
        public void OnClickBake()
        {
            var passedRenderers = new List <MeshRenderer>();
            var rays            = new List <RayDebug>();

            m_Completion = 0.0f;
            m_BakeState  = BakeState.Volumes;
            var staticRenderers = PortalPrepareUtil.GetStaticOccludeeRenderers();

            m_SerializableVolumes = PortalPrepareUtil.GetVolumeData(VolumeMode.Auto, 0);

            m_BakeState = BakeState.Visibility;
            var rayCount = PortalVisibilityUtil.CalculateRayCount(m_RayDensity, m_SerializableVolumes[0].scaleWS);

            for (int r = 0; r < rayCount; r++)
            {
                var rayPosition  = PortalVisibilityUtil.GetRandomPointWithinVolume(m_SerializableVolumes[0]);
                var rayDirection = PortalVisibilityUtil.RandomSphericalDistributionVector();
                rays.Add(new RayDebug(rayPosition, rayDirection));

                foreach (MeshRenderer renderer in staticRenderers)
                {
                    if (PortalVisibilityUtil.CheckAABBIntersection(rayPosition, rayDirection, renderer.bounds))
                    {
                        passedRenderers.AddIfUnique(renderer);
                    }
                }
            }
            m_PassedRenderers = passedRenderers.ToArray();
            m_Rays            = rays.ToArray();
            m_BakeState       = BakeState.Active;
            m_Completion      = 1.0f;
            UnityEditor.SceneView.RepaintAll();
            UnityEditor.SceneManagement.EditorSceneManager.MarkAllScenesDirty();
        }
        private void Update()
        {
            if (raySource == null)
            {
                return;
            }

            var staticRenderers           = PortalPrepareUtil.GetStaticOccludeeRenderers();
            List <MeshRenderer> renderers = new List <MeshRenderer>();

            for (int i = 0; i < staticRenderers.Length; i++)
            {
                if (PortalVisibilityUtil.CheckAABBIntersection(raySource.position, raySource.forward, staticRenderers[i].bounds))
                {
                    renderers.Add(staticRenderers[i]);
                }
            }
            m_PassedRenderers = renderers.ToArray();
        }