/// <summary>
        /// Start setup
        /// </summary>
        private void Start()
        {
            if (m_gaiaSettings == null)
            {
                m_gaiaSettings = GaiaUtils.GetGaiaSettings();
            }
            if (m_planarReflectionProbe == null)
            {
                m_planarReflectionProbe = FindObjectOfType <PlanarReflectionProbe>();
            }
            if (m_player == null)
            {
                m_player = GetThePlayer();
            }

            if (m_planarReflectionProbe != null)
            {
                OptimizePlanarReflections(m_planarReflectionProbe);
                #if UNITY_2019_1_OR_NEWER
                m_planarReflectionProbe.RequestRenderNextUpdate();
                #else
                m_planarReflectionProbe.RequestRealtimeRender();
#endif
            }
        }
Beispiel #2
0
        public static bool BakeReflectionProbeSnapshot(PlanarReflectionProbe probe)
        {
            var rt           = ReflectionSystem.NewRenderTarget(probe);
            var bakedTexture = probe.bakedTexture as Texture2D;
            var assetPath    = string.Empty;

            if (bakedTexture != null)
            {
                assetPath = AssetDatabase.GetAssetPath(bakedTexture);
            }
            if (string.IsNullOrEmpty(assetPath))
            {
                assetPath = GetBakePath(probe);
            }

            if (bakedTexture == null || string.IsNullOrEmpty(assetPath))
            {
                bakedTexture       = new Texture2D(rt.width, rt.height, TextureFormat.RGBAHalf, true, false);
                probe.bakedTexture = bakedTexture;

                EditorUtility.SetDirty(probe);
            }

            ReflectionSystem.Render(probe, rt);

            var art = RenderTexture.active;

            RenderTexture.active = rt;
            bakedTexture.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0, false);
            RenderTexture.active = art;

            WriteAndImportTexture(assetPath, bakedTexture);

            return(true);
        }
        /// <summary>
        /// Optimizes the planar reflections
        /// </summary>
        /// <param name="planarReflectionProbe"></param>
        private void OptimizePlanarReflections(PlanarReflectionProbe planarReflectionProbe)
        {
            if (planarReflectionProbe != null)
            {
                PlanarReflectionProbe planar = planarReflectionProbe;
                if (planar != null)
                {
#if !UNITY_2019_1_OR_NEWER
                    planar.mode        = UnityEngine.Rendering.ReflectionProbeMode.Realtime;
                    planar.refreshMode = UnityEngine.Rendering.ReflectionProbeRefreshMode.OnAwake;
                    planar.captureSettings.farClipPlane = 25f;
                    planar.captureSettings.overrides    = CaptureSettingsOverrides.FieldOfview;
                    planar.captureSettings.fieldOfView  = 90f;
                    planar.RequestRealtimeRender();
#else
                    planar.mode = ProbeSettings.Mode.Realtime;
#endif
                }

                HDAdditionalReflectionData data = planar.gameObject.GetComponent <HDAdditionalReflectionData>();
                if (data != null)
                {
#if !UNITY_2019_1_OR_NEWER
                    data.mode        = UnityEngine.Rendering.ReflectionProbeMode.Realtime;
                    data.refreshMode = UnityEngine.Rendering.ReflectionProbeRefreshMode.OnAwake;
                    data.captureSettings.farClipPlane = 250f;
                    data.captureSettings.fieldOfView  = 90f;
#else
                    data.mode = ProbeSettings.Mode.Realtime;
#endif
                }
            }
        }
