예제 #1
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);
        }