Exemplo n.º 1
0
        /// <summary>
        /// Calls the rendering of a Portal frame
        /// </summary>
        private void OnWillRenderObject()
        {
            if (!TargetPortal)
            {
                return;
            }
            //Is the mesh renderer in the camera frustrum?
            if (MeshRenderer.isVisible)
            {
                UpdateDopplegangers();
                TargetPortal.UpdateDopplegangers();

#if UNITY_EDITOR
                if (Camera.current.name == "SceneCamera" || Camera.current.name == "Preview Camera")
                {
                    return;
                }
#endif
                TryRenderPortal(Camera.current, _nearClipVertsGlobal);
                if (Camera.current == Camera.main)
                {
                    SKSGlobalRenderSettings.Inverted = SKSGlobalRenderSettings.Inverted;
                    SKSGlobalRenderSettings.UvFlip   = SKSGlobalRenderSettings.UvFlip;
                }
                MeshRenderer.GetPropertyBlock(_seamlessRecursionBlock);
                SeamlessRecursionRenderer.SetPropertyBlock(_seamlessRecursionBlock);
                //}
            }
            UpdateEffects();
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Render a Renderer frame, assuming that the camera is in front of the Renderer and all conditions are met.
        /// </summary>
        /// <param name="camera">The camera rendering the Renderer</param>
        /// <param name="nearClipVerts">The vertices of the camera's near clip plane</param>
        private void TryRender(Camera camera, Vector3[] nearClipVerts)
        {
            if (!Target || !Rendering)
            {
                return;
            }
            //bool isVisible = false;
            var isVisible = false;

            //Check if the camera itself is behind the Renderer, even if the frustum isn't.

            if (!IsMirror)
            {
                if (!SKSGeneralUtils.IsBehind(camera.gameObject.transform.position, Origin.position, Origin.forward))
                {
                    isVisible = true;
                }
                else
                {
                    foreach (var v in nearClipVerts)
                    {
                        if (!SKSGeneralUtils.IsBehind(v, Origin.position, Origin.forward))
                        {
                            isVisible = true;
                            break;
                        }
                    }
                }
            }
            else
            {
                if (SKSGeneralUtils.IsBehind(camera.gameObject.transform.position, Origin.position, Origin.forward))
                {
                    isVisible = true;
                }
                else
                {
                    foreach (var v in nearClipVerts)
                    {
                        if (SKSGeneralUtils.IsBehind(v, Origin.position, Origin.forward))
                        {
                            isVisible = true;
                            break;
                        }
                    }
                }
            }


            if (isVisible || CheeseActivated != -1)
            {
                EffectCamera.RenderIntoMaterial(
                    camera, RenderMaterial,
                    MeshRenderer, Target.MeshRenderer,
                    MeshFilter.mesh, !NonObliqueOverride ? CheeseActivated == -1 : false,
                    Is3D, IsMirror, IsLowqEffect);
            }

            MeshRenderer.GetPropertyBlock(_seamlessRecursionBlock);
            SeamlessRecursionRenderer.SetPropertyBlock(_seamlessRecursionBlock);
        }