Beispiel #4
0
        static void SetupCameraForRender(Camera camera, PlanarReflectionProbe probe, Camera viewerCamera = null)
        {
            float            nearClipPlane, farClipPlane, aspect, fov;
            Color            backgroundColor;
            CameraClearFlags clearFlags;
            Vector3          capturePosition;
            Quaternion       captureRotation;
            Matrix4x4        worldToCamera, projection;

            CalculateCaptureCameraProperties(probe,
                                             out nearClipPlane, out farClipPlane,
                                             out aspect, out fov, out clearFlags, out backgroundColor,
                                             out worldToCamera, out projection,
                                             out capturePosition, out captureRotation, viewerCamera);

            camera.farClipPlane        = farClipPlane;
            camera.nearClipPlane       = nearClipPlane;
            camera.fieldOfView         = fov;
            camera.aspect              = aspect;
            camera.clearFlags          = clearFlags;
            camera.backgroundColor     = camera.backgroundColor;
            camera.projectionMatrix    = projection;
            camera.worldToCameraMatrix = worldToCamera;

            var ctr = camera.transform;

            ctr.position = capturePosition;
            ctr.rotation = captureRotation;
        }
Beispiel #5
0
        public static void BakeCustomReflectionProbe(PlanarReflectionProbe probe, bool usePreviousAssetPath)
        {
            string path;

            if (!GetCustomBakePath(probe.name, probe.customTexture, true, usePreviousAssetPath, out path))
            {
                return;
            }

            PlanarReflectionProbe collidingProbe;

            if (IsCollidingWithOtherProbes(path, probe, out collidingProbe))
            {
                if (!EditorUtility.DisplayDialog("Texture is used by other reflection probe",
                                                 string.Format("'{0}' path is used by the game object '{1}', do you really want to overwrite it?",
                                                               path, collidingProbe.name), "Yes", "No"))
                {
                    return;
                }
            }

            EditorUtility.DisplayProgressBar("Planar Reflection Probes", "Baking " + path, 0.5f);
            if (!BakePlanarReflectionProbe(probe, path))
            {
                Debug.LogError("Failed to bake reflection probe to " + path);
            }
            EditorUtility.ClearProgressBar();

            AssetDatabase.ImportAsset(path);
            probe.customTexture = AssetDatabase.LoadAssetAtPath <Texture2D>(path);
            EditorUtility.SetDirty(probe);
        }
Beispiel #6
0
 static bool IsProbeCaptureMirrored(PlanarReflectionProbe probe, Camera viewerCamera)
 {
     return(viewerCamera != null &&
            probe.mode == ReflectionProbeMode.Realtime &&
            probe.refreshMode == ReflectionProbeRefreshMode.EveryFrame &&
            probe.capturePositionMode == PlanarReflectionProbe.CapturePositionMode.MirrorCamera);
 }
Beispiel #7
0
        static void CalculateMirroredCaptureCameraProperties(PlanarReflectionProbe probe, Camera viewerCamera, out float nearClipPlane, out float farClipPlane, out float aspect, out float fov, out CameraClearFlags clearFlags, out Color backgroundColor, out Matrix4x4 worldToCamera, out Matrix4x4 projection, out Vector3 capturePosition, out Quaternion captureRotation)
        {
            nearClipPlane = viewerCamera.nearClipPlane;
            farClipPlane  = viewerCamera.farClipPlane;
            aspect        = 1;
            fov           = probe.overrideFieldOfView
                ? probe.fieldOfViewOverride
                : Mathf.Max(viewerCamera.fieldOfView, viewerCamera.fieldOfView * viewerCamera.aspect);
            clearFlags      = viewerCamera.clearFlags;
            backgroundColor = viewerCamera.backgroundColor;

            var worldToCapture   = GeometryUtils.CalculateWorldToCameraMatrixRHS(viewerCamera.transform);
            var reflectionMatrix = GeometryUtils.CalculateReflectionMatrix(probe.captureMirrorPlanePosition, probe.captureMirrorPlaneNormal);

            worldToCamera = worldToCapture * reflectionMatrix;

            var clipPlane  = GeometryUtils.CameraSpacePlane(worldToCamera, probe.captureMirrorPlanePosition, probe.captureMirrorPlaneNormal);
            var sourceProj = Matrix4x4.Perspective(fov, aspect, nearClipPlane, farClipPlane);

            projection = GeometryUtils.CalculateObliqueMatrix(sourceProj, clipPlane);

            capturePosition = reflectionMatrix.MultiplyPoint(viewerCamera.transform.position);

            var forward = reflectionMatrix.MultiplyVector(viewerCamera.transform.forward);
            var up      = reflectionMatrix.MultiplyVector(viewerCamera.transform.up);

            captureRotation = Quaternion.LookRotation(forward, up);
        }
