private void Update() { // Check if this source's transform has changed. if (transform.hasChanged) { m_Dirty = true; // Recalculate camera bounds. m_CameraBounds = LOSHelper.CalculateSourceBounds(m_Camera); // Reset transform changed flag. transform.hasChanged = false; } // Check if this source and it's frustum are visible to the camera used by the LOS mask. m_IsVisibile = GeometryUtility.TestPlanesAABB(LOSMask.CameraFrustumPlanes, m_CameraBounds); // Only update frustum planes when the source is visible and dirty. if (m_IsVisibile && m_Dirty) { // Recalculate frustum planes. LOSHelper.ExtractFrustumPlanes(m_FrustumPlanes, m_Camera); m_Dirty = false; } }
private void OnPreRender() { if (m_Camera == null) { return; } // Make sure we can acces the cameras depth buffer in our shader. m_Camera.depthTextureMode = DepthTextureMode.DepthNormals; // Update Mask Camera frutsum planes if needed. if (transform.hasChanged) { LOSHelper.ExtractFrustumPlanes(m_CameraFrustumPlanes, m_Camera); transform.hasChanged = false; } }
private void OnEnable() { // Check if this component can be enabled. // Disable if post processing not supported. enabled &= Util.Verify(SystemInfo.supportsImageEffects, "Image effects not supported."); // Disable if buffer storage is not assigned. enabled &= Util.Verify(m_BufferStorage != null, "LOS Buffer Storage property not assigned."); // Disable if camera component is missing. enabled &= Util.Verify(m_Camera != null, "Camera component missing."); if (enabled) { // Make sure Frustum planes are initiliazed. LOSHelper.ExtractFrustumPlanes(m_CameraFrustumPlanes, m_Camera); m_StencilMask = GetComponent <LOSStencilMask>(); } }
private void OnEnable() { // Register with LOS manager singleton. LOSManager.Instance.AddLOSSource(this); // Check if component can be enabled. enabled &= Util.Verify(m_Camera != null, "Camera Component missing"); if (enabled) { // Alert user if camera is set to orthographic. Debug.Assert(!m_Camera.orthographic, "Cameras attached to an LOS source can't be orthographic, changing to perspective!"); // Initiliaze source camera. LOSHelper.InitSourceCamera(m_Camera); // Initiliaze bounds. m_CameraBounds = LOSHelper.CalculateSourceBounds(m_Camera); // Initiliaze frustum planes. LOSHelper.ExtractFrustumPlanes(m_FrustumPlanes, m_Camera); } }