public void DisableSSAO() { ScreenSpaceAmbientOcclusion ssao = HeadCamera.GetComponent <ScreenSpaceAmbientOcclusion>(); if (ssao != null) { ssao.enabled = false; } }
protected IEnumerator SetupCameraRoutine() { while (HeadCamera == null) { yield return(WaitCache.Frame); } HeadCollider = HeadCamera.GetComponent <Collider>(); _nearClipVertsLocal = HeadCamera.EyeNearPlaneDimensions(); _nearClipVertsGlobal = new Vector3[_nearClipVertsLocal.Length]; }
/// <summary> /// Updates the back position of the Portal wall for visual seamlessness /// </summary> private void UpdateBackPosition() { CheeseActivated = -1; if (!Is3D) { transform.localScale = _defaultScale; } if (SeamlessRecursionFix != null) { SeamlessRecursionFix.gameObject.SetActive(false); } if (_headInPortalTrigger == false || HeadCamera == null || GlobalPortalSettings.PlayerTeleportable.MidTeleport) { return; } _nearClipVertsLocal = HeadCamera.EyeNearPlaneDimensions(); //Gets the near clipping plane verts in global space if (_nearClipVertsGlobal == null) { return; } for (var i = 0; i < _nearClipVertsGlobal.Length; i++) { _nearClipVertsGlobal[i] = HeadCamera.transform.position + HeadCamera.transform.rotation * _nearClipVertsLocal[i]; } //Moves the drawn "plane" back if the camera gets too close float deepestVert = 0; var deepestVertVector = Vector3.zero; var portalPlane = new Plane(-Origin.forward, Origin.position); foreach (var currentVert in _nearClipVertsGlobal) { var currentDepth = portalPlane.GetDistanceToPoint(currentVert); if (currentDepth < 0) { Debug.DrawLine(HeadCamera.transform.position, currentVert, Color.red); continue; } Debug.DrawLine(HeadCamera.transform.position, currentVert, Color.green); CheeseActivated = SKEffectCamera.CurrentDepth; if (currentDepth > deepestVert) { deepestVert = currentDepth; deepestVertVector = currentVert; } } //Scale the portal for seamless passthrough if (CheeseActivated != -1 && !Is3D) { SeamlessRecursionFix.gameObject.SetActive(true); //Reset scale so that InverseTransformPoint doesn't return a scaled value transform.localScale = Vector3.one; //Get the local-space distance var dotDist = -PortalUtils.PlanePointDistance(Vector3.forward, Vector3.zero, transform.InverseTransformPoint(deepestVertVector)); //Clamp to Fudge var dist = Mathf.Max(FudgeFactor, dotDist) * 1;//1.5f; //If the dist is too far, do not update the back position, there is a state machine offset if (dist >= 1) { transform.localScale = _defaultScale; return; } //Scale, so that the back wall updates properly. transform.localScale = new Vector3(1, 1, dist); } }