Beispiel #8
0
        public void RegisterProbe(PlanarReflectionProbe planarProbe)
        {
            m_PlanarReflectionProbes.Add(planarProbe);
            SetProbeBoundsDirty(planarProbe);

            if (planarProbe.mode == ReflectionProbeMode.Realtime)
            {
                switch (planarProbe.refreshMode)
                {
                case ReflectionProbeRefreshMode.OnAwake:
                    m_PlanarReflectionProbe_RequestRealtimeRender.Add(planarProbe);
                    break;

                case ReflectionProbeRefreshMode.EveryFrame:
                {
                    switch (planarProbe.capturePositionMode)
                    {
                    case PlanarReflectionProbe.CapturePositionMode.Static:
                        m_PlanarReflectionProbe_RealtimeUpdate.Add(planarProbe);
                        break;

                    case PlanarReflectionProbe.CapturePositionMode.MirrorCamera:
                        m_PlanarReflectionProbe_PerCamera_RealtimeUpdate.Add(planarProbe);
                        break;
                    }
                    break;
                }
                }
            }
        }
Beispiel #9
0
        public static HDCamera GetRenderHDCamera(PlanarReflectionProbe probe)
        {
            var camera = GetRenderCamera();

            probe.frameSettings.CopyTo(s_RenderCameraData.GetFrameSettings());

            return(HDCamera.Get(camera, null, probe.frameSettings));
        }
Beispiel #10
0
        static string GetBakePathFor(PlanarReflectionProbe probe)
        {
            var scene     = probe.gameObject.scene;
            var directory = Path.Combine(Path.GetDirectoryName(scene.path), Path.GetFileNameWithoutExtension(scene.path));
            var filename  = string.Format("PlanarReflectionProbe-{0}.exr", 0);

            return(Path.Combine(directory, filename));
        }
        static void DrawCapturePositionGizmo(PlanarReflectionProbe probe)
        {
            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            // Capture gizmo
            if (k_QuadMesh == null)
            {
                k_QuadMesh = Resources.GetBuiltinResource <Mesh>("Quad.fbx");
            }
            if (k_PreviewMaterial == null)
            {
                k_PreviewMaterial = new Material(Shader.Find("Debug/PlanarReflectionProbePreview"));
            }
            if (k_PreviewOutlineMaterial == null)
            {
                k_PreviewOutlineMaterial = new Material(Shader.Find("Hidden/UnlitTransparentColored"));
            }

            var proxyToWorld   = probe.proxyToWorld;
            var settings       = probe.settings;
            var mirrorPosition = proxyToWorld.MultiplyPoint(settings.proxySettings.mirrorPositionProxySpace);
            var mirrorRotation = proxyToWorld.rotation * settings.proxySettings.mirrorRotationProxySpace * Quaternion.Euler(0, 180, 0);
            var renderData     = probe.renderData;

            var gpuProj = GL.GetGPUProjectionMatrix(renderData.projectionMatrix, true);
            var gpuView = renderData.worldToCameraRHS;
            var vp      = gpuProj * gpuView;

            var cameraPositionWS  = Vector3.zero;
            var capturePositionWS = renderData.capturePosition;

            if (SceneView.currentDrawingSceneView?.camera != null)
            {
                cameraPositionWS = SceneView.currentDrawingSceneView.camera.transform.position;
            }
            if (ShaderConfig.s_CameraRelativeRendering != 0)
            {
                cameraPositionWS = Vector3.zero;
                // For Camera relative rendering, we need to translate with the position of the currently rendering camera
                capturePositionWS -= cameraPositionWS;
            }

            // Draw outline
            k_PreviewOutlineMaterial.SetColor("_Color", InfluenceVolumeUI.k_GizmoThemeColorBase);
            k_PreviewOutlineMaterial.SetPass(0);
            Graphics.DrawMeshNow(k_QuadMesh, Matrix4x4.TRS(mirrorPosition, mirrorRotation, Vector3.one * capturePointPreviewSize * 2.1f));

            k_PreviewMaterial.SetTexture("_MainTex", probe.texture);
            k_PreviewMaterial.SetMatrix("_CaptureVPMatrix", vp);
            k_PreviewMaterial.SetFloat("_Exposure", 1.0f);
            k_PreviewMaterial.SetVector("_CameraPositionWS", new Vector4(cameraPositionWS.x, cameraPositionWS.y, -cameraPositionWS.z, 0));
            k_PreviewMaterial.SetVector("_CapturePositionWS", new Vector4(capturePositionWS.x, capturePositionWS.y, -capturePositionWS.z, 0));
            k_PreviewMaterial.SetPass(0);
            Graphics.DrawMeshNow(k_QuadMesh, Matrix4x4.TRS(mirrorPosition, mirrorRotation, Vector3.one * capturePointPreviewSize * 2));
        }
        protected override void OnEnable()
        {
            m_SerializedHDProbe = new SerializedPlanarReflectionProbe(serializedObject);
            base.OnEnable();

            PlanarReflectionProbe probe = (PlanarReflectionProbe)target;

            probe.influenceVolume.Init(probe);
        }
