Exemplo n.º 1
0
        // ********* Private functions *********
        public virtual void Init()
        {
            if (renderCameraObject == null)
            {
                //Setup new high resolution camera
                renderCameraObject = new GameObject("RenderCameraObject");
                renderCameraObject.transform.SetParent(transform);
                renderCameraObject.transform.position = Vector3.zero;
                renderCameraObject.transform.rotation = new Quaternion(0, 0, 0, 0);
                renderCameraObject.hideFlags          = HideFlags.HideInHierarchy | HideFlags.HideInInspector;

                // Setup components of new camera
                renderCamera          = renderCameraObject.AddComponent <Camera>();
                SSAA_Internal         = renderCameraObject.AddComponent <MadGoatSSAA_InternalRenderer>();
                SSAA_Internal.current = renderCamera;
                SSAA_Internal.main    = currentCamera;
                SSAA_Internal.enabled = true;

                // Copy settings from current camera
                renderCamera.CopyFrom(currentCamera);

                // Disable rendering on internal cam.
                // Nothing is drawn on main camera, performance hit is minimal
                renderCamera.cullingMask = 0;
                renderCamera.clearFlags  = CameraClearFlags.Nothing;
            }
            else
            {
                SSAA_Internal.enabled = true;
            }

            currentCamera.targetTexture = new RenderTexture(1024, 1024, 24, textureFormat);
            currentCamera.targetTexture.Create();
        }