Beispiel #13
0
 public void UnregisterProbe(PlanarReflectionProbe planarProbe)
 {
     m_PlanarReflectionProbes.Remove(planarProbe);
     m_PlanarReflectionProbeBounds.Remove(planarProbe);
     m_PlanarReflectionProbe_DirtyBounds.Remove(planarProbe);
     m_PlanarReflectionProbe_RequestRealtimeRender.Remove(planarProbe);
     m_PlanarReflectionProbe_RealtimeUpdate.Remove(planarProbe);
     m_PlanarReflectionProbe_PerCamera_RealtimeUpdate.Remove(planarProbe);
 }
Beispiel #14
0
        public RenderTexture NewRenderTarget(PlanarReflectionProbe probe)
        {
            var rt = new RenderTexture(m_Parameters.planarReflectionProbeSize, m_Parameters.planarReflectionProbeSize, 0, RenderTextureFormat.ARGBHalf);

            rt.useMipMap        = true;
            rt.autoGenerateMips = false;
            rt.name             = "PlanarProbeRT " + probe.name;
            rt.Create();
            return(rt);
        }
 public static void CalculateCaptureCameraProperties(PlanarReflectionProbe probe, out float nearClipPlane, out float farClipPlane, out float aspect, out float fov, out CameraClearFlags clearFlags, out Color backgroundColor, out Matrix4x4 worldToCamera, out Matrix4x4 projection, out Vector3 capturePosition, out Quaternion captureRotation, Camera viewerCamera = null)
 {
     if (viewerCamera != null
         && probe.mode == ReflectionProbeMode.Realtime
         && probe.refreshMode == ReflectionProbeRefreshMode.EveryFrame
         && probe.capturePositionMode == PlanarReflectionProbe.CapturePositionMode.MirrorCamera)
         CalculateMirroredCaptureCameraProperties(probe, viewerCamera, out nearClipPlane, out farClipPlane, out aspect, out fov, out clearFlags, out backgroundColor, out worldToCamera, out projection, out capturePosition, out captureRotation);
     else
         CalculateStaticCaptureCameraProperties(probe, out nearClipPlane, out farClipPlane, out aspect, out fov, out clearFlags, out backgroundColor, out worldToCamera, out projection, out capturePosition, out captureRotation);
 }
 public RenderTexture NewRenderTarget(PlanarReflectionProbe probe)
 {
     var rt = new RenderTexture(m_Parameters.planarReflectionProbeSize, m_Parameters.planarReflectionProbeSize, 0, RenderTextureFormat.ARGBHalf);
     // No hide and don't save for this one
     rt.useMipMap = true;
     rt.autoGenerateMips = false;
     rt.name = CoreUtils.GetRenderTargetAutoName(m_Parameters.planarReflectionProbeSize, m_Parameters.planarReflectionProbeSize, 1, RenderTextureFormat.ARGBHalf, "PlanarProbeRT");
     rt.Create();
     return rt;
 }
 public static void CalculateCaptureCameraViewProj(PlanarReflectionProbe probe, out Matrix4x4 worldToCamera, out Matrix4x4 projection, out Vector3 capturePosition, out Quaternion captureRotation, Camera viewerCamera = null)
 {
     float nearClipPlane, farClipPlane, aspect, fov;
     CameraClearFlags clearFlags;
     Color backgroundColor;
     CalculateCaptureCameraProperties(
         probe,
         out nearClipPlane, out farClipPlane,
         out aspect, out fov, out clearFlags, out backgroundColor,
         out worldToCamera, out projection, out capturePosition, out captureRotation,
         viewerCamera);
 }
Beispiel #18
0
        internal static void DrawGizmos(PlanarReflectionProbe d, GizmoType gizmoType)
        {
            HDProbeUI.DrawGizmos(d, gizmoType);

            HDProbeUI s;

            if (!HDProbeEditor.TryGetUIStateFor(d, out s))
            {
                return;
            }

            var mat = Matrix4x4.TRS(d.transform.position + d.transform.rotation * d.influenceVolume.offset, d.transform.rotation, Vector3.one);

            //gizmo overrides
            switch (EditMode.editMode)
            {
            case EditBaseShape:
                if (d.influenceVolume.shape != InfluenceShape.Box)
                {
                    break;
                }

                using (new Handles.DrawingScope(mat))
                {
                    s.influenceVolume.boxBaseHandle.center = Vector3.zero;
                    s.influenceVolume.boxBaseHandle.size   = d.influenceVolume.boxSize;
                    s.influenceVolume.boxBaseHandle.DrawHull(true);
                    s.influenceVolume.boxInfluenceHandle.center = d.influenceVolume.boxBlendOffset;
                    s.influenceVolume.boxInfluenceHandle.size   = d.influenceVolume.boxSize + d.influenceVolume.boxBlendSize;
                    s.influenceVolume.boxInfluenceHandle.DrawHull(false);
                    s.influenceVolume.boxInfluenceNormalHandle.center = d.influenceVolume.boxBlendNormalOffset;
                    s.influenceVolume.boxInfluenceNormalHandle.size   = d.influenceVolume.boxSize + d.influenceVolume.boxBlendNormalSize;
                    s.influenceVolume.boxInfluenceNormalHandle.DrawHull(false);
                }
                break;
            }

            if (!HDProbeEditor.TryGetUIStateFor(d, out s))
            {
                return;
            }

            if (s.showCaptureHandles || EditMode.editMode == EditCenter)
            {
                DrawGizmos_CaptureFrustrum(d);
            }

            if (d.useMirrorPlane)
            {
                DrawGizmos_CaptureMirror(d);
            }
        }
Beispiel #19
0
        static int GetProbePersistentID(PlanarReflectionProbe probe)
        {
            var scene = probe.gameObject.scene;

            if (!scene.IsValid())
            {
                return(-1);
            }

            var reflectionDictionary = GetReflectionDictionaryFor(scene);

            return(reflectionDictionary.GetIdFor(probe));
        }
Beispiel #20
0
        public void Render(PlanarReflectionProbe probe, RenderTexture target, Camera viewerCamera = null)
        {
            var renderCamera = GetRenderHDCamera(probe);

            renderCamera.camera.targetTexture = target;

            SetupCameraForRender(renderCamera.camera, probe, viewerCamera);
            GL.invertCulling = IsProbeCaptureMirrored(probe, viewerCamera);
            renderCamera.camera.Render();
            GL.invertCulling = false;
            renderCamera.camera.targetTexture = null;
            target.IncrementUpdateCount();
        }
        public RenderTexture NewRenderTarget(PlanarReflectionProbe probe)
        {
            var desc = GetRenderHDCamera(probe).renderTextureDesc;

            desc.width       = m_Parameters.planarReflectionProbeSize;
            desc.height      = m_Parameters.planarReflectionProbeSize;
            desc.colorFormat = RenderTextureFormat.ARGBHalf;
            desc.useMipMap   = true;
            var rt = new RenderTexture(desc);

            rt.name = "PlanarProbeRT " + probe.name;
            return(rt);
        }
        static void DrawGizmos_CaptureMirror(PlanarReflectionProbeUI s, PlanarReflectionProbe d)
        {
            var c = Gizmos.color;
            var m = Gizmos.matrix;

            Gizmos.matrix = Matrix4x4.TRS(
                d.captureMirrorPlanePosition,
                Quaternion.LookRotation(d.captureMirrorPlaneNormal, Vector3.up),
                Vector3.one);
            Gizmos.color = k_GizmoMirrorPlaneCamera;

            Gizmos.DrawCube(Vector3.zero, new Vector3(1, 1, 0));

            Gizmos.matrix = m;
            Gizmos.color  = c;
        }
Beispiel #23
0
        public void Render(PlanarReflectionProbe probe, RenderTexture target, Camera viewerCamera = null)
        {
            var renderCamera = GetRenderCamera();

            // Copy current frameSettings of this probe to the HDAdditionalData of the render camera
            probe.frameSettings.CopyTo(s_RenderCameraData.GetFrameSettings());

            renderCamera.targetTexture = target;

            SetupCameraForRender(renderCamera, probe, viewerCamera);
            GL.invertCulling = IsProbeCaptureMirrored(probe, viewerCamera);
            renderCamera.Render();
            GL.invertCulling           = false;
            renderCamera.targetTexture = null;
            target.IncrementUpdateCount();
        }
Beispiel #24
0
        public static HDCamera GetRenderHDCamera(PlanarReflectionProbe probe)
        {
            var camera = GetRenderCamera();

            probe.frameSettings.CopyTo(s_RenderCameraData.GetFrameSettings());

            var hdCamera = HDCamera.Get(camera);

            if (hdCamera == null)
            {
                // Warning: this is a bad design pattern.
                // An individual system should not create an HDCamera (which is a shared resource).
                hdCamera = HDCamera.Create(camera, null);
            }

            hdCamera.Update(probe.frameSettings, null, null);

            return(hdCamera);
        }
Beispiel #25
0
 public static bool IsCollidingWithOtherProbes(string targetPath, PlanarReflectionProbe targetProbe, out PlanarReflectionProbe collidingProbe)
 {
     PlanarReflectionProbe[] probes = Object.FindObjectsOfType <PlanarReflectionProbe>().ToArray();
     collidingProbe = null;
     foreach (var probe in probes)
     {
         if (probe == targetProbe || probe.customTexture == null)
         {
             continue;
         }
         var path = AssetDatabase.GetAssetPath(probe.customTexture);
         if (path == targetPath)
         {
             collidingProbe = probe;
             return(true);
         }
     }
     return(false);
 }
        static void CalculateStaticCaptureCameraProperties(PlanarReflectionProbe probe, out float nearClipPlane, out float farClipPlane, out float aspect, out float fov, out CameraClearFlags clearFlags, out Color backgroundColor, out Matrix4x4 worldToCamera, out Matrix4x4 projection, out Vector3 capturePosition, out Quaternion captureRotation)
        {
            nearClipPlane = probe.captureNearPlane;
            farClipPlane = probe.captureFarPlane;
            aspect = 1f;
            fov = probe.overrideFieldOfView
                ? probe.fieldOfViewOverride
                : 90f;
            clearFlags = CameraClearFlags.Nothing;
            backgroundColor = Color.white;

            capturePosition = probe.transform.TransformPoint(probe.captureLocalPosition);
            captureRotation = Quaternion.LookRotation((Vector3)probe.influenceToWorld.GetColumn(3) - capturePosition, probe.transform.up);

            worldToCamera = GeometryUtils.CalculateWorldToCameraMatrixRHS(capturePosition, captureRotation);
            var clipPlane = GeometryUtils.CameraSpacePlane(worldToCamera, probe.captureMirrorPlanePosition, probe.captureMirrorPlaneNormal);
            projection = Matrix4x4.Perspective(fov, aspect, nearClipPlane, farClipPlane);
            projection = GeometryUtils.CalculateObliqueMatrix(projection, clipPlane);
        }
        void OnEnable()
        {
            m_SerializedAsset = new SerializedPlanarReflectionProbe(serializedObject);
            m_UIState.Reset(m_SerializedAsset, Repaint);

            m_TypedTargets  = new PlanarReflectionProbe[targets.Length];
            m_UIHandleState = new PlanarReflectionProbeUI[m_TypedTargets.Length];
            for (var i = 0; i < m_TypedTargets.Length; i++)
            {
                m_TypedTargets[i]  = (PlanarReflectionProbe)targets[i];
                m_UIHandleState[i] = new PlanarReflectionProbeUI();
                m_UIHandleState[i].Reset(m_SerializedAsset, null);

                s_StateMap[m_TypedTargets[i]] = m_UIHandleState[i];
            }

            PlanarReflectionProbe probe = (PlanarReflectionProbe)target;

            probe.influenceVolume.Init(probe);
        }
Beispiel #28
0
        public static bool BakePlanarReflectionProbe(PlanarReflectionProbe probe, string path)
        {
            var rt = ReflectionSystem.NewRenderTarget(probe);

            ReflectionSystem.Render(probe, rt);
            var target = new Texture2D(rt.width, rt.height, TextureFormat.RGBAHalf, false, true);
            var a      = RenderTexture.active;

            RenderTexture.active = rt;
            target.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0, false);
            RenderTexture.active = a;
            rt.Release();

            if (!WriteAndImportTexture(path, target))
            {
                return(false);
            }

            return(true);
        }
Beispiel #29
0
        static void DrawSelectedGizmo(PlanarReflectionProbe probe, GizmoType gizmoType)
        {
            var e = (PlanarReflectionProbeEditor)GetEditorFor(probe);

            if (e == null)
            {
                return;
            }

            var mat = Matrix4x4.TRS(probe.transform.position, probe.transform.rotation, Vector3.one);

            InfluenceVolumeUI.DrawGizmos(
                probe.influenceVolume,
                mat,
                InfluenceVolumeUI.HandleType.None,
                InfluenceVolumeUI.HandleType.Base | InfluenceVolumeUI.HandleType.Influence
                );

            DrawCapturePositionGizmo(probe);
        }
Beispiel #30
0
        internal static void DrawGizmos(PlanarReflectionProbe d, GizmoType gizmoType)
        {
            HDProbeUI.DrawGizmos(d, gizmoType);

            HDProbeUI s;

            if (!HDProbeEditor.TryGetUIStateFor(d, out s))
            {
                return;
            }

            if (s.showCaptureHandles || EditMode.editMode == EditCenter)
            {
                DrawGizmos_CaptureFrustrum(d);
            }

            if (d.useMirrorPlane)
            {
                DrawGizmos_CaptureMirror(d);
            }
        }